createForOwn.js 541 B

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