setup-maven-cached/node_modules/underscore/modules/object.js

17 lines
537 B
JavaScript
Raw Normal View History

2022-06-28 16:39:30 +08:00
import getLength from './_getLength.js';
// Converts lists into objects. Pass either a single array of `[key, value]`
// pairs, or two parallel arrays of the same length -- one of keys, and one of
// the corresponding values. Passing by pairs is the reverse of `_.pairs`.
export default function object(list, values) {
var result = {};
for (var i = 0, length = getLength(list); i < length; i++) {
if (values) {
result[list[i]] = values[i];
} else {
result[list[i][0]] = list[i][1];
}
}
return result;
}