According to Bluebird documentation about promisification:
If the object already has a promisified version of the method, it will be skipped.
In fact, the promisifyAll()
also creates an Async
version of an already promisified function, which is expected to be:
idempotent in the sense that promisified functions are instantly returned back.
As pointed in Issue Idempotent promisify #159
So in the following example, I was expecting that both obj.foo()
and obj.fooAsync()
have the same result.
let obj = {
foo: function(){
return Promise.resolve('I am foo!!!')
}
}
obj = Promise.promisifyAll(obj)
obj.foo().then(msg => console.log(msg)) // > I am foo
obj.fooAsync().then(msg => console.log(msg)) // prints nothing
Which part am I misunderstanding?
Running example here
via Miguel Gamboa
No comments:
Post a Comment