observablehq / runtime

The reactive dataflow runtime that powers Observable Framework and Observable notebooks
https://observablehq.com/@observablehq/how-observable-runs
ISC License
1.01k stars 71 forks source link

check if object is a promise instead of just awaiting it. #343

Closed Kreijstal closed 2 years ago

Kreijstal commented 2 years ago

I wanted to use @masala/parser which uses objects that have .then methods, they are however NOT promises. which means they break on observable.

Example: ({ then: (_) => _(3) }) shouldn't be awaited since it isn't a promise..

mbostock commented 2 years ago

The behavior is the same as Promise.resolve, so yes, we do await all thenables and not just literal promises. You can read about the specification here: https://promisesaplus.com/