mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29: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 { assertEquals } from '@std/assert';
|
||||||
|
|
||||||
|
import { isNumberFrom1To100 } from '@/utils.ts';
|
||||||
|
|
||||||
Deno.test('Value is any number from 1 to 100', () => {
|
Deno.test('Value is any number from 1 to 100', () => {
|
||||||
assertEquals(isNumberFrom1To100('latvia'), false);
|
assertEquals(isNumberFrom1To100('latvia'), false);
|
||||||
assertEquals(isNumberFrom1To100(1.5), false);
|
assertEquals(isNumberFrom1To100(1.5), false);
|
||||||
|
|
@ -19,11 +20,3 @@ Deno.test('Value is any number from 1 to 100', () => {
|
||||||
|
|
||||||
assertEquals(isNumberFrom1To100('1e1'), true);
|
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;
|
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 {
|
export {
|
||||||
bech32ToPubkey,
|
bech32ToPubkey,
|
||||||
dedupeEvents,
|
dedupeEvents,
|
||||||
|
|
@ -111,7 +104,6 @@ export {
|
||||||
findTag,
|
findTag,
|
||||||
isNostrId,
|
isNostrId,
|
||||||
isNumberFrom1To100,
|
isNumberFrom1To100,
|
||||||
isObjectEmpty,
|
|
||||||
isURL,
|
isURL,
|
||||||
type Nip05,
|
type Nip05,
|
||||||
nostrDate,
|
nostrDate,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue