1 var isArray = require('../lang/isArray');
4 * The inverse of `_.pairs`; this method returns an object composed from arrays
5 * of property names and values. Provide either a single two dimensional array,
6 * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names
7 * and one of corresponding values.
13 * @param {Array} props The property names.
14 * @param {Array} [values=[]] The property values.
15 * @returns {Object} Returns the new object.
18 * _.zipObject([['fred', 30], ['barney', 40]]);
19 * // => { 'fred': 30, 'barney': 40 }
21 * _.zipObject(['fred', 'barney'], [30, 40]);
22 * // => { 'fred': 30, 'barney': 40 }
24 function zipObject(props, values) {
26 length = props ? props.length : 0,
29 if (length && !values && !isArray(props[0])) {
32 while (++index < length) {
33 var key = props[index];
35 result[key] = values[index];
37 result[key[0]] = key[1];
43 module.exports = zipObject;