deepdash vs deepmerge vs lodash vs merge-deep vs object-path vs ramda vs underscore
Deep Object Manipulation Libraries in JavaScript
deepdashdeepmergelodashmerge-deepobject-pathramdaunderscoreSimilar Packages:

Deep Object Manipulation Libraries in JavaScript

deepdash, deepmerge, lodash, merge-deep, object-path, ramda, and underscore are all JavaScript utility libraries that help developers work with objects, especially when dealing with deeply nested data structures. These packages provide functions for tasks like deep merging objects, safely accessing nested properties, and transforming complex data. While some are general-purpose utility belts (lodash, underscore, ramda), others focus on specific problems like deep merging (deepmerge, merge-deep) or path-based object access (object-path). deepdash extends Lodash with deep versions of many of its methods. Professional frontend teams choose among these based on their project's architectural style, immutability requirements, and whether they prefer functional programming paradigms or more traditional utility approaches.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
deepdash0278-285 years agoMIT
deepmerge02,82131.2 kB603 years agoMIT
lodash061,5731.41 MB1342 months agoMIT
merge-deep0112-165 years agoMIT
object-path01,067-345 years agoMIT
ramda024,1001.2 MB1466 months agoMIT
underscore027,359908 kB54a month agoMIT

Deep Object Manipulation in JavaScript: A Practical Guide to Popular Utilities

When building complex frontend applications, you often need to work with deeply nested objects — merging configurations, updating nested state, or traversing data structures. The JavaScript ecosystem offers several mature libraries for these tasks, each with distinct philosophies and trade-offs. Let’s compare deepdash, deepmerge, lodash, merge-deep, object-path, ramda, and underscore through the lens of real-world engineering scenarios.

🧩 Core Capabilities: What Each Library Actually Does

Deep Merging Objects

deepmerge is purpose-built for deep object merging with predictable behavior.

import deepmerge from 'deepmerge';

const target = { a: { b: 1 } };
const source = { a: { c: 2 } };
const result = deepmerge(target, source);
// { a: { b: 1, c: 2 } }

lodash provides _.merge() for deep merging, but it mutates the first argument by default (unless you clone it first).

import _ from 'lodash';

const target = { a: { b: 1 } };
const source = { a: { c: 2 } };
const result = _.merge({}, target, source); // Note: {} as first arg to avoid mutation
// { a: { b: 1, c: 2 } }

merge-deep offers a simple, immutable deep merge API.

import mergeDeep from 'merge-deep';

const target = { a: { b: 1 } };
const source = { a: { c: 2 } };
const result = mergeDeep(target, source);
// { a: { b: 1, c: 2 } }

ramda doesn’t include deep merge out of the box, but you can combine R.mergeDeepWith with custom logic.

import * as R from 'ramda';

const target = { a: { b: 1 } };
const source = { a: { c: 2 } };
const result = R.mergeDeepRight(target, source);
// { a: { b: 1, c: 2 } }

underscore has no built-in deep merge — you’d need to implement it manually or use shallow _.extend().

import _ from 'underscore';

const target = { a: { b: 1 } };
const source = { a: { c: 2 } };
const result = _.extend({}, target, source); // Shallow only!
// { a: { c: 2 } } — overwrites entire 'a' property

deepdash extends Lodash with deep versions of many methods, including deep merge.

import _ from 'lodash';
import deepdash from 'deepdash';
const _ = deepdash(_);

const target = { a: { b: 1 } };
const source = { a: { c: 2 } };
const result = _.mergeDeep(target, source);
// { a: { b: 1, c: 2 } }

object-path focuses on path-based access, not merging — so it’s not applicable here.

Accessing Nested Properties Safely

object-path excels at safe, path-based property access.

import objectPath from 'object-path';

const obj = { a: { b: { c: 42 } } };
const value = objectPath.get(obj, 'a.b.c');
// 42
const missing = objectPath.get(obj, 'a.x.y', 'default');
// 'default'

lodash provides _.get() for similar functionality.

import _ from 'lodash';

const obj = { a: { b: { c: 42 } } };
const value = _.get(obj, 'a.b.c');
// 42
const missing = _.get(obj, 'a.x.y', 'default');
// 'default'

ramda uses R.path() for this purpose.

import * as R from 'ramda';

const obj = { a: { b: { c: 42 } } };
const value = R.path(['a', 'b', 'c'], obj);
// 42
const missing = R.pathOr('default', ['a', 'x', 'y'], obj);
// 'default'

underscore has no built-in path access — you’d need to chain _.property() or write custom logic.

import _ from 'underscore';

const obj = { a: { b: { c: 42 } } };
// No direct equivalent — requires manual implementation

deepdash, deepmerge, and merge-deep don’t focus on property access, so they lack this feature.

Functional Programming Style vs Utility Belt

ramda is built around functional programming principles: immutable, curried functions that compose well.

import * as R from 'ramda';

const transform = R.pipe(
  R.assoc('timestamp', Date.now()),
  R.evolve({ count: R.inc })
);

transform({ count: 5 }); // { count: 6, timestamp: 1717020000000 }

lodash and underscore offer a more imperative, utility-belt approach — useful for one-off operations but less composable.

import _ from 'lodash';

const data = { count: 5 };
const transformed = _.assign({}, data, { timestamp: Date.now() });
transformed.count = _.increment(transformed.count); // Note: no _.increment — just example

deepdash enhances Lodash with deep versions of many methods (mapValuesDeep, omitDeep, etc.), making it powerful for nested data transformation.

import _ from 'lodash';
import deepdash from 'deepdash';
const _ = deepdash(_);

const obj = { a: { b: 1, c: null }, d: { e: 2 } };
const cleaned = _.omitDeep(obj, _.isNull);
// { a: { b: 1 }, d: { e: 2 } }

⚙️ Mutation vs Immutability

This is a critical distinction in modern frontend development, especially with React and Redux.

  • lodash: Many methods (like _.merge()) mutate the first argument unless you pass an empty object as the first parameter.
  • deepmerge: Always returns a new object — fully immutable.
  • merge-deep: Also immutable by design.
  • ramda: All functions are immutable and never mutate inputs.
  • underscore: Generally mutable (e.g., _.extend() modifies the first object).
  • deepdash: Follows Lodash’s mutation patterns unless using explicitly immutable variants.
  • object-path: Immutable for reads; set() returns a new object by default (can mutate if you pass { mutable: true }).

📦 Bundle Size and Scope

While we’re not quoting numbers, consider the scope:

  • deepmerge and merge-deep are tiny, single-purpose libraries.
  • object-path is also minimal and focused.
  • lodash and underscore are large utility belts — you’ll likely import only what you need via tree-shaking.
  • ramda is a full FP library — powerful but broad.
  • deepdash is an extension of Lodash, so it adds to Lodash’s footprint.

🛠️ Real-World Decision Guide

Scenario 1: You Need Simple, Reliable Deep Merging

If your only need is deep object merging (e.g., combining config objects), deepmerge is the gold standard — battle-tested, immutable, and zero surprises.

Scenario 2: You’re Already Using Lodash

If you’re already using Lodash for other utilities, lodash’s _.merge() (with an empty initial object) is convenient. If you need deep versions of other Lodash methods (like map, omit, etc.), add deepdash.

Scenario 3: You Prefer Functional Programming

If your codebase embraces FP principles, ramda gives you composable, immutable tools — including mergeDeepRight and path.

Scenario 4: You Frequently Access Nested Properties

For frequent safe access to nested properties (e.g., in form handling or API response parsing), object-path or lodash’s _.get() are excellent choices.

Scenario 5: You’re Working on a Legacy Project

underscore is still found in older codebases, but it lacks modern features like deep merging and safe path access. Avoid it in new projects.

🔄 Key Trade-offs Summarized

LibraryDeep MergeSafe Path AccessImmutabilityFP-FriendlyBest For
deepmerge✅ ExcellentPure deep merging
merge-deep✅ GoodSimple deep merging
lodash✅ (with caveats)✅ (_.get)❌ (mutable by default)General utility work
deepdash✅ (extends Lodash)Deep Lodash operations
object-path✅ Excellent✅ (by default)Nested property access
ramda✅ (mergeDeepRight)✅ (path)Functional programming
underscoreLegacy projects only

💡 Final Recommendation

  • For deep merging only: Choose deepmerge — it’s the most reliable and widely adopted.
  • For mixed utility needs: Use lodash with careful attention to mutation, or ramda if you prefer FP.
  • For nested property access: object-path or lodash.get are both solid.
  • Avoid underscore in new projects — it hasn’t kept pace with modern JavaScript patterns.
  • Consider deepdash only if you’re heavily invested in Lodash and need deep versions of many methods.

Remember: the best library is the one that matches your team’s style, project constraints, and long-term maintainability goals. Don’t add dependencies you don’t need — sometimes a small utility function is better than a full library.

How to Choose: deepdash vs deepmerge vs lodash vs merge-deep vs object-path vs ramda vs underscore

  • deepdash:

    Choose deepdash if you're already using Lodash and need deep versions of Lodash methods like mapValues, omit, or pick that work recursively on nested objects. It's particularly useful when you have complex nested data transformations that go beyond simple merging. However, be aware that it inherits Lodash's mutation behavior unless you explicitly use immutable variants, and it adds to your bundle size on top of Lodash itself.

  • deepmerge:

    Choose deepmerge if your primary need is reliable, immutable deep object merging with predictable behavior. It's the most widely adopted solution for this specific problem and handles edge cases like arrays, dates, and custom merge strategies well. It's ideal for configuration merging, state updates, or any scenario where you need to combine nested objects without side effects.

  • lodash:

    Choose lodash if you need a comprehensive utility library that covers a wide range of operations beyond just deep object manipulation. Its _.merge() and _.get() methods handle common deep object tasks, though you must remember to pass an empty object as the first argument to _.merge() to avoid mutation. Lodash is well-suited for projects that require diverse utility functions and benefit from tree-shaking to minimize bundle impact.

  • merge-deep:

    Choose merge-deep if you want a lightweight, immutable alternative to deepmerge with a simpler API. It's good for basic deep merging scenarios where you don't need advanced customization options like custom merge strategies. However, it's less battle-tested than deepmerge and may not handle as many edge cases, so evaluate carefully for production-critical merging logic.

  • object-path:

    Choose object-path if your main challenge is safely accessing, setting, or deleting deeply nested properties using string paths. It excels at scenarios like form handling, dynamic configuration, or working with API responses where you need to read/write nested values without worrying about undefined intermediate properties. It's not suitable for deep merging or complex transformations, but it's excellent for its specific purpose.

  • ramda:

    Choose ramda if your codebase embraces functional programming principles and you need immutable, composable functions for working with objects. Its mergeDeepRight, path, and pathOr functions handle deep merging and property access elegantly, and everything composes well with other Ramda utilities. It's ideal for teams comfortable with FP concepts who want to avoid mutation entirely and build pipelines of data transformations.

  • underscore:

    Choose underscore only if you're maintaining a legacy codebase that already depends on it. It lacks modern features like deep merging and safe nested property access, and its API feels dated compared to alternatives. For new projects, prefer lodash (which was inspired by Underscore but is more actively maintained and feature-rich) or more specialized libraries based on your specific needs.

README for deepdash

Deepdash

eachDeep, filterDeep, findDeep, someDeep, omitDeep, pickDeep, keysDeep etc.. Tree traversal library written in Underscore/Lodash fashion. Standalone or as a Lodash mixin extension

Deepdash lib is used in PlanZed.org - awesome cloud mind map app created by the author of deepdash.
Plz check it, it's free and I need feedback 😉

All Contributors Known Vulnerabilities Travis (.org) Coverage Status
NPM

Installation

In a browser

Load script after Lodash, then pass a lodash instance to the deepdash function:

<script src="https://cdn.jsdelivr.net/npm/lodash/lodash.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/deepdash/browser/deepdash.min.js"></script>
<script>
  deepdash(_);
  console.log(_.eachDeep); // --> new methods mixed into Lodash
</script>

If you don't use Lodash - there is a standalone version:

<script src="https://cdn.jsdelivr.net/npm/deepdash/browser/deepdash.standalone.min.js"></script>
<script>
  console.log(deepdash.eachDeep); // --> all the methods just work
</script>

Standalone Deepdash weighs more then "dry" version, because it includes some of cherry-picked Lodash methods it depends on. But it's better to use Standalone version, than include full Lodash just as dependency, if you don't need Lodash.

Using npm:

npm i --save deepdash

In Node.js:

// load Lodash if you need it
const _ = require('lodash');
//mixin all the methods into Lodash object
require('deepdash')(_);
// or cherry-pick method you only need and mix it into lodash
require('deepdash/addFilterDeep')(_);
// or cherry-pick method separately if you don't want to mutate Lodash instance
const filterDeep = require('deepdash/getFilterDeep')(_);
// If you don't need Lodash - there is standalone version
const deepdash = require('deepdash/standalone'); // full
const filterDeep = require('deepdash/filterDeep'); // or separate standalone methods

There is also deepdash as ES6 module

npm i --save deepdash-es
import lodash from 'lodash-es';
import deepdash from 'deepdash-es';
const _ = deepdash(lodash);

in the ES package there are same cherry-pick and/or standalone methods as in the main package.

import filterDeep from 'deepdash-es/filterDeep';

or

import { filterDeep } from 'deepdash-es/standalone';

or

import _ from 'lodash-es';
import getFilterDeep from 'deepdash-es/getFilterDeep';
const filterDeep = getFilterDeep(_);

or

import _ from 'lodash-es';
import addFilterDeep from 'deepdash-es/addFilterDeep';
addFilterDeep(_);// --> _.filterDeep

Demo

Example react+redux app with nested comments filtered by Deepdash.(source is here)

Methods

eachDeep (forEachDeep)

› iterate over all the children and sub-children 📚 see docs

expand example
let children = [/* expand to see */];
let children = [
  {
    description: 'description for node 1',
    comment: 'comment for node 1',
    note: 'note for node 1',
    name: 'node 1',
    bad: false,
    children: [
      {
        description: 'description for node 1.1',
        comment: 'comment for node 1.1',
        note: 'note for node 1.1',
        name: 'node 1.1',
        bad: false,
      },
      {
        description: 'description for node 1.2',
        comment: 'comment for node 1.2',
        note: 'note for node 1.2',
        name: 'node 1.2',
        good: true,
      },
      {
        description: 'description for node 1.3',
        comment: 'comment for node 1.3',
        note: 'note for node 1.3',
        name: 'node 1.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 2',
    comment: 'comment for node 2',
    note: 'note for node 2',
    name: 'node 2',
    good: true,
    children: [
      {
        description: 'description for node 2.1',
        comment: 'comment for node 2.1',
        note: 'note for node 2.1',
        name: 'node 2.1',
        bad: false,
      },
      {
        description: 'description for node 2.2',
        comment: 'comment for node 2.2',
        note: 'note for node 2.2',
        name: 'node 2.2',
        good: true,
      },
      {
        description: 'description for node 2.3',
        comment: 'comment for node 2.3',
        note: 'note for node 2.3',
        name: 'node 2.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 3',
    comment: 'comment for node 3',
    note: 'note for node 3',
    name: 'node 3',
    bad: true,
    good: false,
    children: [
      {
        description: 'description for node 3.1',
        comment: 'comment for node 3.1',
        note: 'note for node 3.1',
        name: 'node 3.1',
        bad: false,
      },
      {
        description: 'description for node 3.2',
        comment: 'comment for node 3.2',
        note: 'note for node 3.2',
        name: 'node 3.2',
        good: true,
      },
      {
        description: 'description for node 3.3',
        comment: 'comment for node 3.3',
        note: 'note for node 3.3',
        name: 'node 3.3',
        bad: true,
        good: false,
      },
    ],
  },
];
  function displayField(val, key, parent, context) {
      if (_.isArray(parent)) {
        key = '[' + key + ']';
      }
      console.log(
        _.repeat('   ', context.depth) +
          '→ ' +
          key +
          ': ' +
          (_.isArray(val)
            ? '[' + val.length + ']'
            : _.isObject(val)
            ? '{' + (val.name || '') + '}'
            : val)
      );
    }

    console.log('\n = Iterate over tree (each child object) = \n');

    _.eachDeep(children, displayField, { childrenPath: 'children' });

    console.log('\n = Iterate over object (each field) = \n');

    _.eachDeep(children, displayField);
Console:
 = Iterate over tree (each child object) =

→ [0]: {node 1}
      → [0]: {node 1.1}
      → [1]: {node 1.2}
      → [2]: {node 1.3}
→ [1]: {node 2}
      → [0]: {node 2.1}
      → [1]: {node 2.2}
      → [2]: {node 2.3}
→ [2]: {node 3}
      → [0]: {node 3.1}
      → [1]: {node 3.2}
      → [2]: {node 3.3}

 = Iterate over object (each field) =

→ [0]: {node 1}
   → description: description for node 1
   → comment: comment for node 1
   → note: note for node 1
   → name: node 1
   → bad: false
   → children: [3]
      → [0]: {node 1.1}
         → description: description for node 1.1
         → comment: comment for node 1.1
         → note: note for node 1.1
         → name: node 1.1
         → bad: false
      → [1]: {node 1.2}
         → description: description for node 1.2
         → comment: comment for node 1.2
         → note: note for node 1.2
         → name: node 1.2
         → good: true
      → [2]: {node 1.3}
         → description: description for node 1.3
         → comment: comment for node 1.3
         → note: note for node 1.3
         → name: node 1.3
         → bad: true
         → good: false
→ [1]: {node 2}
   → description: description for node 2
   → comment: comment for node 2
   → note: note for node 2
   → name: node 2
   → good: true
   → children: [3]
      → [0]: {node 2.1}
         → description: description for node 2.1
         → comment: comment for node 2.1
         → note: note for node 2.1
         → name: node 2.1
         → bad: false
      → [1]: {node 2.2}
         → description: description for node 2.2
         → comment: comment for node 2.2
         → note: note for node 2.2
         → name: node 2.2
         → good: true
      → [2]: {node 2.3}
         → description: description for node 2.3
         → comment: comment for node 2.3
         → note: note for node 2.3
         → name: node 2.3
         → bad: true
         → good: false
→ [2]: {node 3}
   → description: description for node 3
   → comment: comment for node 3
   → note: note for node 3
   → name: node 3
   → bad: true
   → good: false
   → children: [3]
      → [0]: {node 3.1}
         → description: description for node 3.1
         → comment: comment for node 3.1
         → note: note for node 3.1
         → name: node 3.1
         → bad: false
      → [1]: {node 3.2}
         → description: description for node 3.2
         → comment: comment for node 3.2
         → note: note for node 3.2
         → name: node 3.2
         → good: true
      → [2]: {node 3.3}
         → description: description for node 3.3
         → comment: comment for node 3.3
         → note: note for node 3.3
         → name: node 3.3
         → bad: true
         → good: false

Try it yourself ›››

filterDeep

› deep filter object 📚 see docs

expand example
let children = [/* expand to see */];
let children = [
  {
    description: 'description for node 1',
    comment: 'comment for node 1',
    note: 'note for node 1',
    name: 'node 1',
    bad: false,
    children: [
      {
        description: 'description for node 1.1',
        comment: 'comment for node 1.1',
        note: 'note for node 1.1',
        name: 'node 1.1',
        bad: false,
      },
      {
        description: 'description for node 1.2',
        comment: 'comment for node 1.2',
        note: 'note for node 1.2',
        name: 'node 1.2',
        good: true,
      },
      {
        description: 'description for node 1.3',
        comment: 'comment for node 1.3',
        note: 'note for node 1.3',
        name: 'node 1.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 2',
    comment: 'comment for node 2',
    note: 'note for node 2',
    name: 'node 2',
    good: true,
    children: [
      {
        description: 'description for node 2.1',
        comment: 'comment for node 2.1',
        note: 'note for node 2.1',
        name: 'node 2.1',
        bad: false,
      },
      {
        description: 'description for node 2.2',
        comment: 'comment for node 2.2',
        note: 'note for node 2.2',
        name: 'node 2.2',
        good: true,
      },
      {
        description: 'description for node 2.3',
        comment: 'comment for node 2.3',
        note: 'note for node 2.3',
        name: 'node 2.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 3',
    comment: 'comment for node 3',
    note: 'note for node 3',
    name: 'node 3',
    bad: true,
    good: false,
    children: [
      {
        description: 'description for node 3.1',
        comment: 'comment for node 3.1',
        note: 'note for node 3.1',
        name: 'node 3.1',
        bad: false,
      },
      {
        description: 'description for node 3.2',
        comment: 'comment for node 3.2',
        note: 'note for node 3.2',
        name: 'node 3.2',
        good: true,
      },
      {
        description: 'description for node 3.3',
        comment: 'comment for node 3.3',
        note: 'note for node 3.3',
        name: 'node 3.3',
        bad: true,
        good: false,
      },
    ],
  },
];
  console.log('\n = Filter tree (good children) = \n');

  console.log(
    _.filterDeep(children, 'good', { childrenPath: 'children' })
  );

  console.log('\n = Filter object (names of good children) = \n');

  console.log(
      _.filterDeep(children, (val, key, parent) => {
        if (key == 'name' && parent.good) return true;
      })
  );
Console:
 = Filter tree (good children) =

[
  {
    "description": "description for node 1",
    "comment": "comment for node 1",
    "note": "note for node 1",
    "name": "node 1",
    "bad": false,
    "children": [
      {
        "description": "description for node 1.2",
        "comment": "comment for node 1.2",
        "note": "note for node 1.2",
        "name": "node 1.2",
        "good": true
      }
    ]
  },
  {
    "description": "description for node 2",
    "comment": "comment for node 2",
    "note": "note for node 2",
    "name": "node 2",
    "good": true,
    "children": [
      {
        "description": "description for node 2.2",
        "comment": "comment for node 2.2",
        "note": "note for node 2.2",
        "name": "node 2.2",
        "good": true
      }
    ]
  },
  {
    "description": "description for node 3",
    "comment": "comment for node 3",
    "note": "note for node 3",
    "name": "node 3",
    "bad": true,
    "good": false,
    "children": [
      {
        "description": "description for node 3.2",
        "comment": "comment for node 3.2",
        "note": "note for node 3.2",
        "name": "node 3.2",
        "good": true
      }
    ]
  }
]

 = Filter object (names of good children) =

[
  {
    "children": [
      {
        "name": "node 1.2"
      }
    ]
  },
  {
    "name": "node 2",
    "children": [
      {
        "name": "node 2.2"
      }
    ]
  },
  {
    "children": [
      {
        "name": "node 3.2"
      }
    ]
  }
]

Try it yourself ›››

findDeep

› find first matching deep meta-value 📚 see docs

example a bit later
let children = [/* expand to see */];
// next time
// sorry
Console:
❤️

Try it yourself (no yet) ›››

findValueDeep

› find first matching deep value 📚 see docs

example a bit later
let children = [/* expand to see */];
// next time
// sorry
Console:
❤️

Try it yourself (no yet) ›››

findPathDeep

› find the path of the first matching deep value 📚 see docs

example a bit later
let children = [/* expand to see */];
// next time
// sorry
Console:
❤️

Try it yourself (no yet) ›››

mapDeep

› get array of values processed by iteratee. 📚 see docs

expand example
  let res = _.mapDeep(
    { hello: { from: { the: 'deep world', and: 'deepdash' } } },
    (v) => v.toUpperCase(),
    { leavesOnly: true }
  );
  // res -> ['DEEP WORLD','DEEPDASH']

Try it yourself (no yet) ›››

mapValuesDeep

› get the object with same structure, but transformed values. 📚 see docs

expand example
  let res = _.mapValuesDeep(
    { hello: { from: { the: 'deep world' } } },
    (v) => v.toUpperCase(),
    { leavesOnly: true }
  );
  // res -> { hello: { from: { the: 'DEEP WORLD' } } }

Try it yourself ›››

mapKeysDeep

› get the object with same values, but transformed keys. 📚 see docs

expand example
  let res = _.mapKeysDeep(
    { hello: { from: { the: 'deep world' } } },
    (v, k) => k.toUpperCase()
  );
  // res -> { HELLO: { FROM: { THE: 'deep world' } } }

Try it yourself (no yet) ›››

reduceDeep

› like reduce, but deep 📚 see docs

expand example
  let max = _.reduceDeep({ a: 2, b: 3, c: { d: 6, e: [1, 5, 8] } },
    (acc, value, key, parent, ctx) => {
      if (typeof value == 'number' && (typeof acc != 'number' || value > acc))
        return value;
      return undefined;
    }
  );
  // max == 8

Try it yourself ›››

someDeep

› returns true if some matching deep value found 📚 see docs

example a bit later
let children = [/* expand to see */];
// next time
// sorry
Console:
❤️

Try it yourself (no yet) ›››

pickDeep

› pick values by paths specified by endings or regexes 📚 see docs

expand example
let children = [/* expand to see */];
let children = [
  {
    description: 'description for node 1',
    comment: 'comment for node 1',
    note: 'note for node 1',
    name: 'node 1',
    bad: false,
    children: [
      {
        description: 'description for node 1.1',
        comment: 'comment for node 1.1',
        note: 'note for node 1.1',
        name: 'node 1.1',
        bad: false,
      },
      {
        description: 'description for node 1.2',
        comment: 'comment for node 1.2',
        note: 'note for node 1.2',
        name: 'node 1.2',
        good: true,
      },
      {
        description: 'description for node 1.3',
        comment: 'comment for node 1.3',
        note: 'note for node 1.3',
        name: 'node 1.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 2',
    comment: 'comment for node 2',
    note: 'note for node 2',
    name: 'node 2',
    good: true,
    children: [
      {
        description: 'description for node 2.1',
        comment: 'comment for node 2.1',
        note: 'note for node 2.1',
        name: 'node 2.1',
        bad: false,
      },
      {
        description: 'description for node 2.2',
        comment: 'comment for node 2.2',
        note: 'note for node 2.2',
        name: 'node 2.2',
        good: true,
      },
      {
        description: 'description for node 2.3',
        comment: 'comment for node 2.3',
        note: 'note for node 2.3',
        name: 'node 2.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 3',
    comment: 'comment for node 3',
    note: 'note for node 3',
    name: 'node 3',
    bad: true,
    good: false,
    children: [
      {
        description: 'description for node 3.1',
        comment: 'comment for node 3.1',
        note: 'note for node 3.1',
        name: 'node 3.1',
        bad: false,
      },
      {
        description: 'description for node 3.2',
        comment: 'comment for node 3.2',
        note: 'note for node 3.2',
        name: 'node 3.2',
        good: true,
      },
      {
        description: 'description for node 3.3',
        comment: 'comment for node 3.3',
        note: 'note for node 3.3',
        name: 'node 3.3',
        bad: true,
        good: false,
      },
    ],
  },
];
  console.log('\n = Pick name and description only = \n');

  console.log(
    _.pickDeep(children, ['name', 'description'])
  );
Console:
 = Pick name and description only =

[
  {
    "description": "description for node 1",
    "name": "node 1",
    "children": [
      {
        "description": "description for node 1.1",
        "name": "node 1.1"
      },
      {
        "description": "description for node 1.2",
        "name": "node 1.2"
      },
      {
        "description": "description for node 1.3",
        "name": "node 1.3"
      }
    ]
  },
  {
    "description": "description for node 2",
    "name": "node 2",
    "children": [
      {
        "description": "description for node 2.1",
        "name": "node 2.1"
      },
      {
        "description": "description for node 2.2",
        "name": "node 2.2"
      },
      {
        "description": "description for node 2.3",
        "name": "node 2.3"
      }
    ]
  },
  {
    "description": "description for node 3",
    "name": "node 3",
    "children": [
      {
        "description": "description for node 3.1",
        "name": "node 3.1"
      },
      {
        "description": "description for node 3.2",
        "name": "node 3.2"
      },
      {
        "description": "description for node 3.3",
        "name": "node 3.3"
      }
    ]
  }
]

Try it yourself ›››

omitDeep

› get object without paths specified by endings or regexes 📚 see docs

expand example
let children = [/* expand to see */];
let children = [
  {
    description: 'description for node 1',
    comment: 'comment for node 1',
    note: 'note for node 1',
    name: 'node 1',
    bad: false,
    children: [
      {
        description: 'description for node 1.1',
        comment: 'comment for node 1.1',
        note: 'note for node 1.1',
        name: 'node 1.1',
        bad: false,
      },
      {
        description: 'description for node 1.2',
        comment: 'comment for node 1.2',
        note: 'note for node 1.2',
        name: 'node 1.2',
        good: true,
      },
      {
        description: 'description for node 1.3',
        comment: 'comment for node 1.3',
        note: 'note for node 1.3',
        name: 'node 1.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 2',
    comment: 'comment for node 2',
    note: 'note for node 2',
    name: 'node 2',
    good: true,
    children: [
      {
        description: 'description for node 2.1',
        comment: 'comment for node 2.1',
        note: 'note for node 2.1',
        name: 'node 2.1',
        bad: false,
      },
      {
        description: 'description for node 2.2',
        comment: 'comment for node 2.2',
        note: 'note for node 2.2',
        name: 'node 2.2',
        good: true,
      },
      {
        description: 'description for node 2.3',
        comment: 'comment for node 2.3',
        note: 'note for node 2.3',
        name: 'node 2.3',
        bad: true,
        good: false,
      },
    ],
  },
  {
    description: 'description for node 3',
    comment: 'comment for node 3',
    note: 'note for node 3',
    name: 'node 3',
    bad: true,
    good: false,
    children: [
      {
        description: 'description for node 3.1',
        comment: 'comment for node 3.1',
        note: 'note for node 3.1',
        name: 'node 3.1',
        bad: false,
      },
      {
        description: 'description for node 3.2',
        comment: 'comment for node 3.2',
        note: 'note for node 3.2',
        name: 'node 3.2',
        good: true,
      },
      {
        description: 'description for node 3.3',
        comment: 'comment for node 3.3',
        note: 'note for node 3.3',
        name: 'node 3.3',
        bad: true,
        good: false,
      },
    ],
  },
];
  console.log('\n = Omit paths not ending with "e" = \n');

  console.log(
    _.omitDeep(children, /[^e]$/i, { onMatch: { skipChildren: false } }),
  );
Console:
 = Omit paths not ending with "e" =

[
  {
    "note": "note for node 1",
    "name": "node 1",
    "children": [
      {
        "note": "note for node 1.1",
        "name": "node 1.1"
      },
      {
        "note": "note for node 1.2",
        "name": "node 1.2"
      },
      {
        "note": "note for node 1.3",
        "name": "node 1.3"
      }
    ]
  },
  {
    "note": "note for node 2",
    "name": "node 2",
    "children": [
      {
        "note": "note for node 2.1",
        "name": "node 2.1"
      },
      {
        "note": "note for node 2.2",
        "name": "node 2.2"
      },
      {
        "note": "note for node 2.3",
        "name": "node 2.3"
      }
    ]
  },
  {
    "note": "note for node 3",
    "name": "node 3",
    "children": [
      {
        "note": "note for node 3.1",
        "name": "node 3.1"
      },
      {
        "note": "note for node 3.2",
        "name": "node 3.2"
      },
      {
        "note": "note for node 3.3",
        "name": "node 3.3"
      }
    ]
  }
]

Try it yourself ›››

index

› get an object with all the paths as keys and corresponding values 📚 see docs

expand example
  let index = _.index(
    {
      a: {
        b: {
          c: [1, 2, 3],
          'hello world': {},
        },
      },
    },
    { leavesOnly: true }
  );
  console.log(index);

Console:

{ 'a.b.c[0]': 1,
  'a.b.c[1]': 2,
  'a.b.c[2]': 3,
  'a.b["hello world"]': {} }

Try it yourself ›››

paths (keysDeep)

› get an array of paths 📚 see docs

expand example
  let paths = _.paths(
    {
      a: {
        b: {
          c: [1, 2, 3],
          'hello world': {},
        },
      },
    },
    { leavesOnly: false }
  );
  console.log(paths);

Console:

[ 'a',
  'a.b',
  'a.b.c',
  'a.b.c[0]',
  'a.b.c[1]',
  'a.b.c[2]',
  'a.b["hello world"]' ]

Try it yourself ›››

condense

› condense sparse array 📚 see docs

expand example
  let arr = ['a', 'b', 'c', 'd', 'e'];
  delete arr[1];
  console.log(arr);
  delete arr[3];
  console.log(arr);
  _.condense(arr);
  console.log(arr);

Console:

  [ 'a', <1 empty item>, 'c', 'd', 'e' ]
  [ 'a', <1 empty item>, 'c', <1 empty item>, 'e' ]
  [ 'a', 'c', 'e' ]

Try it yourself ›››

condenseDeep

› condense all the nested arrays 📚 see docs

expand example
  let obj = { arr: ['a', 'b', { c: [1, , 2, , 3] }, 'd', 'e'] };
  delete obj.arr[1];
  delete obj.arr[3];
  _.condenseDeep(obj);
  console.log(obj);

Console:

  { arr: [ 'a', { c: [ 1, 2, 3 ] }, 'e' ] }

Try it yourself ›››

exists

› like a _.has but returns false for empty array slots 📚 see docs

expand example
  var obj = [, { a: [, 'b'] }];
  console.log(_.exists(obj, 0)); // false
  console.log(_.exists(obj, 1)); // true
  console.log(_.exists(obj, '[1].a[0]')); // false
  console.log(_.exists(obj, '[1].a[1]')); // true

Try it yourself ›››

pathToString

› convert an array to string path (opposite to _.toPath) 📚 see docs

expand example
  console.log(_.pathToString(['a', 'b', 'c', 'defg', 0, '1', 2.3]
    ,'prefix1', 'prefix2', '[3]'));
  // prefix1.prefix2[3].a.b.c.defg[0][1]["2.3"]
  console.log(_.pathToString(['"', '"', '"']));
  // ["\\""]["\\""]["\\""]
  console.log(_.pathToString('it.s.a.string'));
  // it.s.a.string

Try it yourself ›››

See full docs for details.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Raz Sinay

💻 📓 🤔

Florent

🐛 📓

JoeSchr

🤔 📓

Matt Black

🤔

Lukas Siemon

🤔 📓 💻 📢 ⚠️

crapthings

🤔

Corrado Masciullo

🐛 🤔

Jed Richards

🚇

Kolja Zuelsdorf

🐛 📓 💡

Noval Agung Prayogo

💬

Nathan Tomsic

🤔

madflow

💬

Matthew Kirkley

🐛 🤔

Torma Gábor

🐛 🤔 📓

Andreas Richter

🐛 📓

James

🐛 💻 📖 📓

rxliuli

🐛 💻 📖

TeleMediaCC

🐛

Nicolas Coutin

💵 📓

barrct

🐛 📖

casamia918

🐛 💻 📖

ferreirix

🤔

John Camden

🐛

Joshua

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!