remove-property
v1.0.1
Published
Removes property of an object
Downloads
25
Maintainers
Readme
remove-property
Create a new object without the unwanted properties from the original one.
Install with:
npm i remove-property
Start requiring and then make the magic happen
const flush = require('remove-property')
You might need at least 2 arguments, the first one is the object you want to change, the second onwards is the fields you want to remove.
flush(obj, param, param1, param2, ..., paramN)
obj
is your objectp+
are strings with the property (key) name to be removed
Sample
const flush = require('remove-property')
const obj = {
name: 'John Heinz Lopes',
password: '1234!@#$',
address: 'Street Calle Rua',
}
const result = flush(obj, 'password', 'address')
// or
const result = flush(obj, ['password', 'address'])
// or
const result = flush(obj, 'password', ['address'])
// or
const result = flush(obj, ...['password', 'address'])
console.log(obj); // { name: 'John Heinz Lopes', password: '1234!@#$', address: 'Street Calle Rua' }
console.log(result); // { name: 'John Heinz Lopes' }
PS: all array will be flattened