or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-3/

Argument-Aware Pipeline Builder

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.

Capabilities

Builds left-to-right pipelines with argument control

  • With steps: (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

Supports right-to-left composition

  • With steps: (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

Limits and transforms incoming arguments

  • With steps: (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`. @test

Argument 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).

Implementation

@generates

API

/**
 * 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);

Dependencies { .dependencies }

lodash { .dependency }

Utility helpers for composing functions and reshaping arguments.