# yieldflow

> > Asynchronous becomes synchronous with the yield

Latest version **0.0.2** (published 2016-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install yieldflow
pnpm add yieldflow
yarn add yieldflow
bun add yieldflow
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-03-04 |
| First published | 2016-03-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Eleven Chen |
| Maintainers | eleven |
| Keywords | yield |

## Links

- npm: https://www.npmjs.com/package/yieldflow
- Repository: https://github.com/skyhacker2/yieldflow
- Homepage: https://github.com/skyhacker2/yieldflow#readme
- Issues: https://github.com/skyhacker2/yieldflow/issues
- npm.io page: https://npm.io/package/yieldflow

## Recent versions

- 0.0.2 (latest) — 2016-03-04
- 0.0.1 — 2016-03-04

## README

# yieldflow
> Asynchronous becomes synchronous with the yield

## Install

```
npm install yieldflow
```

## Usage

```
var yieldflow = require('yieldflow');

var assert = require('assert');

function login(username, password, callback) {
    assert(username);
    assert(password);
    assert(callback);
    setTimeout(()=>callback(0), 1000);
}

function sendmsg(msg, callback) {
    assert(msg);
    setTimeout(()=>callback(msg), 500);
}

yieldflow(function* (next){
    var code = yield login('user', '123', (code)=>{
        next(code);
    });
    console.log('login: ' + code);

    var sendText = yield sendmsg('xxx', (text)=>{
        next(text);
    });
    console.log('send: ' + sendText);

    sendText = yield sendmsg('fuck', (text)=> {
        next(text);
    });
    console.log('send: ' + sendText);
});

```

result print:

```
login: 0
send: xxx
send: fuck
```

`login` and `sendmsg` is two asyns function.

`yeildflow` pass a next function to you, you will call `next(result)` in the async function callback to return the result to yield operation (`var code = yield login(...);`) and move one step.

Have fun.

## License

MIT: http://rem.mit-license.org

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