diff --git a/core/stdlib/src/patterns/behavioral/Command/types.ts b/core/stdlib/src/patterns/behavioral/Command/types.ts index d64e680..2523783 100644 --- a/core/stdlib/src/patterns/behavioral/Command/types.ts +++ b/core/stdlib/src/patterns/behavioral/Command/types.ts @@ -1,11 +1,11 @@ import type { MaybePromise } from '../../../types'; -export type Command = { +export interface Command { execute: () => void; undo: () => void; -}; +} -export type AsyncCommand = { +export interface AsyncCommand { execute: () => MaybePromise; undo: () => MaybePromise; -}; +} diff --git a/core/stdlib/src/patterns/behavioral/StateMachine/base.ts b/core/stdlib/src/patterns/behavioral/StateMachine/base.ts index d48d713..634f362 100644 --- a/core/stdlib/src/patterns/behavioral/StateMachine/base.ts +++ b/core/stdlib/src/patterns/behavioral/StateMachine/base.ts @@ -8,7 +8,7 @@ */ export class BaseStateMachine< States extends string, - Events extends string, + _Events extends string, Context, NodeConfig, > { diff --git a/core/stdlib/src/patterns/behavioral/StateMachine/types.ts b/core/stdlib/src/patterns/behavioral/StateMachine/types.ts index 9a72834..6b57492 100644 --- a/core/stdlib/src/patterns/behavioral/StateMachine/types.ts +++ b/core/stdlib/src/patterns/behavioral/StateMachine/types.ts @@ -7,18 +7,18 @@ import type { MaybePromise } from '../../../types'; * @template Guard - Guard return type (boolean or MaybePromise\) * @template Action - Action return type (void or MaybePromise\) */ -export type TransitionConfig< +export interface TransitionConfig< Context, Guard = boolean, Action = void, -> = { +> { /** Target state to transition to */ target: string; /** Guard condition — transition only occurs if this returns true */ guard?: (context: Context) => Guard; /** Side effect executed during transition (before entering target state) */ action?: (context: Context) => Action; -}; +} /** * A transition can be a target state name or a detailed configuration @@ -36,18 +36,18 @@ export type Transition< * @template Guard - Guard return type * @template Hook - Hook return type (entry/exit/action) */ -export type StateNodeConfig< +export interface StateNodeConfig< Context, Guard = boolean, Hook = void, -> = { +> { /** Map of event names to transitions */ on?: Record>; /** Hook called when entering this state */ entry?: (context: Context) => Hook; /** Hook called when exiting this state */ exit?: (context: Context) => Hook; -}; +} /** Sync state node config — guards return boolean, hooks return void */ export type SyncStateNodeConfig = StateNodeConfig; diff --git a/core/stdlib/src/structs/BinaryHeap/index.ts b/core/stdlib/src/structs/BinaryHeap/index.ts index 4758051..e5b04cf 100644 --- a/core/stdlib/src/structs/BinaryHeap/index.ts +++ b/core/stdlib/src/structs/BinaryHeap/index.ts @@ -52,7 +52,7 @@ export class BinaryHeap implements BinaryHeapLike { constructor(initialValues?: T[] | T, options?: BinaryHeapOptions) { this.comparator = options?.comparator ?? defaultComparator; - if (initialValues != null) { + if (initialValues !== null && initialValues !== undefined) { const items = isArray(initialValues) ? initialValues : [initialValues]; this.heap.push(...items); this.heapify(); diff --git a/core/stdlib/src/structs/CircularBuffer/index.ts b/core/stdlib/src/structs/CircularBuffer/index.ts index 856c064..9f59972 100644 --- a/core/stdlib/src/structs/CircularBuffer/index.ts +++ b/core/stdlib/src/structs/CircularBuffer/index.ts @@ -21,7 +21,7 @@ export class CircularBuffer implements CircularBufferLike { * @private * @type {(T | undefined)[]} */ - private buffer: (T | undefined)[]; + private buffer: Array; /** * The index of the front element @@ -53,7 +53,7 @@ export class CircularBuffer implements CircularBufferLike { const requested = Math.max(items.length, initialCapacity ?? 0); const cap = Math.max(MIN_CAPACITY, nextPowerOfTwo(requested)); - this.buffer = new Array(cap); + this.buffer = Array.from({ length: cap }); for (const item of items) this.pushBack(item); @@ -190,7 +190,7 @@ export class CircularBuffer implements CircularBufferLike { * @returns {this} */ clear() { - this.buffer = new Array(MIN_CAPACITY); + this.buffer = Array.from({ length: MIN_CAPACITY }); this.head = 0; this.count = 0; @@ -203,7 +203,7 @@ export class CircularBuffer implements CircularBufferLike { * @returns {T[]} */ toArray() { - const result = new Array(this.count); + const result = Array.from({ length: this.count }); for (let i = 0; i < this.count; i++) result[i] = this.buffer[(this.head + i) & (this.buffer.length - 1)] as T; @@ -246,7 +246,7 @@ export class CircularBuffer implements CircularBufferLike { */ private grow() { const newCapacity = this.buffer.length << 1; - const newBuffer = new Array(newCapacity); + const newBuffer = Array.from({ length: newCapacity }); for (let i = 0; i < this.count; i++) newBuffer[i] = this.buffer[(this.head + i) & (this.buffer.length - 1)]; diff --git a/core/stdlib/src/structs/LinkedList/index.ts b/core/stdlib/src/structs/LinkedList/index.ts index 4c8d88c..38d60fa 100644 --- a/core/stdlib/src/structs/LinkedList/index.ts +++ b/core/stdlib/src/structs/LinkedList/index.ts @@ -30,7 +30,7 @@ export class LinkedList implements LinkedListLike { * @private * @type {number} */ - private count: number = 0; + private count = 0; /** * The first node in the list @@ -54,7 +54,7 @@ export class LinkedList implements LinkedListLike { * @param {(T[] | T)} [initialValues] The initial values to add to the list */ constructor(initialValues?: T[] | T) { - if (initialValues != null) { + if (initialValues !== null && initialValues !== undefined) { const items = isArray(initialValues) ? initialValues : [initialValues]; for (const item of items) @@ -258,7 +258,7 @@ export class LinkedList implements LinkedListLike { * @returns {T[]} Array of values from head to tail */ public toArray(): T[] { - const result = new Array(this.count); + const result = Array.from({ length: this.count }); let current = this.first; let i = 0;