paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

Update Promise implementation to match latest ES6 spec. #345

Closed cscott closed 9 years ago

cscott commented 9 years ago

Includes the erratum for Promise.resolve discussed in #344.

Also fixes the Map/Set constructors, since the spec uses [[Construct]] now instead of a hidden create method, and the previous version misapplied Symbol.species in this role.

Also added ES.IteratorClose and updated a number of places where that is used in the latest spec, including in the implementation of Array.from.

Fixes issue #239 and #344.

ljharb commented 9 years ago

Thanks for doing this! I think the "default species" stuff, and the "Array.from" stuff, might work better as separate PRs first, to keep this one smaller.

cscott commented 9 years ago

Splitting the patch would require me to fixup the old implementation of Promises, just before I got rid of it. I'd prefer not to waste the effort, assuming you can manage reviewing this as is.

ljharb commented 9 years ago

Hm, it seems like you could leave the Promise implementation and ES.Construct alone in the first PR, and get in the addDefaultSpecies and new ES methods separately? If you don't think it would add much then that's fine.

ljharb commented 9 years ago

(also it looks like the tests are failing because we're not clobbering the native Promise when some of the new tests fail)

cscott commented 9 years ago

Updated the patch to fix the wrapping-paren issue, and added a test on Promise.resolve() which should correct the test failures.

ljharb commented 9 years ago

Thanks for bearing with me - this looks awesome, much appreciated