Skip to content

odynvolk/omit-deep-lodash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3d4c5ef · Jun 12, 2022

History

55 Commits
Nov 10, 2018
Oct 13, 2020
Apr 20, 2017
May 6, 2017
May 6, 2017
May 6, 2017
Jul 30, 2018
Sep 21, 2020
May 6, 2017
Jul 22, 2018
Apr 22, 2016
Jun 12, 2022
Oct 29, 2018
Apr 9, 2022
Jun 12, 2022

Repository files navigation

omit-deep-lodash

Omit object key/values recursively

Sometimes we need to omit things from an object recursively. omit-deep did this in a great manner but hadn't been updated for quite some time and didn't really work with Arrays. omit-deep-lodash solves this and uses only lodash as external dependency.

The code for this module uses new features in the Javascript language, but the code is transpiled by Babel to ES2015 so most projects who needs it should be able to use it.

Note! All non-omitted properties that are objects lose their prototype chains and thus their true type. This implementation is thus best used for simple JSON type objects like data objects and not typed object graphs where members have objects with constructors.

Install

Install with npm

$ npm i omit-deep-lodash --save

Usage

const omitDeep = require("omit-deep-lodash");

omitDeep({a: "a", b: "b", c: {b: "b", d: {b: "b", f: "f"}}}, "b");
//=> {a: "a", c: {d: {f: "f"}}}

omitDeep({a: "a", b: "b", c: {b: "b", d: {b: "b", f: "f"}}}, "a", "b");
//=> {c: {d: {f: "f"}}}

Related projects

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

License

Released under the MIT license.