feat(utils.ts): create isObjectEmpty function

This commit is contained in:
P. Reis 2024-07-19 16:26:50 -03:00
parent cc6441d239
commit c17db58448

View file

@ -97,6 +97,13 @@ function isNumberFrom1To100(value: unknown): boolean {
return z.coerce.number().int().gte(1).lte(100).safeParse(value).success;
}
function isObjectEmpty(obj: object): boolean {
for (const prop in obj) {
if (Object.hasOwn(obj, prop)) return false;
}
return true;
}
export {
bech32ToPubkey,
dedupeEvents,
@ -104,6 +111,7 @@ export {
findTag,
isNostrId,
isNumberFrom1To100,
isObjectEmpty,
isURL,
type Nip05,
nostrDate,