Skip to content

Instantly share code, notes, and snippets.

@jpblancoder
Created March 4, 2024 21:12
Show Gist options
  • Select an option

  • Save jpblancoder/53c7e8e6fb66372342d8085d009b4e16 to your computer and use it in GitHub Desktop.

Select an option

Save jpblancoder/53c7e8e6fb66372342d8085d009b4e16 to your computer and use it in GitHub Desktop.

Revisions

  1. jpblancoder created this gist Mar 4, 2024.
    10 changes: 10 additions & 0 deletions callAll.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    /**
    * Create a function that calls all the functions passed to it, with the same arguments.
    * @example <div onClick={callAll(f, g, h)} />
    * @param {...any} fns - Functions to call (left-to-right execution)
    * @returns {Function}
    */
    export const callAll =
    (...fns) =>
    (...args) =>
    fns.forEach(fn => isFunctionThenInvoke(fn, args, undefined));