diff --git a/source/event-emitter.ts b/source/event-emitter.ts index 96c200a..7a82c49 100644 --- a/source/event-emitter.ts +++ b/source/event-emitter.ts @@ -187,7 +187,11 @@ export class EventEmitter { * @param timeoutMs - The timeout in milliseconds. * @returns The event payload. */ - async waitFor(type: K, predicate: (payload: DeeplyReadonly) => boolean, timeoutMs?: number): Promise> { + async waitFor( + type: K, + predicate: (payload: DeeplyReadonly) => boolean, + timeoutMs?: number, + ): Promise> { // Create a promise to wait for the event to be emitted. return new Promise((resolve, reject) => { let timeoutId: ReturnType | undefined; diff --git a/source/misc.ts b/source/misc.ts index 157ef72..87aff34 100644 --- a/source/misc.ts +++ b/source/misc.ts @@ -1,4 +1,4 @@ -import { DeeplyReadonly } from "./types"; +import type { DeeplyReadonly } from './types'; /** * Recursively freezes an object by iterating over all properties and freezing them. @@ -6,20 +6,17 @@ import { DeeplyReadonly } from "./types"; * @returns The frozen object. */ export const deepFreeze = (value: T): DeeplyReadonly => { - if ( - value !== null && - (typeof value === 'object' || typeof value === 'function') - ) { + if (value !== null && (typeof value === 'object' || typeof value === 'function')) { for (const key of Reflect.ownKeys(value)) { - const descriptor = Reflect.getOwnPropertyDescriptor(value, key); + const descriptor = Reflect.getOwnPropertyDescriptor(value, key); - if (descriptor && 'value' in descriptor) { - deepFreeze(descriptor.value); - } + if (descriptor && 'value' in descriptor) { + deepFreeze(descriptor.value); + } } Object.freeze(value); } return value; -} +}; diff --git a/source/types.ts b/source/types.ts index b643cde..e1408bd 100644 --- a/source/types.ts +++ b/source/types.ts @@ -4,8 +4,5 @@ * @returns The deeply readonly type. */ export type DeeplyReadonly = { - readonly [K in keyof T]: - T[K] extends (...args: never[]) => unknown - ? T[K] - : DeeplyReadonly; -}; \ No newline at end of file + readonly [K in keyof T]: T[K] extends (...args: never[]) => unknown ? T[K] : DeeplyReadonly; +}; diff --git a/test/event-emitter.test.ts b/test/event-emitter.test.ts index 865a68e..3c66e1d 100644 --- a/test/event-emitter.test.ts +++ b/test/event-emitter.test.ts @@ -5,6 +5,7 @@ import { EventEmitter } from '../source/event-emitter.ts'; type TestEvents = { message: string; count: number; + nested: { nested: { value: number } }; }; /**