Gathering detailed insights and metrics for callback-chain-resolver
Gathering detailed insights and metrics for callback-chain-resolver
Gathering detailed insights and metrics for callback-chain-resolver
Gathering detailed insights and metrics for callback-chain-resolver
npm install callback-chain-resolver
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
Version 16 introduces series
and parallel
functions and removes earlier functions.
Helps you generate values out of functions in series or in parallel.
npm i callback-chain-resolver
1 2import {series, parallel} from 'callback-chain-resolver' 3 4const incrementBy1 = (x) => x + 1; 5const decrementBy1 = (x) => x - 1; 6const double = x => 2 * x 7const square = x => x * x 8const cube = x => x * square(x) 9 10series(1, [incrementBy1, incrementBy1, incrementBy1]) // === 4 11series(1, [incrementBy1, incrementBy1, incrementBy1, double, square]) // === 64 12series(1, [incrementBy1, incrementBy1, incrementBy1, cube]) // === 64 13series(1, [decrementBy1, decrementBy1, decrementBy1]) // === -2 14series(1, [incrementBy1, decrementBy1]) // === 1 15series(1, [incrementBy1, cube, decrementBy1]) // === 7 16series(1, [decrementBy1, incrementBy1]) // === 1 17 18parallel(1, [incrementBy1, incrementBy1, incrementBy1]) // === [2, 2, 2] 19parallel(1, [incrementBy1, incrementBy1, incrementBy1, double, square]) // [2, 2, 2, 2, 1] 20
Check test cases for more examples.
Throws compile time error if you pass mixed output type functions.
For example when you add toString
to the typedResolver test cases.
1TS2345: Argument of type '(((x: number) => number) | ((x: number) => string))[]' is not assignable to parameter of type 'FnT<number>[]'. 2 Type '((x: number) => number) | ((x: number) => string)' is not assignable to type 'FnT<number>'. 3 Type '(x: number) => string' is not assignable to type 'FnT<number>'. 4 Type 'string' is not assignable to type 'number'
Use any
in <any>
while invoking mixed functions.
MIT © 2016 - 2021
No vulnerabilities found.
No security vulnerabilities found.