Package Exports
- js-remove-property
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-remove-property) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
js-remove-property
Remove specific properties from a JavaScript object.
How to use
var removeProp = require('js-remove-property');
var test = {
name: 'hoge',
val: 32,
obj : {
name: 'hoge',
},
complex: {
arry: [
'hoge',
'foo',
{
name: 'hoge',
value: 1
}
]
}
};
removeProp('name', test); // remove 'name' properties
console.log(test);
result is.. -->
{
"val": 32,
"arry": ["hoge", "foo"],
"obj": {},
"nested_obj": {
"value": 1,
"obj": {
"value": 1
}
},
"complex": {
"arry": ["hoge", "foo", {
"value": 1
}]
}
}
How to test
Please test your code before you request pull-request.
$ npm test
#Invalida data input
✓ set null key for remove key
✓ set null object for target object
✓ set null for both arguments
✓ insufficient argument
✓ empty arguments
Remove properties recursively
✓ remove prop of 1st layer property
✓ remove prop of 2nd layer property
✓ remove prop of complex object
8 passing (14ms)