_createOver.js 778 B

123456789101112131415161718192021222324252627
  1. import apply from './_apply.js';
  2. import arrayMap from './_arrayMap.js';
  3. import baseIteratee from './_baseIteratee.js';
  4. import baseRest from './_baseRest.js';
  5. import baseUnary from './_baseUnary.js';
  6. import flatRest from './_flatRest.js';
  7. /**
  8. * Creates a function like `_.over`.
  9. *
  10. * @private
  11. * @param {Function} arrayFunc The function to iterate over iteratees.
  12. * @returns {Function} Returns the new over function.
  13. */
  14. function createOver(arrayFunc) {
  15. return flatRest(function(iteratees) {
  16. iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
  17. return baseRest(function(args) {
  18. var thisArg = this;
  19. return arrayFunc(iteratees, function(iteratee) {
  20. return apply(iteratee, thisArg, args);
  21. });
  22. });
  23. });
  24. }
  25. export default createOver;