{"version":3,"file":"index.cjs","sources":["../../../src/placeholder.ts","../../../src/index.ts"],"sourcesContent":["export const enum Placeholder {\n  Value = '<<\\u200bCURRIABLE PLACEHOLDER\\u200b>>',\n}\n\nexport const __ = Placeholder.Value;\n","import type { Curried, CurriedFn, NormalizeFn } from './internalTypes.js';\nimport { __ } from './placeholder.js';\n\nexport { __ };\n\nfunction createCurried<Fn extends (...args: any[]) => any, Arity extends number>(\n  fn: Fn,\n  arity: Arity,\n): CurriedFn<Fn, Arity> {\n  const curried = function (initialArgs: any[]) {\n    return function (this: any, ...nextArgs: any[]): any {\n      const length: number = initialArgs.length;\n      const newArgsLength = nextArgs.length;\n\n      const combined: any[] = [];\n\n      let newArgsIndex = 0;\n      let remaining = arity;\n      let value: any;\n\n      if (length) {\n        let index = -1;\n\n        while (++index < length) {\n          combined[index] = value =\n            initialArgs[index] === __ && newArgsIndex < newArgsLength ? nextArgs[newArgsIndex++] : initialArgs[index];\n\n          if (value !== __) {\n            --remaining;\n          }\n        }\n      }\n\n      if (newArgsIndex < newArgsLength) {\n        while (newArgsIndex < newArgsLength) {\n          combined[combined.length] = value = nextArgs[newArgsIndex];\n\n          if (value !== __ && newArgsIndex < arity) {\n            --remaining;\n          }\n\n          ++newArgsIndex;\n        }\n      }\n\n      return remaining > 0 ? curried(combined) : fn.apply(this, combined);\n    };\n  };\n\n  return curried([]);\n}\n\n/**\n * Get the method passed as a curriable method based on its parameters\n */\nexport function curry<Fn extends (...args: any[]) => any, Arity extends number = Parameters<Fn>['length']>(\n  fn: Fn,\n  arityOverride?: Arity,\n): number extends Arity ? never : Curried<Fn, NormalizeFn<Fn, Arity>, Arity> {\n  const arity = typeof arityOverride === 'number' ? arityOverride : fn.length;\n  const curried = createCurried(fn, arity as Arity) as any;\n\n  curried.arity = arity as Arity;\n  curried.fn = fn;\n\n  return curried;\n}\n\n/**\n * Return a function that is the non-curried version of the fn passed.\n */\nexport function uncurry<CurriedFn extends Curried<(...args: any[]) => any, (...args: any[]) => any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