Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

omit-deep

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

omit-deep - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

30

index.js
'use strict';
var isObject = require('is-plain-object');
var forOwn = require('for-own');
var omit = require('omit-keys');
var unset = require('unset-value');
module.exports = function omitDeep(value, props) {
module.exports = function omitDeep(value, keys) {
if (typeof value === 'undefined') {

@@ -14,3 +13,3 @@ return {};

for (var i = 0; i < value.length; i++) {
value[i] = omitDeep(value[i], props);
value[i] = omitDeep(value[i], keys);
}

@@ -24,8 +23,21 @@ return value;

var o = {};
forOwn(value, function(val, key) {
o[key] = omitDeep(val, props);
});
if (typeof keys === 'string') {
keys = [keys];
}
return omit(o, props);
if (!Array.isArray(keys)) {
return value;
}
for (var j = 0; j < keys.length; j++) {
unset(value, keys[j]);
}
for (var key in value) {
if (value.hasOwnProperty(key)) {
value[key] = omitDeep(value[key], keys);
}
}
return value;
};
{
"name": "omit-deep",
"description": "Recursively omit the specified key or keys from an object.",
"version": "0.2.1",
"version": "0.3.0",
"homepage": "https://github.com/jonschlinkert/omit-deep",

@@ -23,5 +23,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"dependencies": {
"for-own": "^0.1.3",
"is-plain-object": "^2.0.1",
"omit-keys": "^0.1.0"
"unset-value": "^0.1.1"
},

@@ -28,0 +27,0 @@ "devDependencies": {

@@ -18,6 +18,19 @@ # omit-deep [![NPM version](https://img.shields.io/npm/v/omit-deep.svg?style=flat)](https://www.npmjs.com/package/omit-deep) [![NPM monthly downloads](https://img.shields.io/npm/dm/omit-deep.svg?style=flat)](https://npmjs.org/package/omit-deep) [![NPM total downloads](https://img.shields.io/npm/dt/omit-deep.svg?style=flat)](https://npmjs.org/package/omit-deep) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/omit-deep.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/omit-deep)

omitDeep({a: 'a', b: 'b', c: {b: 'b', d: {b: 'b', f: 'f'}}});
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:
```js
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

@@ -33,3 +46,3 @@

| --- | --- |
| 11 | [jonschlinkert](https://github.com/jonschlinkert) |
| 18 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [splodingsocks](https://github.com/splodingsocks) |

@@ -36,0 +49,0 @@ | 1 | [rikukissa](https://github.com/rikukissa) |

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc