Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-dropkey
From each object in an array, delete keys specified
https://github.com/wankdanker/node-dropkey
Last synced: 14 days ago
JSON representation
From each object in an array, delete keys specified
- Host: GitHub
- URL: https://github.com/wankdanker/node-dropkey
- Owner: wankdanker
- Created: 2015-11-27T14:31:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-27T14:42:36.000Z (about 9 years ago)
- Last Synced: 2024-12-13T09:39:17.535Z (25 days ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
dropkey
-------From each object in an array, delete keys specified
example
-------```js
var dk = require('dropkey');
var a = [{ item_id : 1, name : 'test1' }, { item_id : 2, name : 'test2' }]dk(a, ['item_id']);
console.log(a);
//[{ name : 'test1' }, { name : 'test2' }]
```api
---### dropkey(objectArray, keyArray)
* objectArray: [Array] - an array containing objects to process
* keyArray: [Array] - an array of strings containing the keys to delete from the objects in objectArrayadditional info
---------------There's nothing magical about this. This is just a module for this small snippet of code:
```js
function dropkeys (array, dropable) {
array.forEach(function (item) {
dropable.forEach(function (key) {
delete item[key];
});
});
return array;
}
```license
-------MIT