-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdeno_time.deno.txt
42 lines (30 loc) · 2.04 KB
/
deno_time.deno.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
┏━━━━━━━━━━━━━━━┓
┃ DENO_TIME ┃
┗━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> #See @sinonjs/fake-timers
VERSION ==> #Part of Deno test (see its doc)
@std/testing/time #Entrypoint (std library)
┌──────────┐
│ CORE │
└──────────┘
new FakeTime([START[, OPTS]]) #Mocks set|clearTimeout|Interval(), [new] Date.*()
#START is FAKETIME.start, as DATE[_NUM]|'DATE'
restore() #Call all FAKETIME.restore()
FAKETIME.restore()
FAKETIME[Symbol.dispose]() #Unmocks
restoreFor(FUNC()[->>])[->>] #Unmocks only while running FUNC
┌─────────────┐
│ ADVANCE │
└─────────────┘
FAKETIME.now #DATE_NUM (in ms). Current time
FAKETIME.start #DATE_NUM (in ms). Initial time
FAKETIME.tick([NUM]) #Advance fake time by NUMms (def: 0)
FAKETIME.next()->BOOL #Advance fake time to next timer
#Returns false if there was no next timer
FAKETIME.runAll() #Advance fake time to last timer
FAKETIME.delay(...) #Like async delay(...) but unmocked
FAKETIME.runMicrotasks() #Run all pending microtasks. Same as FAKETIME.delay(0)
FAKETIME.tick|next|runAllAsync
(...)->>... #Same but calls FAKETIME.runMicrotasks()
OPTS.advanceRate #NUM (def: 0). Advance fake time by NUMms each time real time advances by 1ms
OPTS.advanceFrequency #NUM (in ms, def: 10). With OPTS.advanceRate, how often to update fake time