zipObject.js 664 B

12345678910111213141516171819202122232425
  1. var assignValue = require('./_assignValue'),
  2. baseZipObject = require('./_baseZipObject');
  3. /**
  4. * This method is like `_.fromPairs` except that it accepts two arrays,
  5. * one of property identifiers and one of corresponding values.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 0.4.0
  10. * @category Array
  11. * @param {Array} [props=[]] The property identifiers.
  12. * @param {Array} [values=[]] The property values.
  13. * @returns {Object} Returns the new object.
  14. * @example
  15. *
  16. * _.zipObject(['a', 'b'], [1, 2]);
  17. * // => { 'a': 1, 'b': 2 }
  18. */
  19. function zipObject(props, values) {
  20. return baseZipObject(props || [], values || [], assignValue);
  21. }
  22. module.exports = zipObject;