promises-aplus-robin is a lightweight Promises/A+ implementation that is able to detect circular thenable chain. Except for the features defined in the Promises/A+ Standard, more features can be found in the extended version.
- Promise/A+ standard
- detecting thenable cycle
-
MyPromise.prototype.catch
-
MyPromise.prototype.finally
-
MyPromise.resolve
-
MyPromise.reject
-
MyPromise.all
-
MyPromise.race
- ......
- raw version: promises-aplus-robin.js
- annotated version: promises-aplus-robin-annotated.js
- extended version: promises-aplus-robin-extended.js
- hack version: promises-aplus-robin-hack.js
The extended version is used for supporting some features that is excluded in Promises/A+ standard but can be found in modern browsers.
The hack version is used for adapting the following case. The explanation can be found at 我以为我很懂Promise,直到我开始实现Promise/A+规范.
Promise.resolve().then(() => {
console.log(0);
return Promise.resolve(4);
}).then((res) => {
console.log(res)
})
Promise.resolve().then(() => {
console.log(1);
}).then(() => {
console.log(2);
}).then(() => {
console.log(3);
}).then(() => {
console.log(5);
}).then(() =>{
console.log(6);
})
The implementation of Promise/A+ can be tested by promises-tests.
npm run test