{"version":3,"file":"purryFromLazy-tuFvR-GT.cjs","names":["pipe"],"sources":["../src/internal/purryFromLazy.ts"],"sourcesContent":["import { pipe } from \"../pipe\";\nimport type { LazyDefinition } from \"./types/LazyDefinition\";\nimport type { LazyEvaluator } from \"./types/LazyEvaluator\";\n\n/**\n * A version of `purry` for cases where the only meaningful implementation is a\n * lazy one. This is useful for functions that don't have a built-in\n * implementation already, and that can't be optimized to take advantage of\n * having the complete array upfront.\n *\n * Under the hood the function uses `pipe` to utilize it's built-in lazy logic\n * and wraps the pipe with the required invocations to allow using the function\n * outside of pipes too.\n *\n * @param lazy - The main lazy implementation, it assumes that data is an\n * iterable (array-like).\n * @param args - The arguments passed to the overloaded invocation.\n * @see purry\n * @see pipe\n */\nexport function purryFromLazy(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n lazy: (...args: any) => LazyEvaluator,\n args: readonly unknown[],\n): unknown {\n const diff = args.length - lazy.length;\n\n if (diff === 1) {\n // dataFirst\n const [data, ...rest] = args;\n const lazyDefinition = { lazy, lazyArgs: rest } satisfies LazyDefinition;\n\n // @ts-expect-error [ts2353] - Pipe expects a function which *might* also have a lazy definition. We are tricking pipe here to take our lazyDefinition without any function attached to it.\n return pipe(data, lazyDefinition);\n }\n\n if (diff === 0) {\n const lazyDefinition = { lazy, lazyArgs: args } satisfies LazyDefinition;\n\n // @ts-expect-error [ts2353] - Pipe expects a function which *might* also have a lazy definition. We are tricking pipe here to take our lazyDefinition without any function attached to it.\n const dataLast = (data: unknown): unknown => pipe(data, lazyDefinition);\n return Object.assign(dataLast, lazyDefinition);\n }\n\n throw new Error(\"Wrong number of arguments\");\n}\n"],"mappings":"uCAoBA,SAAgB,EAEd,EACA,EACS,CACT,IAAM,EAAO,EAAK,OAAS,EAAK,OAEhC,GAAI,IAAS,EAAG,CAEd,GAAM,CAAC,EAAM,GAAG,GAAQ,EAIxB,OAAOA,EAAAA,EAAK,EAHW,CAAE,OAAM,SAAU,EAAM,CAGd,CAGnC,GAAI,IAAS,EAAG,CACd,IAAM,EAAiB,CAAE,OAAM,SAAU,EAAM,CAI/C,OAAO,OAAO,OADI,GAA2BA,EAAAA,EAAK,EAAM,EAAe,CACxC,EAAe,CAGhD,MAAU,MAAM,4BAA4B"}