You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check to determine if global.Promise is native promise #557
The “official” way would be value instanceof Promise, the “correct” way that works across VM contexts would be process.binding('util').isPromise(value) (see nodejs/node-eps#44 for a proposal turning the latter into a public Node API).
process.binding('util') is the same as require('util') or no?
No, process.binding() gives you direct access to Node’s internal C++ APIs. It’s not part of our public API, so don’t rely on it being there forever. (Sorry – I fear that’s the best answer we have right now. If you want something more reliable, maybe engage in nodejs/node-eps#44 …)
Activity
addaleax commentedon Mar 29, 2017
The “official” way would be
value instanceof Promise, the “correct” way that works across VM contexts would beprocess.binding('util').isPromise(value)(see nodejs/node-eps#44 for a proposal turning the latter into a public Node API).ORESoftware commentedon Mar 29, 2017
hmmm
sorry, I should been more detailed
but the second methodology should work I think, right?
addaleax commentedon Mar 29, 2017
Ah, right, should have read that you were asking for checking
global.Promise, not a promise.Yes, the second way should work.
ORESoftware commentedon Mar 29, 2017
process.binding('util')is the same asrequire('util')or no?addaleax commentedon Mar 29, 2017
No,
process.binding()gives you direct access to Node’s internal C++ APIs. It’s not part of our public API, so don’t rely on it being there forever. (Sorry – I fear that’s the best answer we have right now. If you want something more reliable, maybe engage in nodejs/node-eps#44 …)ORESoftware commentedon Mar 29, 2017
sure will do thanks!