lie

A basic but performant promise implementation

MIT 47 个版本
安装
npm install lie
yarn add lie
pnpm add lie
bun add lie
README

lie

[![Build Status](https://travis-ci.org/calvinmetcalf/lie.svg)](https://travis-ci.org/calvinmetcalf/lie)

lie is a small, performant promise library implementing the Promises/A+ spec (Version 1.1).

Originally a fork of Ruben Verborgh's promiscuous, with version 2.6 it became a fork of ayepromise by Chris Burgmer.

npm install lie

var Promise = require('lie');
// or use the pollyfill
require('lie/polyfill');

Usage

Either use it with browserify (recommended) or grab one of the files from the dist folder:

  • lie.js/lie.min.js exposes 'Promise' either as a UMD module or from the global scope, depending on if a CJS or AMD loader is available.
  • lie.polyfill.js/lie.polyfill.min.js adds 'Promise' to the global scope only if it's not already defined (not a UMD).

API

Implements the standard ES6 api:

new Promise(function(resolve, reject){
    doSomething(function(err, result) {
        if (err) {
            reject(err);
        } else {
            resolve(result);
        }
    });
}).then(function (value) {
    //on success
}, function (reason) {
    //on error
}).catch(function (reason) {
    //shortcut for error handling
});

Promise.all([
    //array of promises or values
]).then(function ([/* array of results */]));

Promise.race([
    //array of promises or values
]);
// either resolves or rejects depending on the first value to do so

Unhandled Rejections

In Node.js, lie emits an unhandledRejection event when a rejected promise isn't caught, in line with how io.js does it. This allows it to act as a promise shim in both Node.js and the browser.

版本列表
3.3.0 2018-03-06
3.2.0 2018-01-29
3.1.1 2017-02-09
3.1.0 2016-07-27
3.0.4 2016-04-30
3.0.3 2016-04-30
3.0.2 2016-01-21
3.0.1 2015-08-06
3.0.0 2015-07-30
2.9.1 2015-05-27
2.9.0 2015-05-26
2.8.1 2015-01-07
2.8.0 2014-09-19
2.7.7 2014-07-01
2.7.6 2014-06-04
2.7.5 2014-06-04
2.7.4 2014-05-08
2.7.3 2014-05-05
2.7.2 2014-05-04
2.7.0 2014-05-02
2.6.0 2014-03-14
2.5.4 2014-03-10
2.5.3 2014-01-30
2.5.2 2014-01-12
2.5.1 2014-01-08
2.5.0 2014-01-08
2.4.0 2013-12-19
2.3.0 2013-10-31
2.2.1 2013-10-28
2.2.0 2013-10-28
2.1.0 2013-10-26
2.0.7 2013-10-24
2.0.6 2013-10-11
2.0.5 2013-10-01
2.0.3 2013-09-27
2.0.1 2013-09-25
2.0.0 2013-09-25
1.4.0 2013-09-22
1.3.0 2013-09-19
1.1.0 2013-09-17
1.0.3 2013-08-31
1.0.0 2013-08-30
0.6.2 2013-08-17
0.6.1 2013-08-17
0.6.0 2013-08-17
0.5.1 2013-08-17
0.5.0 2013-08-16