Hacker News new | ask | show | jobs
by stby 995 days ago
I had a hard time reading the example until I applied the "normal" JS indentation, that would also likely be applied by Prettier and the likes.

  V(greeting,         // initial value  "hi"
      V(capitalize),  // custom function call  "Hi"
      V.concat("!"),  // String method `concat` call  "Hi!"
      V(send),        // custom async function call  Promise { <pending> }
      V.status,       // automatic promise chaining + getting property  Promise { 200 }
      V(console.log), // automatic promise chaining + global function call  logs 200
  )

It's certainly a nice usage of JavaScript's Proxy object and the resulting syntax is simple to grasp. Also glad to see the TS definitions in there. Well done!
1 comments

Author here. Thanks for your nice comment. I added a note to show the "normal" autoformatted syntax.