hd-utils
Version:
A handy utils for modern JS developers
20 lines (19 loc) • 802 B
TypeScript
import { KeysArr, PredicateFunc } from '../types';
/**
* "It returns a new object with the same keys as the original object, except for the keys that match
* the predicate."
*
* The predicate is a function that takes three arguments: the key, the value, and the object. It
* returns true if the key should be included in the new object, and false if it should be excluded
* @example excludeKeys({
foo: true,
bar: false
}, (key, value) => value === true) => {bar: false}
* @example excludeKeys({
foo: true,
bar: false
}, ["foo"]) => {bar:true}
* @param object - The object to filter.
* @param predicate - A function that returns true if the key should be included.
*/
export default function excludeKeys<T extends object>(object: T, predicate: KeysArr | PredicateFunc<T>): {};