CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
index.d.ts105 linesDownload Raw Back to lib
1/**2 * @typedef {(error?: Error | null | undefined, ...output: Array<any>) => void} Callback3 *   Callback.4 *5 * @typedef {(...input: Array<any>) => any} Middleware6 *   Ware.7 *8 * @typedef Pipeline9 *   Pipeline.10 * @property {Run} run11 *   Run the pipeline.12 * @property {Use} use13 *   Add middleware.14 *15 * @typedef {(...input: Array<any>) => void} Run16 *   Call all middleware.17 *18 *   Calls `done` on completion with either an error or the output of the19 *   last middleware.20 *21 *   > ๐Ÿ‘‰ **Note**: as the length of input defines whether async functions get a22 *   > `next` function,23 *   > itโ€™s recommended to keep `input` at one value normally.24 25 *26 * @typedef {(fn: Middleware) => Pipeline} Use27 *   Add middleware.28 */29/**30 * Create new middleware.31 *32 * @returns {Pipeline}33 *   Pipeline.34 */35export function trough(): Pipeline;36/**37 * Wrap `middleware` into a uniform interface.38 *39 * You can pass all input to the resulting function.40 * `callback` is then called with the output of `middleware`.41 *42 * If `middleware` accepts more arguments than the later given in input,43 * an extra `done` function is passed to it after that input,44 * which must be called by `middleware`.45 *46 * The first value in `input` is the main input value.47 * All other input values are the rest input values.48 * The values given to `callback` are the input values,49 * merged with every non-nullish output value.50 *51 * * if `middleware` throws an error,52 *   returns a promise that is rejected,53 *   or calls the given `done` function with an error,54 *   `callback` is called with that error55 * * if `middleware` returns a value or returns a promise that is resolved,56 *   that value is the main output value57 * * if `middleware` calls `done`,58 *   all non-nullish values except for the first one (the error) overwrite the59 *   output values60 *61 * @param {Middleware} middleware62 *   Function to wrap.63 * @param {Callback} callback64 *   Callback called with the output of `middleware`.65 * @returns {Run}66 *   Wrapped middleware.67 */68export function wrap(middleware: Middleware, callback: Callback): Run;69/**70 * Callback.71 */72export type Callback = (error?: Error | null | undefined, ...output: Array<any>) => void;73/**74 * Ware.75 */76export type Middleware = (...input: Array<any>) => any;77/**78 * Pipeline.79 */80export type Pipeline = {81    /**82     *   Run the pipeline.83     */84    run: Run;85    /**86     *   Add middleware.87     */88    use: Use;89};90/**91 * Call all middleware.92 *93 * Calls `done` on completion with either an error or the output of the94 * last middleware.95 *96 * > ๐Ÿ‘‰ **Note**: as the length of input defines whether async functions get a97 * > `next` function,98 * > itโ€™s recommended to keep `input` at one value normally.99 */100export type Run = (...input: Array<any>) => void;101/**102 * Add middleware.103 */104export type Use = (fn: Middleware) => Pipeline;105//# sourceMappingURL=index.d.ts.map