From f3d521356d1ca64a3472ce1652755703763f9ad7 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 25 Jul 2024 14:52:52 -0300 Subject: [PATCH] refactor: get rid of isObjectEmpty function --- src/utils.test.ts | 11 ++--------- src/utils.ts | 8 -------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/utils.test.ts b/src/utils.test.ts index 1023c633..d89472c6 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -1,6 +1,7 @@ -import { isNumberFrom1To100, isObjectEmpty } from '@/utils.ts'; import { assertEquals } from '@std/assert'; +import { isNumberFrom1To100 } from '@/utils.ts'; + Deno.test('Value is any number from 1 to 100', () => { assertEquals(isNumberFrom1To100('latvia'), false); assertEquals(isNumberFrom1To100(1.5), false); @@ -19,11 +20,3 @@ Deno.test('Value is any number from 1 to 100', () => { assertEquals(isNumberFrom1To100('1e1'), true); }); - -Deno.test('Object is empty', () => { - assertEquals(isObjectEmpty([1]), false); - assertEquals(isObjectEmpty({ 'yolo': 'no yolo' }), false); - - assertEquals(isObjectEmpty([]), true); - assertEquals(isObjectEmpty({}), true); -}); diff --git a/src/utils.ts b/src/utils.ts index de826ad6..a1c3b1d1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -97,13 +97,6 @@ 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, @@ -111,7 +104,6 @@ export { findTag, isNostrId, isNumberFrom1To100, - isObjectEmpty, isURL, type Nip05, nostrDate,