You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
866 B

4 years ago
  1. var baseForOwnRight = require('./_baseForOwnRight'),
  2. castFunction = require('./_castFunction');
  3. /**
  4. * This method is like `_.forOwn` except that it iterates over properties of
  5. * `object` in the opposite order.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 2.0.0
  10. * @category Object
  11. * @param {Object} object The object to iterate over.
  12. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13. * @returns {Object} Returns `object`.
  14. * @see _.forOwn
  15. * @example
  16. *
  17. * function Foo() {
  18. * this.a = 1;
  19. * this.b = 2;
  20. * }
  21. *
  22. * Foo.prototype.c = 3;
  23. *
  24. * _.forOwnRight(new Foo, function(value, key) {
  25. * console.log(key);
  26. * });
  27. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  28. */
  29. function forOwnRight(object, iteratee) {
  30. return object && baseForOwnRight(object, castFunction(iteratee));
  31. }
  32. module.exports = forOwnRight;