parole

Another ES6 promise implementation (compliant with Promises/A+)

  • parole

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
parole
2.0.28a year ago7 years agoMinified + gzip package size for parole in KB

Readme

Parole
Promises/A+ logo

Another ES6 promise implementation (compliant with Promises/A+)
ᴋɪʟᴛ ᴊs npm Build Status codecov GitHub license

Installation

```.sh npm install parole
alternatively you can use bower (minified version by default)
yarn add parole
### ES6 fulfill

> `Parole` implements [ES6 Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) specs

Implements:
- Promise.prototype.then
- Promise.prototype.catch
- Promise.prototype.finally

Also static methods
- Promise.resolve
- Promise.reject
- Promise.all
- Promise.allSettled
- Promise.any
- Promise.race

Includes:
- Promise.defer

``` js
// parole respects the es6 promise specification
// you can use parole as global polyfill

if( !window.Promise ) {
  window.Promise = Parole;
}

Example

new Parole((resolve, reject) => {
    resolve('gogogo!')
  })

  .then((result) => {
    console.log('checkpoint 1', result)
    throw 'whoops!'
  })

  .then(
    (result) => {
      console.log('checkpoint 2', result)
    },
    (result) => {
      console.log('checkpoint 2.1', result)
      return new Parole((resolve, reject) => {
        setTimeout(() => resolve('all right!'), 400)
      })
    },
  )

  .then(
    (result) => console.log('checkpoint 3', result),
    (reason) => console.log('checkpoint 3.1', reason),
  )
;
output

```.sh checkpoint 1 gogogo! checkpoint 2.1 whoops!
elapsed 400ms
checkpoint 3 all right! ```