delete-key

1.1.0 • Public • Published

delete-key

Deletes keys of an object.

Installation

Node.js

npm install delete-key --save

Example

const deleteKey = require('delete-key');
 
const targetObj = {a: 4, b: 5, d: {a: 1}};
 
deleteKey(targetObj, ['b, d']);
 
console.log(targetObj); //=> {a: 4};

Deletes recursively

const targetObj = {a: 4, b: 5, d: {a: 1}};
 
deleteKey(targetObj, ['b, a'], true);
 
console.log(targetObj); //=> {a: 4, d: {}};

Copy target object

const targetObj = {a: 4, b: 5, d: {a: 1}};
 
const newTargetObject = deleteKey.copy(targetObj, ['b, a'], true);
 
console.log(targetObj); //=> {a: 4, b: 5, d: {a: 1}};
console.log(newTargetObject); //=> {a: 4, d: {}};

Changelog

You can view the changelog here

License

delete-key is open-sourced software licensed under the MIT license

Author

Fabio Ricali

Package Sidebar

Install

npm i delete-key

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • fabioricali