{"version":3,"file":"pipe.cjs","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["/**\n * Creates a function that is the composition of the provided functions,\n * where each successive invocation is supplied the return value of the previous.\n * Functions are executed from left to right.\n *\n * @param funcs - The functions to pipe\n * @returns Returns the new composite function\n *\n * @example\n * const add = (x: number) => x + 1;\n * const multiply = (x: number) => x * 2;\n * const piped = pipe(add, multiply);\n * piped(5); // => 12 (add(5) = 6, then multiply(6) = 12)\n *\n * @example\n * const toUpper = (str: string) => str.toUpperCase();\n * const exclaim = (str: string) => `${str}!`;\n * const shout = pipe(toUpper, exclaim);\n * shout('hello'); // => 'HELLO!'\n */\nexport function pipe<T>(...funcs: Array<(arg: T) => T>): (arg: T) => T {\n  if (funcs.length === 0) {\n    return (arg: T) => arg;\n  }\n\n  if (funcs.length === 1) {\n    return funcs[0];\n  }\n\n  return function piped(arg: T): T {\n    let result = arg;\n    for (let i = 0; i < funcs.length; i++) {\n      result = funcs[i](result);\n    }\n    return result;\n  };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,KAAQ,GAAG,OAA4C;CACrE,IAAI,MAAM,WAAW,GACnB,QAAQ,QAAW;CAGrB,IAAI,MAAM,WAAW,GACnB,OAAO,MAAM;CAGf,OAAO,SAAS,MAAM,KAAW;EAC/B,IAAI,SAAS;EACb,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,SAAS,MAAM,EAAE,CAAC,MAAM;EAE1B,OAAO;CACT;AACF"}