Is it possible to make the following function?
const method = () => {
let _reject;
const promise = new Promise((resolve, reject) => {
_reject = reject;
...
});
return {
...promise,
cancel: () => _reject('cancelled'),
}
}
i.e. I can do something like:
const promise = method();
// now I have promise.then, promise.catch and promise.cancel
This is just an example; I want to be able to add extra properties to this "promise" object.