From 3014ce30b733d16cbf79f8e066a30db245e6c59d Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Fri, 18 Apr 2025 18:48:20 +0300 Subject: Refactor to use Deno for everything. --- src/shapex.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/shapex.ts') diff --git a/src/shapex.ts b/src/shapex.ts index db8ce08..30c8ef8 100644 --- a/src/shapex.ts +++ b/src/shapex.ts @@ -1,9 +1,9 @@ -type SubscriptionResponseDispatch = { +export type SubscriptionResponseDispatch = { eventName: string; args?: unknown[]; }; -type SubscriptionResponse = { +export type SubscriptionResponse = { state?: T; dispatch?: SubscriptionResponseDispatch | SubscriptionResponseDispatch[]; }; @@ -12,7 +12,7 @@ const isSubscriptionResponseList = ( dispatch: SubscriptionResponseDispatch | SubscriptionResponseDispatch[], ): dispatch is SubscriptionResponseDispatch[] => Array.isArray(dispatch); -type EventCallback = (state: T, ...args: any[]) => SubscriptionResponse; +export type EventCallback = (state: T, ...args: unknown[]) => SubscriptionResponse; type Subscription = { listener: string; @@ -20,13 +20,13 @@ type Subscription = { once: boolean; }; -type ShapeXInstance = { +export type ShapeXInstance = { subscribe: (listener: string, callback: EventCallback) => number; subscribeOnce: (listener: string, callback: EventCallback) => number; unsubscribe: (listener: string) => void; subscriptionCount: (eventName: string) => number; subscriptions: () => string[]; - dispatch: (eventName: string, ...args: any[]) => void; + dispatch: (eventName: string, ...args: unknown[]) => void; }; /** @@ -100,7 +100,7 @@ export default function ShapeX(initialState: T): ShapeXInstanc state: R, path: string, ): { path: string; value: unknown }[] => { - let _paths = []; + const _paths = [] as { path: string; value: unknown }[]; for (const key in state) { const currentPath = `${path}.${key}`; @@ -159,7 +159,7 @@ export default function ShapeX(initialState: T): ShapeXInstanc } const scopedSubsriptions = _subscriptions.get(eventName) ?? []; - const remainingSubscriptions = []; + const remainingSubscriptions = [] as Subscription[]; let callbackCount = 0; for (const subscription of scopedSubsriptions) { -- cgit v1.2.3