MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / zipObject

Function zipObject

MathBox/mathbox-bundle.js:40226–40243  ·  view source on GitHub ↗

* Creates an object composed from arrays of `keys` and `values`. Provide * either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` * or two arrays, one of `keys` and one of corresponding `values`. * * @static * @memberOf _ * @alias object * @

(keys, values)

Source from the content-addressed store, hash-verified

40224 * // => { 'fred': 30, 'barney': 40 }
40225 */
40226 function zipObject(keys, values) {
40227 var index = -1,
40228 length = keys ? keys.length : 0,
40229 result = {};
40230
40231 if (!values && length && !isArray(keys[0])) {
40232 values = [];
40233 }
40234 while (++index < length) {
40235 var key = keys[index];
40236 if (values) {
40237 result[key] = values[index];
40238 } else if (key) {
40239 result[key[0]] = key[1];
40240 }
40241 }
40242 return result;
40243 }
40244
40245 /*--------------------------------------------------------------------------*/
40246

Callers

nothing calls this directly

Calls 1

isArrayFunction · 0.70

Tested by

no test coverage detected