pruneKeyWhen

pruneKeyWhen

Remove key from an object when predicate is true

Import

import { pruneKeyWhen } from '@fullstacksjs/toolbox';

Signature

function pruneKeyWhen(min: number = 0, max: number = Number.MAX_SAFE_INTEGER): number {}

Examples

pruneKeyWhen({ a: { b: null } }, () => false)      // { a: { b: null } }
pruneKeyWhen({ a: 'John', b: {} }, () => true)     // {}
pruneKeyWhen({ a: null, age: '' }, k => k === 'a') // { a: null }