Files
lodash/over.js
John-David Dalton 6cb3460fce Remove semicolons.
2017-02-05 22:22:04 -08:00

28 lines
646 B
JavaScript

import apply from './.internal/apply.js'
import arrayMap from './.internal/arrayMap.js'
/**
* Creates a function that invokes `iteratees` with the arguments it receives
* and returns their results.
*
* @since 4.0.0
* @category Util
* @param {Function[]} [iteratees=[identity]]
* The iteratees to invoke.
* @returns {Function} Returns the new function.
* @example
*
* const func = over([Math.max, Math.min])
*
* func(1, 2, 3, 4)
* // => [4, 1]
*/
function over(iteratees) {
return function(...args) {
const thisArg = this
return arrayMap(iteratees, iteratee => apply(iteratee, thisArg, args))
}
}
export default over