WebAssembly / js-promise-integration

JavaScript Promise Integration
Other
68 stars 17 forks source link

Should returnPromiseOnSuspend always return a Promise #4

Closed eqrion closed 1 year ago

eqrion commented 2 years ago

returnPromiseOnSuspend is specified to either:

  1. Return a Promise if the wrapped export eventually was suspended
  2. Return the results of the wrapped export

If the wrapped export itself returns a Promise, it's not possible to tell whether the wrapped export was suspended or if it returned normally. This is definitely a corner case, so I don't know whether it's a real issue or not.

An alternative would be to returned Promise.resolve(wrappedExportResults) in the case the wrapped export returns normally.

RossTate commented 2 years ago

My recollection of when we discussed the alternative you suggested is that it's easier for the user of the module to apply Promise.resolve to the export themselves than it would be for the user to "undo" always applying Promise.resolve in the exported function should they want the more direct/unflattened behavior.

fgmccabe commented 1 year ago

Closing as its a duplicate of another issue. wrapped exports will always return a Promise; but a future version may allow programmer to specify a different behavior.