parole

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

MIT 46 个版本
安装
npm install parole
yarn add parole
pnpm add parole
bun add parole
README

Parole

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

ᴋɪʟᴛ ᴊs npm Build Status codecov GitHub license

Installation

npm install parole

# alternatively you can use bower (minified version by default)
yarn add parole

ES6 fulfill

Parole implements ES6 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
// 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

checkpoint 1 gogogo!
checkpoint 2.1 whoops!
# elapsed 400ms
checkpoint 3 all right!
版本列表
2.0.28 2023-06-27
2.0.27 2023-06-08
2.0.26 2023-04-24
2.0.25 2023-04-19
2.0.24 2023-04-19
2.0.23 2023-04-19
2.0.22 2023-04-19
2.0.20 2023-04-18
2.0.15 2022-11-03
2.0.14 2022-11-03
2.0.12 2022-10-20
2.0.11 2022-10-20
2.0.10 2022-10-20
2.0.9 2022-10-20
2.0.8 2022-10-20
2.0.7 2022-10-20
2.0.6 2022-10-19
2.0.5 2022-10-19
2.0.4 2022-10-19
2.0.3 2022-10-19
2.0.2 2022-10-19
2.0.1 2022-10-19
2.0.0 2022-10-19
1.1.30 2018-12-07
1.1.29 2018-12-04
1.1.24 2018-08-22
1.1.23 2018-08-22
1.1.22 2018-08-09
1.1.21 2018-08-03
1.1.20 2018-08-03
1.1.19 2018-08-03
1.1.18 2018-06-01
1.1.17 2018-03-06
1.1.16 2018-03-06
1.1.14 2018-03-06
1.1.11 2018-02-18
1.1.10 2018-02-18
1.1.9 2018-02-18
1.1.8 2018-02-18
1.1.7 2018-02-18
1.1.5 2017-04-28
1.1.4 2017-04-17
1.1.3 2017-02-04
1.1.2 2017-01-11
1.0.1 2016-12-10
1.0.0 2016-12-10