@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function curryMulti

    • come here, come all! greet the Types' Olympic Champion of winter 2024.

      it took a while to correctly apply a multitude of gymnastics to get it functioning, but the dedication has paid off! please give curryMulti a round of applause! and don't forget that currying a diverse variety of types all at once brings strength!

      (said a nation right before its downfall)

      now that introductions are over: curryMulti behaves very much like curry, the only difference being that you can bind an arbitrary number of arguments to the curried fn function, instead of just a single argument at a time (like in the case of curry).

      Type Parameters

      Parameters

      • fn: FN

        the function to multi-curry

      • OptionalthisArg: THIS

        provide an optional argument to use as the this object inside of fn

      • remaining_args: number = fn.length

        number of arguments remaining until all parameters (required kind, ideally) are filled. intended for internal use onkly

      Returns CurryMultiSignature<FN, R, THIS>

      a curried function that consumes variable number of arguments, until all required parameters are available, after which a return value is spat out

      import { assertEquals as assertEq } from "jsr:@std/assert"

      const abcd = (a: number, b: string, c: boolean, d: symbol): string => (String(a) + b + String(c) + " " + String(d))
      const abcd_diversity_curry = curryMulti(abcd)

      abcd_diversity_curry satisfies CurryMultiSignature<(a: number, b: string, c: boolean, d: symbol) => string, string, any>

      assertEq(
      (((abcd_diversity_curry(
      42, " hello to za warudo! ") satisfies CurryMultiSignature<(c: boolean, d: symbol) => string, string, any>
      )(true) satisfies CurryMultiSignature<(d: symbol) => string, string, any>
      )(Symbol.iterator) satisfies (string)
      ),
      "42 hello to za warudo! true Symbol(Symbol.iterator)",
      )