Skip to content

Instantly share code, notes, and snippets.

@stockholmux stockholmux/deinterleave.js Secret
Last active Oct 31, 2017

What would you like to do?
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
You can’t perform that action at this time.