【文件属性】:
文件名称:timer-promise:setTimeout 和 clearTimeout 的 Promise 版本
文件大小:3KB
文件格式:ZIP
更新时间:2021-06-21 15:33:32
JavaScript
定时器承诺
setTimeout 和 clearTimeout 的 Promise 版本
您可以像这样启动和停止计时器。
var timer = require ( 'timer-promise' ) ;
timer . start ( 'foo' , 5000 ) .
then ( function ( ) {
} , function ( cancelled ) {
} ) ;
...
timer . stop ( 'foo' ) ;
代替
var timeoutId = setTimeout ( function ( ) {
} , 5000 ) ;
...
clearTimeout ( timeoutId ) ;
【文件预览】:
timer-promise-master
----lib()
--------timer-promise.js(786B)
----LICENSE(1KB)
----README.md(355B)
----.gitignore(587B)
----index.js(49B)
----package.json(504B)