edge-master
Version:
A Micro Framework for Edges
26 lines (25 loc) • 826 B
TypeScript
import { Context } from '../types/base';
/**
* Sets a value in the context state
*/
export declare function setState<T = any>(ctx: Context, key: string, value: T): void;
/**
* Gets a value from the context state
*/
export declare function getState<T = any>(ctx: Context, key: string): T | undefined;
/**
* Gets a value from the context state or returns a default value
*/
export declare function getStateOr<T = any>(ctx: Context, key: string, defaultValue: T): T;
/**
* Checks if a key exists in the context state
*/
export declare function hasState(ctx: Context, key: string): boolean;
/**
* Deletes a value from the context state
*/
export declare function deleteState(ctx: Context, key: string): boolean;
/**
* Clears all values from the context state
*/
export declare function clearState(ctx: Context): void;