@extra-array/zip-object
v1.1.7
Published
Merge values of each object property into corresponding array, like .zip().
Downloads
7
Maintainers
Readme
Merge values of each object property into corresponding array, like _.zip().
const zipObject = require('@extra-array/zip-object');
// zipObject(<array>, [begin=0], [end], [target={}])
zipObject([{odd: 1, even: 2}, {odd: 3, even: 4}, {odd: 5, even: 6}]);
// {odd: [1, 3, 5], even: [2, 4, 6]}
zipObject([{odd: 1, even: 2}, {odd: 3, even: 4}, {odd: 5, even: 6}], 1);
// {odd: [3, 5], even: [4, 6]}
zipObject([{odd: 1, even: 2}, {odd: 3, even: 4}, {odd: 5, even: 6}], 1, 2);
// {odd: [3], even: [4]}
zipObject([{odd: 1, even: 2}, {odd: 3, even: 4}, {odd: 5, even: 6}], 1, 2, {neither: [1.5]});
// {neither: [1.5], odd: [3], even: [4]}
With extra-array try
Array.zipObject()
instead.