Skip to content
/ Promise Public

Promise/a+规范的部分实现, 研究primomise机制使用

Notifications You must be signed in to change notification settings

meooxx/Promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Promise/a+部分实现

实现了部分的 Promise/a+ 规范.只用于学习理解使用, 所以只简单测过几个 case, 不可用于生产环境. 另外.catch, .finally, .all 等. 其实都很好实现, 类似于或者基于.then, 看一下明白了. .all() 稍微复杂一点, 但是也没有什么东西, 理解就完事了. 懒癌晚期

==> 等同于 下一步

  • new Promise(fn) ==> call(fn), with resolve, reject arguments
  • resolve(value) ==> resolve Promise value/resolve function value/resolve value
  • and else promise.state = 1, iterate hander[], calling every handler, with promise.value
  • then(handler), if pedding, push to handler[], else, before the next eventLoop, res = onFulfill(state.value)/onReject(state.value), and resolve the handler promise with res

Reference

About

Promise/a+规范的部分实现, 研究primomise机制使用

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published