I am looking for a way, with Node v7.6 or higher, to get the Bluebird Promise (or any non-native promise) when an asynchronous function is called.
In the same way I can do:
global.Promise = require('Bluebird');
var getResolvedPromise = () => Promise.resolve('value');
getResolvedPromise
.tap(...)
.then(...);
See: Can I use global.Promise = require ("bluebird")
I want to be able to do something like:
global.Promise = require('Bluebird');
var getResolvedAsyncAwaitPromise = async () => 'value';
getResolvedAsyncAwaitPromise()
.tap(...)
.then(...);
I know that I can use something like:
Bluebird.resolve(getResolvedAsyncAwaitPromise())
.tap(...);
But I was curious if there would be a way to change the default promise returned AsyncFunction. The constructor is as follows:
Note that AsyncFunction is not a global object. This can be obtained by evaluating the following code.
Object.getPrototypeOf(async function(){}).constructor
MDN link to AsyncFunction
AsyncFunction Promise, .
!