1.0.8 • Published 4 years ago

etimeout v1.0.8

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

增强的 timeout

用法

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

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周期

function(next){
    ......
    next()
}

cancel

取消

continue

继续

setInterval

设置周期

setContext

设置上下文

License

MIT

1.0.8

4 years ago

1.0.7

5 years ago

1.0.63

5 years ago

1.0.62

5 years ago

1.0.61

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago