Filter out specified keys from an object (support deep structure).
npm install @jswork/filter-keys-deep
import filterKeysDeep from '@jswork/filter-keys-deep';
const obj = {
a: 1,
b: 2,
items: [
{ name: 'apple', price: 10, is_editing: true },
{ name: 'banana', price: 20, is_editing: false },
]
};
const result = filterKeysDeep(obj, ['is_editing']);
console.log(result);
/* expected output:
{
a: 1,
b: 2,
items: [
{ name: 'apple', price: 10 },
{ name: 'banana', price: 20 }
]
}
*/
Code released under the MIT license.