Git Product home page Git Product logo

omit-deep's Introduction

omit-deep NPM version NPM monthly downloads NPM total downloads Linux Build Status

Recursively omit the specified key or keys from an object.

Install

Install with npm:

$ npm install --save omit-deep

Usage

var omitDeep = require('omit-deep');

var obj = {a: 'a', b: 'b', c: {b: 'b', d: {b: 'b', f: 'f'}}};
console.log(omitDeep(obj, ['b']));
//=> {a: 'a', c: {d: {f: 'f'}}}

var obj = {a: 'a', b: 'b', c: {b: 'b', d: {b: 'b', f: 'f'}}};
console.log(omitDeep(obj, ['b', 'f']));
//=> {a: 'a', c: {d: {}}}

Also works with dot-notation:

var obj = {a: 'a', b: 'b', c: {b: 'b', d: {b: 'b', f: 'f'}}};
console.log(omitDeep(obj, ['c.d.b', 'f']));
//=> { a: 'a', b: 'b', c: { b: 'b', d: {} } }

About

Contributing

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

Contributors

Commits Contributor
18 jonschlinkert
2 splodingsocks
1 rikukissa

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT license.


This file was generated by verb-generate-readme, v0.2.1, on January 01, 2017.

omit-deep's People

Contributors

jonschlinkert avatar mrmurphy avatar obsd avatar rikukissa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

omit-deep's Issues

Fails if object property is a Javascript Date object

If an object property is a javascript Date object and it is NOT to be omitted, the value is transformed to an empty object ({}) vs. retaining its date value.

Looking deeper, 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.

omitDeep mutates objects

It looks like the omitDeep function is mutating the object I pass in as well as returning it, is this expected behavior or should it be a pure function?

Error in npm example

The npm page for this project is incorrect, you omit the second parameter from the example.

casts `undefined` to empty object

When I run omitDeep({ x: undefined }, 'y')
I expect to receive { x: undefined } (or {})
But I receive { x: {} }

The problem here is that, when I check for the existance of x afterwards, I get false positives.

Is there a good reason for casting this way?
Otherwise I'd like to change this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.