Create a fake promise that can be resolve and rejected programatically
MIT License
Create a promise that can be resolved and rejected programatically outside of it
It basically extracts the resolve
and reject
callbacks so you can call them whenever you need.
⚠️ The promise can only be resolved once, it's still a regular Promise after all.
npm i faked-promise
faked-promise exports one single function that takes no arguments and returns an array with 3 elements:
resolve
callbackreject
callbackMeaning you can control exactly when the promise is resolved or rejected:
const fakePromise = require('faked-promise')
const [promise, resolve, reject] = fakePromise()
promise.then(() => {})
resolve('any value')