Module: Composition
Type Aliases
Compose
Ƭ Compose<Arguments
, Functions
>: Arguments
["length"
] extends 0
? Functions
: Arguments
extends [infer A, infer B] ? [...Functions, (arg
: A
) => B
] : Arguments
extends [infer A, ...(infer Rest), infer P, infer L] ? Compose
<[A
, ...Rest, P
], [...Functions, (arg
: P
) => L
]> : []
Makes a composition of functions from received arguments.
Type parameters
Name | Type |
---|---|
Arguments | extends any [] |
Functions | extends any [] = [] |
Decompose
Ƭ Decompose<Functions
, Arguments
>: Functions
extends [(arg
: infer Arg) => infer Return] ? [...Arguments, Arg
, Return
] : Functions
extends [...(infer Rest extends UnaryFunction[]), (arg
: infer Arg) => any
] ? Decompose
<Rest
, [...Arguments, Arg
]> : []
Destructures a composition of functions into arguments.
Type parameters
Name | Type |
---|---|
Functions | extends UnaryFunction [] |
Arguments | extends any [] = [] |
Depipe
Ƭ Depipe<Functions
, Arguments
>: Functions
extends [(arg
: infer Arg) => infer Return] ? [...Arguments, Arg
, Return
] : Functions
extends [(arg
: infer Arg) => any
, ...(infer Rest extends UnaryFunction[])] ? Depipe
<Rest
, [...Arguments, Arg
]> : []
Destructures a pipeline of functions into arguments.
Type parameters
Name | Type |
---|---|
Functions | extends UnaryFunction [] |
Arguments | extends any [] = [] |
Pipe
Ƭ Pipe<Arguments
, Functions
>: Arguments
["length"
] extends 0
? Functions
: Arguments
extends [infer A, infer B] ? [(arg
: A
) => B
, ...Functions] : Arguments
extends [infer A, ...(infer Rest), infer P, infer L] ? Pipe
<[A
, ...Rest, P
], [(arg
: P
) => L
, ...Functions]> : []
Makes a pipeline of functions from received arguments.
Type parameters
Name | Type |
---|---|
Arguments | extends any [] |
Functions | extends any [] = [] |
Functions
compose
▸ compose<A
, B
, C
>(f
, g
): (...args
: A
) => C
(B -> C) . (A -> B) = A -> C
Type parameters
Name | Type |
---|---|
A | extends any [] |
B | B |
C | C |
Parameters
Name | Type |
---|---|
f | (arg : B ) => C |
g | (...args : A ) => B |
Returns
fn
▸ (...args
): C
Parameters
Name | Type |
---|---|
...args | A |
Returns
C
▸ compose<A
, B
, C
>(f
, g
, ...args
): C
(B -> C) . (A -> B) = A -> C
Type parameters
Name | Type |
---|---|
A | extends any [] |
B | B |
C | C |
Parameters
Name | Type |
---|---|
f | (arg : B ) => C |
g | (...args : A ) => B |
...args | A |
Returns
C
pipe
▸ pipe<A
, B
, C
>(f
, g
): (...args
: A
) => C
(A -> B) . (B -> C) = A -> C
Type parameters
Name | Type |
---|---|
A | extends any [] |
B | B |
C | C |
Parameters
Name | Type |
---|---|
f | (...args : A ) => B |
g | (arg : B ) => C |
Returns
fn
▸ (...args
): C
Parameters
Name | Type |
---|---|
...args | A |
Returns
C
▸ pipe<A
, B
, C
>(...args
): C
(A -> B) . (B -> C) = A -> C
Type parameters
Name | Type |
---|---|
A | extends any [] |
B | B |
C | C |
Parameters
Name | Type |
---|---|
...args | [...args: A[], f: Function, g: Function] |
Returns
C