with-promise
An extended promise to keep the context persistently
Installation
npm install with-promise
In browser:
In an AMD loader:
;
In nodejs:
var WithPromise = ;
Features
- Extended Promise, make all
.then()
,.catch()
handlers be executed with your assigned context:this
.
Notice
You should use polyfills providing Promise to ensure with-promise works well. You can try polyfill.io or polyfills.io. For nodejs, you can try es6-promise or ypromise.
Usage
var WithPromise = ; // create a Promise by a resolver function and set contextvar myPromise = WithPromise; // create a resolved Promisevar myPromise = WithPromise; // create a rejected Promisevar myPromise = WithPromise; // wrap Promise.all with contextvar allPromises = WithPromiseallpromises context; // all this == contextmyPromise;