From 47a07c1404364d3e135b3600ccc2c6eb19c3e346 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Tue, 15 Jul 2025 16:57:15 +0300 Subject: Fix typos, bump deps --- src/shapex.ts | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/shapex.ts b/src/shapex.ts index 09f0c0c..3ff67a8 100644 --- a/src/shapex.ts +++ b/src/shapex.ts @@ -24,7 +24,7 @@ const isSubscriptionResponseList = ( ): dispatch is SubscriptionResponseDispatch[] => Array.isArray(dispatch); /** - * A callback passed to subcriptions, called when the event + * A callback passed to subscriptions, called when the event * that the subscription is listening to is called. */ export type EventCallback< @@ -55,7 +55,7 @@ type Subscription< */ export type ShapeXInstance = { /** - * Subcribe to an event. + * Subscribe to an event. */ subscribe: ( listener: string, @@ -99,7 +99,7 @@ export type ShapeXInstance = { * A function that creates an EventX object. * * @param {T extends object} initialState The initial application state. - * @returns {ShapeXInstance} The ShapeX object. + * @returns {ShapeXInstance} The ShapeX object. */ export function ShapeX(initialState: T): ShapeXInstance { let _state = initialState; @@ -110,10 +110,10 @@ export function ShapeX(initialState: T): ShapeXInstance { let subscriptionId = 0; /** - * Subcribe to an event. + * Subscribe to an event. * * @param {string} listener - * @param {EventCallback} callback + * @param {EventCallback} callback * @returns */ const subscribe = < @@ -140,10 +140,10 @@ export function ShapeX(initialState: T): ShapeXInstance { }; /** - * Subcribe to an event, once. + * Subscribe to an event, once. * * @param {string} listener - * @param {EventCallback} callback + * @param {EventCallback} callback * @returns */ const subscribeOnce = ( @@ -287,23 +287,14 @@ export function ShapeX(initialState: T): ShapeXInstance { to: string, withData?: W, ): void => { - if (!_subscriptions.has(to)) { - return; - } + if (!_subscriptions.has(to)) return; - const scopedSubsriptions = _subscriptions.get(to) ?? []; - const remainingSubscriptions = [] as Array< - Subscription - >; + const scopedSubscriptions = _subscriptions.get(to) ?? []; + const remainingSubscriptions = [] as Array>; let callbackCount = 0; - for (const subscription of scopedSubsriptions) { - const callback = subscription.callback as unknown as EventCallback< - T, - W, - unknown - >; - + for (const subscription of scopedSubscriptions) { + const callback = subscription.callback as unknown as EventCallback; let response = withData ? callback(_state, withData) : callback(_state); // Async response @@ -362,7 +353,7 @@ export function ShapeX(initialState: T): ShapeXInstance { /** * Returns the current state. * - * @returns {T} The current state. + * @returns {} The current state. */ const state = (): T => { return _state; -- cgit v1.2.3