Invoke functions on arguments

JavaScript, Function · Oct 21, 2020

Creates a function that invokes each provided function with the arguments it receives and returns the results.

const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));

const minMax = over(Math.min, Math.max);
minMax(1, 2, 3, 4, 5); // [1, 5]

More like this

  • Rearrange function arguments

    Creates a function that invokes the provided function with its arguments arranged according to the specified indexes.

    JavaScript, Function · Oct 22, 2020

  • Transform function arguments

    Creates a function that invokes the provided function with its arguments transformed.

    JavaScript, Function · Oct 21, 2020

  • Append function arguments

    Creates a function that invokes fn with partials appended to the arguments it receives.

    JavaScript, Function · Sep 15, 2020