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

throttle-spec.ts
نووسراو ببینە
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
import {delay, throttle} from 'rambda'
describe('R.throttle', () => { it('arity of 1', async() => { const fn = throttle((x: number) => x + 1, 1000) const result1 = fn(1) await delay(100) const result2 = fn(1) result1 // $ExpectType number result2 // $ExpectType number }) it('arity of 2', () => { function add(x: number, y: number) { return x + y } const fn = throttle(add, 1000) const result = fn(1, 2) result // $ExpectType number }) it('arity of 3', () => { const toThrottle = (x: number, y: string, z: boolean) => { if (z) return 'foo' return `${x}${y}` }
const fn = throttle(toThrottle, 1000) const result = fn(1, 'bar', true) result // $ExpectType string })})
rambda

Version Info

Tagged at
2 months ago