The object to filter.
The options for filtering.
Available presets: no-falsy
, no-empty
, no-null
, no-undefined
filterKeys({ a: 1, b: 2, c: 3 }, { filter: (key, value) => value === 2 })
// returns { b: 2 }
filterKeys({ a: 1, b: 2, c: 3 }, { filter: (key, value) => key === 'a' })
// returns { a: 2 }
filterKeys({ a: 1, b: 2, c: null }, { preset: 'no-null' })
// returns { a: 2, b: 2 }
Filters the keys of an object based on provided options. Supports presets: