1 Star 0 Fork 0

301_bobbyboy/promise-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
core.js 692 Bytes
一键复制 编辑 原始数据 按行查看 历史
301_bobbyboy 提交于 2024-02-23 17:58 . update
console.log("core.js")
class CorePromise {
static PENDING = "pending"
static FULFILLED = "fulfilled"
static REJECTED = "rejected"
constructor(executor) {
this.status = CorePromise.PENDING
this.value = undefined
executor(this.resolve.bind(this), this.reject.bind(this))
}
resolve (value) {
if (this.status === CorePromise.PENDING) {
this.status = CorePromise.FULFILLED
this.value = value
}
}
reject (reason) {
if (this.status === CorePromise.PENDING) {
this.status = CorePromise.REJECTED
this.value = reason
}
}
}
const res = new CorePromise((resolve, reject) => {
resolve(1)
})
console.log(res)
console.log('123')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/bobbyboy/promise-core.git
git@gitee.com:bobbyboy/promise-core.git
bobbyboy
promise-core
promise-core
master

搜索帮助