Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于 thenable 对象的处理 #1

Open
mqyqingfeng opened this issue Aug 2, 2018 · 2 comments
Open

关于 thenable 对象的处理 #1

mqyqingfeng opened this issue Aug 2, 2018 · 2 comments

Comments

@mqyqingfeng
Copy link

首先感谢这个库让我更多的了解了 Promise 的实现,(๑•̀ㅂ•́)و✧

其次是模仿实现的时候,发现了一个问题:

let thenable = {
  then: function(resolve, reject) {
    resolve({
        then: function(resolve, reject) {
            resolve({
                then: function(resolve, reject) {
                    resolve(42)
                }
            })
        }
    })
  }
};

var promise1 = new Promise((resolve, reject) => {
    resolve(thenable)
})

promise1
.then(function(value) {
    console.log(value)
})

浏览器原生的 Promise 会打印 42
这个库会打印 thenable 对象

@xieranmaya
Copy link
Owner

xieranmaya commented Aug 5, 2018 via email

@nzhl
Copy link

nzhl commented Jan 20, 2019

已经修复 #3 , 请求接受 PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants