clean-promise
A minimal and clean implement of JavaScript ES6 Promise, which passes all standard test cases.
Installation
> npm install clean-promise --save
Usage
You can use it like this in your own code:
const Promise = ; PromiseallPromise 2 3 ;
APIs
.then([function(any value) onResolved], [function(any error) onRejected]) -> Promise
.catch(function(any error) onRejected) -> Promise
.spread(function(any values...) cb, [onRejected]) -> Promise
.all(Iterable<any> | Promise<Iterable<any>> input) -> Promise
.map(function(any item, int index, int length) mapper, [function(any error) onRejected]) -> Promise
.return(Promise<any> | any value) -> Promise
.tap([function(any value) onResolved]) -> Promise
Promise.resolve(Promise<any> | any value) -> Promise
Promise.reject(any error) -> Promise
Promise.all(Iterable<any> | Promise<Iterable<any>> input) -> Promise
Promise.map(Iterable<any> | Promise<Iterable<any>> input, function(any item, int index, int length) mapper) -> Promise
Promise.race(Iterable<any> | Promise<Iterable<any>> input) -> Promise
Promise.try(function() fn) -> Promise
Features
- multiple ES6 features are applied: const/let, Class, Symbol, => etc
- clean, explict and fast
- both available on back-end and front-end
Test
> npm test
ChangeLog
V 1.1.1 - 2016.08.30
- simplify and optimize code
- update README
V 1.1.0 - 2016.08.26
- fix async bugs in .all & .return
- add .tap API
V 1.0.0 - 2016.08.26
- finish all basical functions
- do some basical tests
- fix async bugs in Promise.all & Promise.map
- add .map API
License
MIT