Giter Site home page Giter Site logo

t-roc / promises-aplus-robin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cumt-robin/promises-aplus-robin

0.0 0.0 0.0 20 KB

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

License: MIT License

JavaScript 100.00%

promises-aplus-robin's Introduction

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

promises-aplus-robin's People

Contributors

cumt-robin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.