Call All Fns

    0

    0

    Steven-Failla_mmcgh

    This code defines a function that takes an array of functions as its arguments. The function returns a function that takes an array of arrays as its arguments.

    type CallAllFns = <
      Args extends Array<unknown>,
      Fns extends Array<((...args: Args) => unknown) | undefined>
    >(
      ...fns: [...Fns]
    ) => (...args: [...Args]) => void;
    
    const callAll: CallAllFns =
      (...fns) =>
      (...args) =>
        fns.forEach(fn => fn?.(...args));
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.