UNPKG
timer
Version:
latest (1.0.1)
1.0.1
1.0.0
0.0.2
0.0.1
timeout utilities (promisfied setTimeout, chained timeouts)
timer
/
example
/
awaitExample.js
18 lines
(12 loc)
•
259 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
timer =
require
(
'../timer'
)
async
function
go
(
) {
await
timer
(
1500
);
console
.
log
(
'done'
) }
go
()
// promise race
Promise
.
race
( [
timer
(
2000
), timer.
timeout
(
1000
) ] ).
then
(
function
(
){
console
.
log
(
'success'
) },
function
(
x
){
console
.
log
(
'error'
,x) });