lodash deinterleave
const deinterleave = function(doc) { // `doc` is an array like this `['fname','kyle','lname','davis']` | |
return _(doc) // Start the lodash chain with `doc` | |
.chunk(2) // `chunk` to convert `doc` to `[['fname','kyle'],['lname','davis']]` | |
.fromPairs() // `fromPairs` converts paired arrays into objects `{ fname : 'kyle', lname : 'davis }` | |
.value(); // Stop the chain and return it back | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment