ECMA Script already have a difinition about Promise, so is there a reason that Promise/A+ exits?
Asked
Active
Viewed 144 times
3
-
2It exists because that "already", although true now, *wasn't* true at the time the A+ specs were written. Native promises are a relatively new feature. – jonrsharpe Nov 17 '18 at 08:47
-
@jonrsharpe if i want to wirte my own Promise obj, which spec should I follow? – Shuai Li Nov 17 '18 at 08:50
-
@saltfish try both and see which works best for you... only one way to find out and that would be by trying. – NewToJS Nov 17 '18 at 08:51
-
A+ has a [test conformance suite](https://github.com/promises-aplus/promises-tests) which you can use to test your implementation. Not sure ECMAScript has a dedicated one. – avo Nov 17 '18 at 09:24
-
If interested, you could have a look at my personal documented [attempt](https://stackoverflow.com/a/42057900/5459839) on implementing a Promise object based on the original Promise/A+ specs (that existed before ES6), with references to each requirement in the code comments. – trincot Nov 17 '18 at 10:18
1 Answers
4
Its actually the other way round. The Promise/A+ spec was written first and then implemented in JS using bluebird and other libraries. Then the authors of the ECMA spec saw a need to natively support it, and added it to the ES 6 spec. There is no real difference between them as the ES spec follows the A+ spec. source

Jonas Wilms
- 132,000
- 20
- 149
- 151
-
Native promises are *conformant*, that doesn't mean there aren't differences. Although they support the thenable interface, for example, native promises are also catchable. – jonrsharpe Nov 17 '18 at 10:45