index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * lodash 3.0.3 (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modularize exports="npm" -o ./`
  4. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <https://lodash.com/license>
  8. */
  9. /**
  10. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  11. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  12. * each property. Iteratee functions may exit iteration early by explicitly
  13. * returning `false`.
  14. *
  15. * @private
  16. * @param {Object} object The object to iterate over.
  17. * @param {Function} iteratee The function invoked per iteration.
  18. * @param {Function} keysFunc The function to get the keys of `object`.
  19. * @returns {Object} Returns `object`.
  20. */
  21. var baseFor = createBaseFor();
  22. /**
  23. * Creates a base function for methods like `_.forIn`.
  24. *
  25. * @private
  26. * @param {boolean} [fromRight] Specify iterating from right to left.
  27. * @returns {Function} Returns the new base function.
  28. */
  29. function createBaseFor(fromRight) {
  30. return function(object, iteratee, keysFunc) {
  31. var index = -1,
  32. iterable = Object(object),
  33. props = keysFunc(object),
  34. length = props.length;
  35. while (length--) {
  36. var key = props[fromRight ? length : ++index];
  37. if (iteratee(iterable[key], key, iterable) === false) {
  38. break;
  39. }
  40. }
  41. return object;
  42. };
  43. }
  44. module.exports = baseFor;