Skip to content

Instantly share code, notes, and snippets.

@divarvel
Created February 2, 2012 23:46
Show Gist options
  • Save divarvel/1726491 to your computer and use it in GitHub Desktop.
Save divarvel/1726491 to your computer and use it in GitHub Desktop.
flatten & flatMap
function flatten(list) {
return _.reduce(list, function(acc, item) {
return acc.concat(item);
}, []);
}
function flatMap(list, func, context) {
return flatten(_.map(list, func, context));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment