Omit properties from an object or deeply nested property of an object using object path notation.
Install with npm
$ npm i omit-value --save
var omit = require('omit-value');
omit a nested value:
var obj = {foo: {a: 'b', c: 'd'}, bar: {x: 'y'}};
omit(obj, 'foo');
//=> {bar: {x: 'y'}}
omit a nested value:
var obj = {foo: {a: 'b', c: 'd'}};
omit(obj, 'foo', 'a');
// obj.foo ==> {c: 'd'}
omit a deeply nested value:
var obj = {foo: {bar: {baz: {a: 'b', c: 'd'}}}}
omit(obj, 'foo.bar.baz', 'c');
// obj.foo.bar.baz ==> {a: 'b'}
omit multiple deeply nested values:
var obj = {foo: {bar: {baz: {a: 'b', c: 'd', e: 'f', g: 'h'}}}}
omit(obj, 'foo.bar.baz', ['a', 'c', 'g']);
// obj.foo.bar.baz ==> {e: 'f'}
- get-value: Use property paths (
a.b.c
) to get a nested value from an object. - has-value: Returns true if a value exists, false if empty. Works with deeply nested values using… more
- set-value: Create nested values and any intermediaries using dot notation (
'a.b.c'
) paths. - union-value: Set an array of unique values as the property of an object. Supports setting deeply… more
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on July 08, 2015.