mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
refactor: get rid of isObjectEmpty function
This commit is contained in:
parent
541b5b1c39
commit
f3d521356d
2 changed files with 2 additions and 17 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue