deno.land / x / rambda@v9.1.1 / source / throttle.spec.js

throttle.spec.js
نووسراو ببینە
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
import { delay } from './delay.js'import { inc } from './inc.js'import { throttle } from './throttle.js'
test('with side effect', async () => { let counter = 0
const incFn = a => { counter += a
return counter } const incWrapped = throttle(incFn, 1000) incWrapped(1) incWrapped(1) await delay(1500) incWrapped(1) expect(counter).toBe(2)})
test('return result', async () => { const incWrapped = throttle(inc, 1000) const results = [] results.push(incWrapped(1)) results.push(incWrapped(1)) await delay(1500) results.push(incWrapped(1)) await delay(500) results.push(incWrapped(1)) expect(results).toEqual([ 2, 2, 2, 2 ])})
rambda

Version Info

Tagged at
2 months ago