Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/remove-field
removes a list of fields from a json
https://github.com/mcollina/remove-field
Last synced: 13 days ago
JSON representation
removes a list of fields from a json
- Host: GitHub
- URL: https://github.com/mcollina/remove-field
- Owner: mcollina
- License: mit
- Created: 2016-01-07T10:41:26.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-07T11:20:15.000Z (about 9 years ago)
- Last Synced: 2024-12-25T10:21:32.758Z (15 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remove-field [![Build Status](https://travis-ci.org/mcollina/remove-field.svg)](https://travis-ci.org/mcollina/remove-field)
Creates a new Object with some field removed.
Every field not listed in the first argument will be deep copied.## Install
```
npm i remove-field --save
```## Usage
```js
var remove = require('remove-field')
var original = {
a: '1',
hello: 'world',
b: { an: 'object' },
some: [{
something: 'else',
b: 'aaa'
}, {
a: 'aaaa'
}],
deep: {
deep: {
a: 'to remove',
answer: 42
}
}
}var result = remove(['a', 'b'], original)
console.log(result)
console.log(result !== original)// prints
//
// { hello: 'world',
// some: [ { something: 'else' }, {} ],
// deep: { deep: { answer: 42 } } }
// truevar result2 = remove('a', original)
console.log(result2)
// prints
//
// { hello: 'world',
// b: { an: 'object' },
// some: [ { something: 'else', b: 'aaa' }, {} ],
// deep: { deep: { answer: 42 } } }```
## Acknowledgements
remove-field is sponsored by [nearForm](http://nearform.com).
## License
MIT