shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
filterDeep
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.object
Allow to filter an object using a function and this through all of the object structure. It works the same as the filter method on the Array object type. The passed filter function will have as parameter each object properties and must return true or false depending if you want the passed property in the filtered object
Params
- object*-Object
The object to filter
- filter*-Function
The filter function that take as parameter the property itself, and the property name
Return
- -Object
The filtered object
Example
import { filterDeep } from '@blackbyte/sugar/object';
filterDeep ({
coco: 'hello',
plop: true,
sub: {
property: 'world'
}
}, ({key, value}) => typeof item === 'string');
// {
// coco: 'hello'
// sub: {
// property: 'world'
// }
// }Settings
- clonetrueBoolean
Specify if you want to clone the object before filter it
Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space