Skip to content

Instantly share code, notes, and snippets.

@ahsquared
Created October 26, 2016 20:44
Show Gist options
  • Save ahsquared/4f980dac4e11ae4797a203475ad11f7c to your computer and use it in GitHub Desktop.
Save ahsquared/4f980dac4e11ae4797a203475ad11f7c to your computer and use it in GitHub Desktop.
export function setupMixins() {
_.mixin({
deepPluck: (obj, path) => {
if (_.isString(path)) {
path = path.split(".")
}
return _.reduce(path, function pluck(ret, ident) {
if (ident === "*") {
for (var key in ret) {
if (ret.hasOwnProperty(key)) {
return ret[key];
}
}
}
return ret[ident];
}, obj);
}
});
}
setupMixins();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment