ES Promise | bluebird
bluebird是一个第三方Promise规范实现库,它不仅完全兼容原生Promise对象,且比原生对象功能更强大,bluebird号称速度是所有 Promise 库里最快的。
导入:
npm install bluebird --save
使用
var Promise = require("bluebird");
ES6写法:
import * as Promise from "bluebird";
or
import {Promise} from "bluebird";
基本使用:
import {Promise} from "bluebird"; const promise = new Promise((resolve,reject) => { setTimeout(()=> { resolve('foo') },3000) }) promise.then((value) => { console.log(value) // foo })
bluebirds官网API doc:
http://bluebirdjs.com/docs/api-reference.html
IBM Developer:
https://developer.ibm.com/zh/articles/wa-lo-use-bluebird-implements-power-promise/
博客:
https://itbilu.com/nodejs/npm/VJHw6ScNb.html#api-new-promise