TreasureTrails/node_modules/remeda/dist/pipe-Dw7DdqoP.cjs.map

1 line
13 KiB
Text
Raw Permalink Normal View History

2026-03-18 09:02:21 -05:00
{"version":3,"file":"pipe-Dw7DdqoP.cjs","names":["lazySequence: PreparedLazyFunction[]","accumulator: unknown[]","lazyResult: LazyResult<any>","SKIP_ITEM"],"sources":["../src/pipe.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable jsdoc/check-param-names -- we don't document the op params, it'd be redundant */\n\nimport type { LazyDefinition } from \"./internal/types/LazyDefinition\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { LazyResult } from \"./internal/types/LazyResult\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype PreparedLazyFunction = LazyEvaluator & {\n readonly isSingle: boolean;\n\n // These are intentionally mutable, they maintain the lazy piped state.\n index: number;\n items: unknown[];\n};\n\ntype LazyFunction = LazyDefinition & ((input: unknown) => unknown);\n\n/**\n * Performs left-to-right function composition, passing data through functions\n * in sequence. Each function receives the output of the previous function,\n * creating a readable top-to-bottom data flow that matches how the\n * transformation is executed. This enables converting deeply nested function\n * calls into clear, sequential steps without temporary variables.\n *\n * When consecutive functions with a `lazy` tag (e.g., `map`, `filter`, `take`,\n * `drop`, `forEach`, etc...) are used together, they process data item-by-item\n * rather than creating intermediate arrays. This enables early termination\n * when only partial results are needed, improving performance for large\n * datasets and expensive operations.\n *\n * Functions are only evaluated lazily when their data-last form is used\n * directly in the pipe. To disable lazy evaluation, use data-first calls via\n * arrow functions: `($) => map($, callback)` instead of `map(callback)`.\n *\n * Any function can be used in pipes, not just Remeda utilities. For creating\n * custom functions with currying and lazy evaluation support, see the `purry`\n * utility.\n *\n * A \"headless\" variant `piped` is available for creating reusable pipe\n * functions without initial data.\n *\n * IMPORTANT: During lazy evaluation, callbacks using the third parameter (the\n * input array) receive only items processed up to that point, not the complete\n * array.\n *\n * @param data - The input data.\n * @param functions - A sequence of functions that take one argument and\n * return a value.\n * @signature\n * R.pipe(data, ...functions);\n * @example\n * R.pipe([1, 2, 3], R.map(R.multiply(3))); //=> [3, 6, 9]\n *\n * // = Early termination with lazy evaluation =\n * R.pipe(\n * hugeArray,\n * R.map(expensiveComputation),\n * R.filter(complexPredicate),\n * // Only processes items until 2 results are found, then stops.\n * // Most of hugeArray never gets processed.\n * R.take(2),\n * );\n *\n * // = Custom logic within a pipe =\n * R.pipe(\n * input,\n * R.toLowerCase(),\n * normalize,\n * ($) => validate($, CONFIG),\n * R.split(\",\"),\n * R.unique(),\n * );\n *\n * // = Migrating nested transformations to pipes =\n * // Nested\n * const result = R.prop(\n * R.mapValues(R.groupByProp(users, \"department\"), R.length()),\n * \"engineering\",\n * );\n *\n * // Piped\n * const result = R.pipe(\n * users,\n * R.groupByProp(\"department\"),\n * R.mapValues(R.length()),\n * R.prop(\"engineering\"),\n * );\n *\n * // = Using the 3rd param of a callback =\n * // The following would print out `data` in its entirety for each value\n * // of `data`.\n * R.forEach([1, 2, 3, 4], (_item, _index, data) => {\n * console.log(data);\n * }); //=> \"[1, 2, 3, 4]\" logged 4 times\n *\n * // But with `pipe` data would only contain the items up to the current\n * // index\n * R.pipe([1, 2, 3, 4], R.forEach((_item, _index, data) => {\n * console.log(data);\n * })); //=> \"[1]\", \"[1, 2]\", \"[1, 2, 3]\", \"[1, 2, 3, 4]\"\n * @dataFirst\n