# ko-timeout

> Error on timeout

Latest version **1.1.6** (published 2017-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install ko-timeout
pnpm add ko-timeout
yarn add ko-timeout
bun add ko-timeout
```

## 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.1.6 |
| Published | 2017-10-19 |
| First published | 2015-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | alsotang |
| Maintainers | alsotang |
| Keywords | timeout, co, yield, generator |

## Links

- npm: https://www.npmjs.com/package/ko-timeout
- Repository: https://github.com/alsotang/ko-timeout
- Homepage: https://github.com/alsotang/ko-timeout#readme
- Issues: https://github.com/alsotang/ko-timeout/issues
- npm.io page: https://npm.io/package/ko-timeout

## Dependencies (4)

- [co](https://npm.io/package/co.md) ^4.6.0
- [ms](https://npm.io/package/ms.md) ^0.7.1
- [co-mocha](https://npm.io/package/co-mocha.md) ^1.1.2
- [custom-error](https://npm.io/package/custom-error.md) ^0.2.1

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.1.6 (latest) — 2017-10-19
- 1.1.5 — 2015-11-15
- 1.1.4 — 2015-11-14
- 1.1.3 — 2015-11-14
- 1.1.2 — 2015-11-14
- 1.1.1 — 2015-11-14
- 1.1.0 — 2015-11-14
- 1.0.0 — 2015-11-14

## README

# ko-timeout

**deprecated please use https://github.com/sindresorhus/delay**

[![Build Status](https://travis-ci.org/alsotang/ko-timeout.svg?branch=master)](https://travis-ci.org/alsotang/ko-timeout)

## usage

```js
timeout(gen, ms)
```

`gen` - a genarator function

`ms` - millisecond. can use '3s' or '200ms', which https://www.npmjs.com/package/ms support

if timeout, `err.name` will be `CoTimeoutError`

## example

### should timeout

```js
try {
  yield timeout(function * () {
    yield sleep(50)
  }, 20)
} catch (e) {
  e.message.should.eql('timeout: exceed 20ms')
}
```

### should get return value


```js
var value = yield timeout(function * () {
  yield sleep(10)
  return 30;
}, 20)

value.should.eql(30)
```

## license

MIT

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