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

  1. object*-Object

    The object to filter

  2. filter*-Function

    The filter function that take as parameter the property itself, and the property name

Return

  1. -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

  1. clonetrueBoolean

    Specify if you want to clone the object before filter it

Todo

  • testsnormal