MCPcopy
hub / github.com/remeda/remeda / purry

Function purry

packages/remeda/src/purry.ts:46–65  ·  view source on GitHub ↗
(
  fn: StrictFunction,
  args: readonly unknown[],
  lazy?: (...args: any) => LazyEvaluator,
)

Source from the content-addressed store, hash-verified

44 * @category Function
45 */
46export 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}

Callers 15

capitalizeFunction · 0.90
entriesFunction · 0.90
uncapitalizeFunction · 0.90
zipFunction · 0.90
sortFunction · 0.90
mapToObjFunction · 0.90
dropLastWhileFunction · 0.90
reduceFunction · 0.90
startsWithFunction · 0.90
roundFunction · 0.90
mergeFunction · 0.90
fnFunction · 0.90

Calls 2

lazyDataLastImplFunction · 0.90
fnFunction · 0.70

Tested by 1

fnFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…