UNPKG

487 BJavaScriptView Raw
1const test = require('./config').test
2const { map, chain } = require('..')
3
4
5// --- Preserving state
6
7const checkState = (name, cpsFn, cpsFn1) => {
8 test(name + 'prototype passed to transformed CPS fn', t => {
9 t.is(cpsFn1.a, 22)
10 })
11}
12
13const cpsFn = cb => cb(42)
14const protoObj = {a: 22}
15Object.setPrototypeOf(cpsFn, protoObj)
16
17const cpsFn1 = map(x => x*2)(cpsFn)
18const cpsFn2 = chain(x => cb => cb(x*2))(cpsFn)
19
20checkState('map: ', cpsFn, cpsFn1)
21checkState('chain: ', cpsFn, cpsFn2)