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

replace-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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {replace} from 'rambda'
const str = 'foo bar foo'const replacer = 'bar'
describe('R.replace', () => { it('happy', () => { const result = replace(/foo/g, replacer, str)
result // $ExpectType string }) it('with string as search pattern', () => { const result = replace('foo', replacer, str)
result // $ExpectType string }) it('with function as replacer', () => { const result = replace('f(o)o', (m: string, p1: string, offset: number) => { m // $ExpectType string p1 // $ExpectType string offset // $ExpectType number return p1 }, str)
result // $ExpectType string })})
describe('R.replace - curried', () => { it('happy', () => { const result = replace(/foo/g, replacer)(str)
result // $ExpectType string }) it('with string as search pattern', () => { const result = replace('foo', replacer)(str)
result // $ExpectType string }) it('with function as replacer', () => { const result = replace('f(o)o')((m: string, p1: string, offset: number) => { m // $ExpectType string p1 // $ExpectType string offset // $ExpectType number return p1 })(str)
result // $ExpectType string })})
rambda

Version Info

Tagged at
2 months ago