Skip to content

cumt-robin/promises-aplus-robin

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

promises-aplus-robin

Promises/A+ logo

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.

Supported Features

  • Promise/A+ standard
  • detecting thenable cycle
  • MyPromise.prototype.catch
  • MyPromise.prototype.finally
  • MyPromise.resolve
  • MyPromise.reject
  • MyPromise.all
  • MyPromise.race
  • ......

Versions

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);
})

Testing

The implementation of Promise/A+ can be tested by promises-tests.

npm run test

About

a lightweight Promises/A+ implementation that is able to detect circular thenable chain.

Resources

License

Stars

Watchers

Forks

Packages

No packages published