# etimeout

> 增强的setTimeout

Latest version **1.0.8** (published 2020-03-12) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2020-03-12 |
| First published | 2019-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | xiangwenhu |
| Maintainers | xiangwenhu |
| Keywords | timeout |

## Links

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

## Recent versions

- 1.0.8 (latest) — 2020-03-12
- 1.0.7 — 2019-06-18
- 1.0.63 — 2019-04-11
- 1.0.62 — 2019-04-11
- 1.0.61 — 2019-01-24
- 1.0.6 — 2019-01-22
- 1.0.5 — 2019-01-21
- 1.0.4 — 2019-01-21
- 1.0.3 — 2019-01-21
- 1.0.2 — 2019-01-21
- 1.0.1 — 2019-01-21
- 1.0.0 — 2019-01-21

## README

## 增强的 timeout

## 用法

```js
var timeout = require("etimeout");

var context = { name: "我的名字" };
const t = timeout(1000, context);

t.start(async function(next) {
    console.log(this.name);
    context.name = "我的名字-" + Date.now();
    next();
});

timeout(5500).start(function() {
    t.cancel();
});
```

ts使用, 有智能提示。   
可能需要设置 tsconfig 的 `compilerOptions.esModuleInterop:true`   
```js
import timeout  from "etimeout";

var t = timeout(1000);

var context = { name: "哈哈" };
t.setContext(context);
t.start(function(next) {
    console.log(Date.now(), this.name);
    next();
});

timeout(5500).start(() => {
    t.cancel();
});

```

## 方法

### start(fn)
fn如下，调用next即可进入下一个timeout周期
```js
function(next){
    ......
    next()
}
```

### cancel
取消

### continue
继续

### setInterval
设置周期

### setContext
设置上下文

## License
MIT

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