( fn: StrictFunction, args: readonly unknown[], lazy?: (...args: any) => LazyEvaluator, )
| 44 | * @category Function |
| 45 | */ |
| 46 | export function purry( |
| 47 | fn: StrictFunction, |
| 48 | args: readonly unknown[], |
| 49 | lazy?: (...args: any) => LazyEvaluator, |
| 50 | ): unknown { |
| 51 | const diff = fn.length - args.length; |
| 52 | if (diff === 0) { |
| 53 | // @ts-expect-error [ts2345] -- This error is accurate because we don't know |
| 54 | // anything about `fn` so can't ensure that we are passing the correct |
| 55 | // arguments to it, we just have to trust that the caller knows what they |
| 56 | // are doing. |
| 57 | return fn(...args); |
| 58 | } |
| 59 | |
| 60 | if (diff === 1) { |
| 61 | return lazyDataLastImpl(fn, args, lazy); |
| 62 | } |
| 63 | |
| 64 | throw new Error("Wrong number of arguments"); |
| 65 | } |
searching dependent graphs…