有没有办法在Node.js中替换本机Promise构造函数而不在每个文件的基础上执行它(这样第三方库也将使用它)?
以下不起作用:
global.Promise = require('bluebird');
const foo = (cb) => cb('hello');
Promise.fromCallback(cb => foo(cb)) // TypeError: Promise.fromCallback is not a function
.tap(val => console.log(val))
.then(val => { console.log('fromCallback is supported!') });