forIn.js 980 B

123456789101112131415161718192021222324252627282930313233
  1. var baseFor = require('../internal/baseFor'),
  2. createForIn = require('../internal/createForIn');
  3. /**
  4. * Iterates over own and inherited enumerable properties of an object invoking
  5. * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked
  6. * with three arguments: (value, key, object). Iteratee functions may exit
  7. * iteration early by explicitly returning `false`.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @category Object
  12. * @param {Object} object The object to iterate over.
  13. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14. * @param {*} [thisArg] The `this` binding of `iteratee`.
  15. * @returns {Object} Returns `object`.
  16. * @example
  17. *
  18. * function Foo() {
  19. * this.a = 1;
  20. * this.b = 2;
  21. * }
  22. *
  23. * Foo.prototype.c = 3;
  24. *
  25. * _.forIn(new Foo, function(value, key) {
  26. * console.log(key);
  27. * });
  28. * // => logs 'a', 'b', and 'c' (iteration order is not guaranteed)
  29. */
  30. var forIn = createForIn(baseFor);
  31. module.exports = forIn;