Promise from scratch从零实现 Promise

Three versions, each doing more than the last: simple.js stores a state and calls the waiting callbacks, promise-a+.js passes all 872 Promises/A+ tests, and index.js is a class with catch, finally, all and race. The numbers below come from two chained then calls on the class version.

三个版本,一个比一个完整:simple.js 保存状态,并调用等待中的回调;promise-a+.js 通过了全部 872 项 Promises/A+ 测试;index.js 是一个 class,带有 catch、finally、all 和 race。下面的数字来自在 class 版本上串联的两次 then 调用。