standard-data-structures
Version:
A collection of standard data-structures for node and browser
36 lines (35 loc) • 873 B
TypeScript
/**
* Pipeline that can take only one argument.
*/
declare class Pipeline1<T> {
readonly drain: T;
constructor(drain: T);
/**
* Refer [[Into.into]]
*/
into<S>(F: (T: T) => S): Pipeline1<S>;
}
/**
* Pipeline class that takes in any number of arguments
*/
declare class PipelineN<T extends unknown[]> {
private readonly TT;
constructor(TT: T);
/**
* Refer [[Into.into]]
*/
into<S>(F: (...T: T) => S): Pipeline1<S>;
}
/**
* Takes in any number of values that can be piped into a function.
* Returns a pipeline that can be used recursively to pipe to other functions.
*
* **Example:**
* ```ts
* import {pipe} from 'standard-data-structures'
*
* pipe(1, 2).into((A, B) => A + B).into(A => [A, A * A]).drain // [3, 9]
* ```
*/
export declare const pipe: <T extends unknown[]>(...T: T) => PipelineN<T>;
export {};