|
| 1 | +/*! |
| 2 | + * WebUtils Library v1.0.0 |
| 3 | + * Author: Khin Maung Win |
| 4 | + * License: MIT |
| 5 | + * Standalone utility library for all websites (TypeScript version) |
| 6 | + */ |
| 7 | +type EventHandler = EventListenerOrEventListenerObject; |
| 8 | +declare const WebUtils: { |
| 9 | + $: (selector: string, all?: boolean) => Element | NodeListOf<Element> | null; |
| 10 | + addClass: (el: Element | Element[] | NodeListOf<Element> | null, className: string) => void; |
| 11 | + removeClass: (el: Element | Element[] | NodeListOf<Element> | null, className: string) => void; |
| 12 | + toggleClass: (el: Element | Element[] | NodeListOf<Element> | null, className: string) => void; |
| 13 | + on: (el: Element | Element[] | NodeListOf<Element> | null, event: string, handler: EventHandler) => void; |
| 14 | + off: (el: Element | Element[] | NodeListOf<Element> | null, event: string, handler: EventHandler) => void; |
| 15 | + getCookie: (name: string) => string | null; |
| 16 | + setCookie: (name: string, value: string, days?: number) => void; |
| 17 | + deleteCookie: (name: string) => void; |
| 18 | + getQueryParams: () => Record<string, string>; |
| 19 | + fetchJson: (url: string, options?: RequestInit) => Promise<any>; |
| 20 | + capitalize: (str: string) => string; |
| 21 | + truncate: (str: string, length?: number) => string; |
| 22 | + debounce: <T extends (...args: any[]) => any>(func: T, wait?: number) => (...args: Parameters<T>) => void; |
| 23 | + throttle: <T extends (...args: any[]) => any>(func: T, limit?: number) => (...args: Parameters<T>) => void; |
| 24 | + formatDate: (date: Date | string) => string; |
| 25 | + smoothScrollTo: (target: string | HTMLElement, offset?: number, duration?: number) => void; |
| 26 | + storageSet: (key: string, value: any) => void; |
| 27 | + storageGet: (key: string) => any; |
| 28 | + storageRemove: (key: string) => void; |
| 29 | +}; |
| 30 | +export default WebUtils; |
0 commit comments