omit-value

    0.1.1 • Public • Published

    omit-value NPM version

    Omit properties from an object or deeply nested property of an object using object path notation.

    Install

    Install with npm

    $ npm i omit-value --save

    Usage

    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'}

    Related projects

    • 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

    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

    Jon Schlinkert

    License

    Copyright © 2015 Jon Schlinkert Released under the MIT license.


    This file was generated by verb-cli on July 08, 2015.

    Install

    npm i omit-value

    DownloadsWeekly Downloads

    15

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • jonschlinkert