Created
October 26, 2016 20:44
-
-
Save ahsquared/4f980dac4e11ae4797a203475ad11f7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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