stimulus-store
Version:
Lightweight state management for Stimulus.js
26 lines (25 loc) • 1.1 kB
TypeScript
/**
* Checks if the initial value is defined.
* @param {T} initialValue - The initial value of the store.
* @throws {Error} If the initial value is undefined.
*/
export declare function checkInitialValue<T>(initialValue: T): void;
/**
* Checks if the store name is a string.
* @param {string} name - The name of the store.
* @throws {Error} If the store name is not a string.
*/
export declare function checkName(name: string): void;
/**
* Checks if the type constructor exists in the type map.
* @param {string} type - The type of the store value.
* @throws {Error} If the type constructor does not exist in the type map.
*/
export declare function checkTypeConstructor(type: string): void;
/**
* Handles errors that occur when setting the store value.
* @param {unknown} error - The error that occurred.
* @throws {Error} A new error with the same message if the original error is an instance of Error.
* @throws {Error} A new error with a generic message if the original error is not an instance of Error.
*/
export declare function handleStoreSetError(error: unknown): never;