import { PipeFunction, Then } from './src/types' type Initial = T extends (...args: any[]) => infer A ? Then : T /** * @description * Run a set of functions in series using the output of each * as the input to the next. The first value is allowed to be * of any kind - if it is not a function it is simply passed * as the argument to the second item. Subsequent non-function * items are ignored. * * Because `pipe` handles Promise-returning functions, it will * always return a Promise in order to maintain a consistent API * even if all given functions & values are synchronous. * * @parameters * | name | type | description | * | :--: | :--: | ----------- | * | ...inputs | `Function[]` | Set of functions to pipe through | * * @returns `Promise` * * @example * pipe( * 'hello', * str => str.toUpperCase(), * str => str.split('').join('-') * ).then(result => { * console.log(result) * // -> 'H-E-L-L-O' * }) * * async function getUserData (name) { * return { name, favoriteColor: 'blue' } * } * * pipe( * name => getUserData(name), * user => user.favoriteColor === 'blue' * ).then(result => { * console.log(result) * // -> true * }) * * @since v1.0.0 * @tag functions */ interface Pipe { (a: A, b: PipeFunction, B>): Promise (a: A, b: PipeFunction, B>, c: PipeFunction): Promise (a: A, b: PipeFunction, B>, c: PipeFunction, d: PipeFunction): Promise (a: A, b: PipeFunction, B>, c: PipeFunction, d: PipeFunction, e: PipeFunction): Promise (a: A, b: PipeFunction, B>, c: PipeFunction, d: PipeFunction, e: PipeFunction, f: PipeFunction): Promise (a: A, b: PipeFunction, B>, c: PipeFunction, d: PipeFunction, e: PipeFunction, f: PipeFunction, g: PipeFunction): Promise (a: A, b: PipeFunction, B>, c: PipeFunction, d: PipeFunction, e: PipeFunction, f: PipeFunction, g: PipeFunction, h: PipeFunction): Promise (a: A, b: PipeFunction, B>, c: PipeFunction, d: PipeFunction, e: PipeFunction, f: PipeFunction, g: PipeFunction, h: PipeFunction, i: PipeFunction): Promise // type-unsafe fallback (...args: PipeFunction[]): Promise } declare const pipe: Pipe export = pipe