delete-key
v1.1.0
Published
Deletes keys of an object
Downloads
12
Maintainers
Readme
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