25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
929 B

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