# ty-step

> 简单的异步流程控制方法，可以并行和串行执行给出的方法序列，适用于nodejs和浏览器环境

Latest version **1.0.1** (published 2017-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install ty-step
pnpm add ty-step
yarn add ty-step
bun add ty-step
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-02-12 |
| First published | 2017-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | tingyuan |
| Maintainers | tingyuan |
| Keywords | control-flow, async, sync, step, parallel, serial, executor |

## Links

- npm: https://www.npmjs.com/package/ty-step
- Repository: https://github.com/lovetingyuan/ty-step
- Homepage: https://github.com/lovetingyuan/ty-step#readme
- Issues: https://github.com/lovetingyuan/ty-step/issues
- npm.io page: https://npm.io/package/ty-step

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-02-12
- 1.0.0 — 2017-02-12

## README

# ty-step
异步流程控制，可以以并行或串行的方式执行给定的函数序列，支持参数传递和错误捕获

Inspired by [`step`](https://github.com/creationix/step) and [`gulp-sequence`](https://github.com/teambition/gulp-sequence)

---------
## Install
`npm install ty-step`

## Usage

```javascript
var step = require('ty-step')
var af = function(time) {
	return function(next, payload) {
		setTimeout(function() {
			next(null, time)
		}, time)
	}
}
var task = step(af(200), af(100), [af(150), af(80), af(250)], af(400), af(50))
task(function(err, payload) {
	if(err)
		console.error(err)
	else
		console.log(payload) // payload = [200, 100, [80, 150, 250], 400, 50]
})
```

`step`接收一系列的函数或者由函数组成的数组作为参数，这些函数代表要执行的任务，接收`next`和`payload`作为参数。`next`在任务结束时调用，传入的参数为`error`和`data`，`error`代表上一个函数是否发生了错误，若不为`null`则表示发生了错误，会中断执行后续函数，`data`表示上一个函数中`next`传递的结果。`step`返回一个函数，该函数接收一个`callback`作为参数，表示对最终结果的处理，同样接收`error`和`data`作为参数

## License
**MIT**

---
_Source: https://npm.io/package/ty-step · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
