Skip to content

Commit

Permalink
feat(excludeObjectKeys): add excludeObjectKeys function
Browse files Browse the repository at this point in the history
  • Loading branch information
djcsdy committed Feb 22, 2023
1 parent 6a6bb73 commit 489360a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,25 @@ export function excludeObjectEntriesFn<T extends object>(
return object => excludeObjectEntries(object, predicate);
}

/** Creates a new object that contains the string-keyed properties of the
* specified object, excluded by the specified predicate. */
export function excludeObjectKeys<T extends object>(
object: Readonly<T>,
predicate: (key: StringKey<T>) => boolean
): Partial<StringKeyedProperties<T>> {
return filterObjectKeys(object, key => !predicate(key));
}

/** Curried variant of {@link excludeObjectKeys}.
*
* Returns a function that creates a new object that contains the string-keyed
* properties of the specified object, excluded by the specified predicate. */
export function excludeObjectKeysFn<T extends object>(
predicate: (key: StringKey<T>) => boolean
): (object: Readonly<T>) => Partial<StringKeyedProperties<T>> {
return object => excludeObjectKeys(object, predicate);
}

export function excludeNull<T>(
dictionary: Readonly<Record<string, T | undefined | null>>
): Record<string, T> {
Expand Down

0 comments on commit 489360a

Please sign in to comment.