Skip to content

Commit

Permalink
Update isEmptyObject typing
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyStash committed Dec 14, 2023
1 parent 76d55f7 commit c5da0d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/types/utils/EmptyObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import Falsy from './Falsy';

type EmptyObject = Record<string, never>;

type EmptyValue = EmptyObject | null | undefined;

// eslint-disable-next-line rulesdir/no-negated-variables
function isNotEmptyObject<T extends Record<string, unknown> | Falsy>(arg: T | EmptyObject): arg is NonNullable<T> {
return Object.keys(arg ?? {}).length > 0;
}

function isEmptyObject<T>(obj: T | EmptyObject | null | undefined): obj is EmptyObject {
function isEmptyObject<T>(obj: T | EmptyValue): obj is EmptyValue {
return Object.keys(obj ?? {}).length === 0;
}

Expand Down

0 comments on commit c5da0d2

Please sign in to comment.