Skip to content

Instantly share code, notes, and snippets.

View Oliboy50's full-sized avatar
🐈
💨

Oliver THEBAULT Oliboy50

🐈
💨
View GitHub Profile
I am the Miaou user with id 103 and name "Oliboy50" on http://dystroy.org/miaou
@Oliboy50
Oliboy50 / multiGet.js
Last active May 8, 2018 14:40
Lodash multi get (with `[]` path syntax)
const _ = require('lodash');
function multiGet(object, path, defaultValue) {
return path
.split('[]')
.reduce((resolvedPaths, pathShard, pathShardIndex, pathShards) => {
const isFirstPathShard = pathShardIndex === 0;
const isLastPathShard = pathShardIndex === pathShards.length -1;
return resolvedPaths
.map(resolvedPath => {