filterObject

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.object

Allow to filter an object using a function. 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 { filterObject } from '@blackbyte/sugar/object';
filterObject({
   coco: 'hello',
   plop: true
}, (key, item) => typeof item === 'string');
// { coco: 'hello' }

Todo

  • testsnormal