# yieldpromise

> Yield promises in generator functions

Latest version **1.3.1** (published 2018-07-08) · ISC license · 0 weekly downloads

## Install

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

## 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.3.1 |
| Published | 2018-07-08 |
| First published | 2018-05-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 161 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | kanitsharma |
| Keywords | promise, generators, do monad, asynchronous programming |

## Links

- npm: https://www.npmjs.com/package/yieldpromise
- npm.io page: https://npm.io/package/yieldpromise

## Alternatives

- [@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
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.3.1 (latest) — 2018-07-08
- 1.3.0 — 2018-07-08
- 1.2.0 — 2018-06-11
- 1.1.0 — 2018-05-14
- 1.0.5 — 2018-05-14
- 1.0.3 — 2018-05-14
- 1.0.2 — 2018-05-05
- 1.0.1 — 2018-05-05
- 1.0.0 — 2018-05-05

## README

# yieldpromise

Yield promises in generator functions

## Getting started

```javascript
  npm i -s yieldpromise
```

### Usage

```javascript
const run = require("yieldpromise");
const fetch = require("node-fetch");

// Using as a standalone function
run(function* main() {
  const a = yield fetch("https://jsonplaceholder.typicode.com/posts/1");
  const b = yield a.json();
  console.log(b);
});
```

#### Since run injects resolve and reject as parameters to the child generator function, it can be used inside promise chain

##### Example

```javascript
const run = require("yieldpromise");
const fetch = require("node-fetch");

run(function* main(resolve, reject) {
  const a = yield fetch("https://jsonplaceholder.typicode.com/posts/1");
  const b = yield a.json();
  resolve(b);
})
  .then(x => x.userId)
  .then(console.log);
```

##### OR

```javascript
const run = require("yieldpromise");
const fetch = require("node-fetch");

fetch("https://jsonplaceholder.typicode.com/posts/1")
  .then(x =>
    run(function* main(resolve, reject) {
      const a = yield x.json();
      const b = a.userId;
      resolve(b);
    })
  )
  .then(console.log);
```

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