ECMA Script already have a difinition about Promise, so is there a reason that Promise/A+ exits?
-
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 8:47
-
@jonrsharpe if i want to wirte my own Promise obj, which spec should I follow? – bytefish Nov 17 '18 at 8: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 8:51
-
A+ has a test conformance suite which you can use to test your implementation. Not sure ECMAScript has a dedicated one. – avo Nov 17 '18 at 9:24
-
If interested, you could have a look at my personal documented attempt 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
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
-
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