Our great sponsors
-
promises-spec
An open standard for sound, interoperable JavaScript promises—by implementers, for implementers.
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
A fourth twist is to take off the functional hat and instead use an obscure corner of OOP: multiple inheritance. This isn't natively supported in JS, but some libraries use the technique in the wild (e.g. zx monkeypatches Promises with a facade over the ChildProcess interface). This differs from union types because it's two things simultaneously (rather than one OR the other), and it's up to the consumer to then await it or map over the functor if it needs to, or just access properties synchronously.
The promise-with-special-semantics thing you propose is a flavor of what's called a thenable (something that looks like a promise but has different semantics). The idea isn't new; it was debated to death way back when the promise specification effort was still called A+. Early versions of jQuery had thenables and so did early versions of Angular.js.