UNPKG

@medyll/idae-be

Version:

A modern, lightweight, and extensible DOM manipulation library built with TypeScript. Designed for precise element targeting and manipulation using a callback-based approach. Features include advanced DOM traversal, event handling, style management, attri

66 lines (65 loc) 2.72 kB
import { Be } from '../be.js'; import type { HandlerCallBackFn, CommonHandler, HandlerCallBack } from '../types.js'; declare enum timersMethods { timeout = "timeout", interval = "interval", clearTimeout = "clearTimeout", clearInterval = "clearInterval" } type cd = Record<'timeout' | 'interval', number> & HandlerCallBack; type cds = Record<'clearTimeout' | 'clearInterval', HandlerCallBackFn>; export type TimerHandlerHandle = cd & cds; export declare class TimersHandler implements CommonHandler<TimersHandler, TimerHandlerHandle> { #private; private beElement; static methods: timersMethods[]; constructor(element: Be); methods: string[] | keyof TimersHandler; valueOf(): unknown; handle(actions: TimerHandlerHandle): Be; /** * Sets a timeout for the element(s). * @param value - The timeout duration in milliseconds. * @param callback - The callback function to execute after the timeout. * @returns The Be instance for method chaining. * @example * // HTML: <div id="test"></div> * const beInstance = be('#test'); * beInstance.timeout(1000, () => console.log('Timeout executed')); // Sets a 1-second timeout */ timeout(value: TimerHandlerHandle['timeout'], callback?: HandlerCallBackFn): Be; /** * Sets an interval for the element(s). * @param value - The interval duration in milliseconds. * @param callback - The callback function to execute at each interval. * @returns The Be instance for method chaining. * @example * // HTML: <div id="test"></div> * const beInstance = be('#test'); * beInstance.interval(500, () => console.log('Interval executed')); // Sets a 500ms interval */ interval(value: TimerHandlerHandle['interval'], callback?: HandlerCallBackFn): Be; /** * Clears the timeout for the element(s). * @param callback - Optional callback function. * @returns The Be instance for method chaining. * @example * // HTML: <div id="test"></div> * const beInstance = be('#test'); * beInstance.timeout(1000, () => console.log('Timeout executed')); * beInstance.clearTimeout(); // Clears the timeout */ clearTimeout(callback?: HandlerCallBackFn): Be; /** * Clears the interval for the element(s). * @param callback - Optional callback function. * @returns The Be instance for method chaining. * @example * // HTML: <div id="test"></div> * const beInstance = be('#test'); * beInstance.interval(500, () => console.log('Interval executed')); * beInstance.clearInterval(); // Clears the interval */ clearInterval(callback?: HandlerCallBackFn): Be; } export {};