1.0.1 • Published 4 years ago

remove-property v1.0.1

Weekly downloads
275
License
GNU
Repository
github
Last release
4 years ago

remove-property

file size version

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 object
  • p+ 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