createForIn.js 587 B

1234567891011121314151617181920
  1. var bindCallback = require('./bindCallback'),
  2. keysIn = require('../object/keysIn');
  3. /**
  4. * Creates a function for `_.forIn` or `_.forInRight`.
  5. *
  6. * @private
  7. * @param {Function} objectFunc The function to iterate over an object.
  8. * @returns {Function} Returns the new each function.
  9. */
  10. function createForIn(objectFunc) {
  11. return function(object, iteratee, thisArg) {
  12. if (typeof iteratee != 'function' || thisArg !== undefined) {
  13. iteratee = bindCallback(iteratee, thisArg, 3);
  14. }
  15. return objectFunc(object, iteratee, keysIn);
  16. };
  17. }
  18. module.exports = createForIn;