UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

44 lines (43 loc) 907 B
/** * @module Lock */ import { TimeSpan } from "../../../../utilities/_module-exports.js"; /** * @internal */ export type ILockState = { expiration: Date | null; }; /** * @internal */ export type ILockStore = Partial<Record<string, ILockState>>; /** * @internal */ export declare class LockState { private stateRecord; private readonly key; constructor(stateRecord: ILockStore, key: string); /** * Return the expiration as a date. */ get(): Date | null; /** * Sets the expiration time. * If a number is provided, it must be in milliseconds. */ set(ttl: TimeSpan | number | null): void; /** * Checks if the key is expired. */ isExpired(): boolean; /** * Returns the remaining time. */ getRemainingTime(): TimeSpan | null; /** * Removes the expiration from the record. */ remove(): void; }