UNPKG
@prelude/function
Version:
latest (0.4.1)
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0
0.0.3
Function module.
@prelude/function
/
src
/
memoize.test.ts
14 lines
(11 loc)
•
265 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import
*
as
F
from
'./index.js'
const
factorial = F.
memoize
((
n
:
number
):
bigint
=>
n ===
1
?
1n
:
BigInt
(n) *
factorial
(n -
1
) )
test
(
'memoize'
,
() =>
{
expect
(
factorial
(
100
)).
toMatchSnapshot
()
expect
(factorial.
cache
).
toMatchSnapshot
() })