docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Create a utility that builds callable pipelines from multiple functions while allowing the caller to control argument order, per-argument preprocessing, breadth of accepted inputs, and whether functions run left-to-right or right-to-left.
(a, b) => a + b, (n) => n * n, (n) => \value:${n}`; options { order: [1, 0, 2], transforms: [(x) => x + 1, (y) => y * 2, (z) => z * 2], limit: 2 }; and inputs (2, 5, 9), the pipeline returns value:100` after reordering inputs, applying transforms, dropping arguments beyond the limit, and running steps in the provided order. @test(a, b) => a - b, (n) => n * 3, (n) => \R${n}`; options { direction: 'rtl', order: [0, 1], transforms: [(x) => x + 2, (y) => y - 1] }; and inputs (4, 10), the pipeline runs the last step first, threads outputs backward, and returns R18`. @test(a, b, c) => [a, b, c].filter((v) => v !== undefined).join('-'), (s) => s.toUpperCase(); options { transforms: [(x) => \id-${x}`, (y) => y * 10], limit: 2 }; and inputs (7, 3, 99), the pipeline only exposes the limited, transformed arguments to the first step and returns ID-7-30`. @testArgument handling happens in this order before the first step runs: reorder using order if provided, apply per-position transforms, drop any arguments past limit if set, then feed the prepared list into the first executed step (the first element for left-to-right, the last element for right-to-left).
/**
* Builds a callable pipeline from ordered steps with optional argument choreography.
* @param {Array<Function>} steps - Functions executed in sequence.
* @param {Object} [options]
* @param {'ltr'|'rtl'} [options.direction='ltr'] - Composition direction. 'rtl' runs steps from the end of the array back to the start.
* @param {number[]} [options.order] - Desired ordering of incoming arguments before transforms.
* @param {Function[]} [options.transforms] - Per-argument transforms applied after reordering.
* @param {number} [options.limit] - Maximum number of incoming arguments to expose to the pipeline; extras are ignored.
* @returns {Function} A function that accepts any arguments, applies choreography, then runs the composed steps.
*/
export function createPipeline(steps, options);Utility helpers for composing functions and reshaping arguments.