domenic / promises-unwrapping

The ES6 promises spec, as per September 2013 TC39 meeting
1.23k stars 94 forks source link

Deduplicate thenable coercion, and bring back thenable coercions weak map #62

Closed domenic closed 10 years ago

domenic commented 10 years ago

The code of ThenableToPromise and Promise Reaction Functions both does a form of thenable coercion:

These are pretty similar, but I believe I'm making them unnecessarily distinct in my current set up. E.g., if I moved some of the caller behavior into the former, the parallel would be clearer.

Once these functions are deduplicated, I will probably have an easier time reintroducing the thenable coercions weak map. I gave it a stab in bring-back-thenable-coercions branch but it did not pass the existing tests because I only did it inside ThenableToPromise and not inside Promise Reaction Functions.

I am reasonably happy with the verbiage surrounding the weak map in that branch, so the work here subsumes #39. Also I can try to be sure not to reintroduce any reentrance bugs, so let's subsume #61 in here too.