Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xiongwilee/promise-generator
Promise 顺序执行器
https://github.com/xiongwilee/promise-generator
Last synced: 3 months ago
JSON representation
Promise 顺序执行器
- Host: GitHub
- URL: https://github.com/xiongwilee/promise-generator
- Owner: xiongwilee
- License: mit
- Created: 2017-09-30T07:24:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-10T05:57:57.000Z (about 7 years ago)
- Last Synced: 2024-10-05T01:47:08.747Z (3 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Promise generator
简单可依赖的Promise 顺序执行(串行执行)器。
[![Build Status](https://travis-ci.org/xiongwilee/promise-generator.svg?branch=master)](https://travis-ci.org/xiongwilee/promise-generator) [![npm version](https://img.shields.io/npm/v/promise-generator.svg?style=flat)](https://npmjs.org/package/promise-generator) [![download](https://img.shields.io/npm/dm/promise-generator.svg?style=flat)](https://npmjs.org/package/promise-generator)
## 安装
```shell
$ npm install promise-generator
```## 使用
```javascript
const pg = require('promise-generator')const promises = [() => {
return Promise.resolve(0)
}, () => {
return new Promise((resolve) => {
resolve(1)
})
}, () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(2)
}, 100)
})
}, () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(3)
}, 100)
})
}, () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(4)
}, 100)
})
}]pg(promises).then((data) => {
console.log(data); // 300ms+之后输出:[0,1,2,3,4]
})
```## 贡献
欢迎大家提issue、fork;有任何疑问也可以邮件联系:xiongwilee[at]foxmail.com。