News for hackers. Stuff that matters.
Re:A generically typed pipe function in TypeScript by dan-robertson on Sunday August 07, 2022 @03:27PM (#32379075)
Is there an implementation where ‘then’ is added to Object.prototype as:

  function(f, ...preargs) { return f(...preargs, this) }
And then you can use it to pipeline sync and async things together? It’s still kinda bad and seems pretty crazy though. Some obvious issues are:

- the preargs thing presumably doesn’t work for promises so you’d need to use bind.

- there’s no great way to specify ‘the function which is property foo of the object being operated on’ to e.g. map an array that is in a promise you can’t write .then(.map, …). But I think this is also a problem with other pipe implementations.

Re:A generically typed pipe function in TypeScript by AprilArcus on Monday August 08, 2022 @02:09AM (#32382794)
I think `Object.prototype.then` would break every source file that uses `typeof o?.then === 'function'` as a check for PromiseLike behavior.