tiinvo

tiinvo / Exports / Pipe

Namespace: Pipe

Table of contents

Type Aliases

Functions

Type Aliases

AsChain

Ƭ AsChain<f, g>: { [k in keyof f]: Function }

Type parameters

Name Type
f extends [FuncType, …FuncType[]]
g extends FuncType[] = Tail<f>

Defined in

src/Pipe.ts:1


AsAsyncChain

Ƭ AsAsyncChain<f, g>: { [k in keyof f]: Function }

Type parameters

Name Type
f extends [FuncType, …FuncType[]]
g extends FuncType[] = Tail<f>

Defined in

src/Pipe.ts:8


ArgType

Ƭ ArgType<F, Else>: F extends (arg: infer A) => any ? A : Else

Type parameters

Name Type
F F
Else never

Defined in

src/Pipe.ts:17


FuncType

Ƭ FuncType: (arg: any) => any

Type declaration

▸ (arg): any

Parameters
Name Type
arg any
Returns

any

Defined in

src/Pipe.ts:19


LastIndexOf

Ƭ LastIndexOf<a>: (…x: a) => void extends (y: any, …z: infer b) => void ? b["length"] : never

Type parameters

Name Type
a extends any[]

Defined in

src/Pipe.ts:21


Lookup

Ƭ Lookup<t, k, el>: k extends keyof t ? t[k] : el

Type parameters

Name Type
t t
k extends keyof any
el never

Defined in

src/Pipe.ts:28


Tail

Ƭ Tail<a>: (…t: a) => void extends (x: any, …u: infer b) => void ? b : never

Type parameters

Name Type
a extends any[]

Defined in

src/Pipe.ts:32


Pipe

Ƭ Pipe: <f>(…f: f & AsChain<f>) => f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: infer U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Type declaration

▸ <f>(...f): f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: infer U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Type parameters
Name Type
f extends [(arg: any) => any | () => any, …Function[]]
Parameters
Name Type
...f f & AsChain<f>
Returns

f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: infer U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Defined in

src/Pipe.ts:39


PipeAsync

Ƭ PipeAsync: <f>(…f: f & AsAsyncChain<f>) => f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: infer U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Type declaration

▸ <f>(...f): f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: infer U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Type parameters
Name Type
f extends [(arg: any) => Promise<any> | () => Promise<any>, …Function[]]
Parameters
Name Type
...f f & AsAsyncChain<f>
Returns

f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: infer U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Defined in

src/Pipe.ts:44

Functions

async

async<f>(...f): f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Same as the sync version, but handles promises.

Since

4.0.0

Type parameters

Name Type
f extends [(arg: any) => Promise<any> | () => Promise<any>, …Function[]]

Parameters

Name Type
...f f & AsAsyncChain<f, Tail<f>>

Returns

f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Defined in

src/Pipe.ts:44


sync

sync<f>(...f): f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Creates a pipeline of synchronous functions

Example

import { Num, Pipe } from 'tiinvo'

const vat = Pipe.sync(Num.div(100), Num.mul(22));

vat(100)     // 22
vat(150)     // 33
vat(200)     // 44

Since

4.0.0

Type parameters

Name Type
f extends [(arg: any) => any, …Function[]]

Parameters

Name Type
...f f & AsChain<f, Tail<f>>

Returns

f[0] extends () => any ? () => ReturnType<f[LastIndexOf<f>]> : f[0] extends (arg: U) => any ? (arg: U) => ReturnType<f[LastIndexOf<f>]> : never

Defined in

src/Pipe.ts:39