Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
Ermiyas Arage edited this page Sep 16, 2024 · 5 revisions

API reference

Notice: For comprehensive explanations and usage details, please refer to the inline JSDoc comments embedded within the code. This document is intended to provide a concise API reference, focusing on method signatures and listing, rather than in-depth discussions. For a deeper understanding, the JSDoc comments within the code will offer more extensive insights.

Classes and Methods

All Classes

DOM Utilities

Classes

Methods

Obj Class
  • compareObjects(obj1: any, obj2: any): boolean;
  • deepCloneObject(obj: any, cache?: WeakMap<any, any>): any;
  • deepMergeObjects(target: any, source: any): any;
  • deepFreezeObject(obj: any): any;
  • isPlainObject(obj: any): boolean;
  • isObjectEmpty(obj: any): boolean;
  • isObjectEqual(obj1: any, obj2: any): boolean;
  • isObjectSubset(subset: any, superset: any): boolean;
  • objectMap(obj: any, callback: Function): any;
  • objectFilter(obj: any, predicate: Function): any;
  • objectReduce(obj: any, callback: Function, initialValue: any): any;
  • objectForEach(obj: any, callback: Function): void;
  • objectPick(obj: any, keys: any[]): any;
  • objectOmit(obj: any, keys: any[]): any;
  • objectRenameKeys(obj: any, keyMap: any): any;
  • objectFlipKeys(obj: any): any;
  • objectMerge(obj1: any, obj2: any): any;
  • objectZip(keys: any[], values: any[]): any;
  • objectToQueryString(obj: any): string;
String Class
  • isEmptyString(value: string): boolean;
  • trimString(value: string, chars?: string): string;
  • capitalizeString(value: string, separator?: string): string;
  • startsWithString(mainString: string, searchString: string, caseSensitive?: boolean): boolean;
  • endsWithString(mainString: string, searchString: string, caseSensitive?: boolean): boolean;
  • containsString(mainString: string, searchString: string, caseSensitive?: boolean, startIndex?: number): boolean;
  • replaceAllOccurrences(mainString: string, searchString: string, replacement: string, caseSensitive?: boolean): string;
  • formatString(template: string, values: any): string;
  • generateRandomString(length: number, charSet?: string): string;
Attribute Class
  • setElementAttribute(element: HTMLElement, attributeName: string, attributeValue: string): void;
  • removeElementAttribute(element: HTMLElement, attributeName: string): void;
  • getElementAttribute(element: HTMLElement, attributeName: string): string | null;
  • setElementAttributes(element: HTMLElement, attributes: any): void;
  • getAllElementAttributes(element: HTMLElement): any;
  • hasElementAttribute(element: HTMLElement, attributeName: string): boolean;
  • toggleElementAttribute(element: HTMLElement, attributeName: string): void;
  • removeAllElementAttributes(element: HTMLElement): void;
Element Class
  • create(options: { name: string; class?: Array<string>; attr?: { [x: string]: string; }; innerText?: string; innerHTML?: string; children?: Array<HTMLElement>; draggable?: boolean; style?: string; trackMutation?: boolean; }, callback?: Function): HTMLElement;
  • setHTML(element: HTMLElement, htmlContent: string, evaluateScripts?: boolean): void;
  • getHTML(element: HTMLElement): string;
  • setText(element: HTMLElement, textContent: string, options?: { toUpperCase?: boolean; toLowerCase?: boolean; }): void;
  • appendElement(parentElement: HTMLElement, childElement: HTMLElement, recursive?: boolean): void;
  • appendElements(parentElement: HTMLElement, ...childNodes: HTMLElement[]): void;
  • cloneElementWithClasses(sourceElement: HTMLElement, targetElement: HTMLElement): void;
  • wrapElement(element: HTMLElement, wrapperElement: HTMLElement): void;
  • unwrapElement(element: HTMLElement): void;
  • isElementVisible(element: HTMLElement): boolean;
  • isElementHidden(element: HTMLElement): boolean;
  • getClosestElement(element: HTMLElement, selector: string): HTMLElement | null;
  • findParentElement(element: HTMLElement, selector: string): HTMLElement | null;
  • findAncestors(element: HTMLElement, selector: string): Array<HTMLElement>;
  • findDescendants(parentElement: HTMLElement, selector: string): Array<HTMLElement>;
  • closestCommonAncestor(elements: Array<HTMLElement>): HTMLElement | null;
  • removeElementData(element: HTMLElement, key: string): void;
  • clearElementData(element: HTMLElement): void;
  • getDataAttributes(element: HTMLElement): any;
  • generateUniqueId(prefix: string): string;
  • delegateEvent(parentElement: HTMLElement, childSelector: string, eventType: string, handler: Function): void;
  • cloneElement(element: HTMLElement, deepClone?: boolean, cloneListeners?: boolean): HTMLElement;
DragDrop Class
  • setDraggable(draggableElement: HTMLElement, options?: any): void;
  • destroyDraggable(draggableElement: HTMLElement): void;
  • disableDraggable(draggableElement: HTMLElement): void;
  • enableDraggable(draggableElement: HTMLElement): void;
  • createDroppable(droppableElement: HTMLElement, options?: any): void;
  • destroyDroppable(droppableElement: HTMLElement): void;
  • disableDroppable(droppableElement: HTMLElement): void;
  • enableDroppable(droppableElement: HTMLElement): void;
Ripple Class
  • addRippleEffect(element: HTMLElement, options?: { color?: string; duration?: string; size?: number }): void
  • addRippleEffectToMultiple(selector: string, options?: any): void
  • removeRippleEffect(element: HTMLElement): void
  • removeRippleEffectFromMultiple(selector: string): void
RippleEffect Class
  • constructor(element: HTMLElement, options?: { duration: number; eventType: string; createRipple: Function })
  • handleEvent(event: Event): void
  • createDefaultRipple(): HTMLElement
Scroll Class
  • fadeIn(element: HTMLElement, duration: number, callback?: Function): void;
  • fadeOut(element: HTMLElement, duration: number, callback?: Function): void;
  • slideDown(element: HTMLElement, duration: number, callback?: Function): void;
  • slideUp(element: HTMLElement, duration: number, callback?: Function): void;
  • slideToggle(element: HTMLElement, duration: number, callback?: Function): void;
  • toggleClassOnScroll(element: HTMLElement, className: string, offset: number): void;
  • smoothScrollToTop(duration: number): void;
  • animateOpacity; - private
  • animateHeight; - private
  • getFullHeight; - private
  • isElementVisible; - private
  • easeInOutQuad; - private
  • smoothScrollToPosition; - private
  • smoothScrollToElement(element: HTMLElement, duration: number): void;
  • scrollToElement(element: HTMLElement): void;
  • scrollToTop(duration: number): void;
  • scrollToBottom(duration: number): void;
  • scrollToPosition(element: HTMLElement, position: number): void;
  • getScrollPosition(element: HTMLElement): number;
  • disableScroll(): void;
  • enableScroll(): void;
  • getViewportScrollTop(): number;
  • getViewportScrollLeft(): number;
  • getDocumentScrollTop(): number;
  • getDocumentScrollLeft(): number;
Utility Class
  • addClass(element: HTMLElement, className: string, options?: { checkIfExists?: boolean; triggerAnimation?: boolean;}): void;
  • removeClass(element: HTMLElement, className: string, options?: { logChanges?: boolean; preserveState?: boolean;}): void;
  • hasClass(element: HTMLElement, className: string, options?: { delay?: number;}): Promise<boolean>;
  • toggleClass(element: HTMLElement, className: string, options?: { onAdd?: Function; onRemove?: Function;}): void;
  • replaceClass(element: HTMLElement, oldClass: string, newClass: string, options?: { enableUndo?: boolean;}): Function | null;
  • addClasses(element: HTMLElement, classNames: Array<string>, options?: { timeout?: number; checkForDuplicates?: boolean;}): Promise<void>;
  • replaceClasses(element: HTMLElement, classMap: { [x: string]: string; }): void;
  • toggleClassConditionally(element: HTMLElement, condition: boolean, trueClass: string, falseClass: string): void;
  • hasAnyClass(element: HTMLElement, classArray: string[]): boolean;
  • replaceClassPrefix(element: HTMLElement, oldPrefix: string, newPrefix: string): void;
  • addUniqueClass(element: HTMLElement, className: string): void;
  • addClassOnViewportEnter(element: HTMLElement, className: string): void;
  • toggleClassOnFocus(element: HTMLElement, className: string): void;
  • toggleClassOnIdleTime(element: HTMLElement, className: string, idleTime?: number): void;
  • addClassOnInterval(element: any, className: any, interval?: number): void;
  • toggleClassOnDeviceMotion(element: HTMLElement, className: string): void;
  • toggleClassOnOrientationChange(element: HTMLElement, className: string): void;
  • toggleClassOnSwipe(element: HTMLElement, className: string): void;
  • toggleClassOnConnectionStatus(element: HTMLElement, className: string): void;
  • toggleClassOnGeolocationChange(element: HTMLElement, className: string, options?: { enableThrottling?: boolean; throttleInterval?: number; onClassToggle?: Function; onError?: Function; geoOptions?: any; }): () => void;
  • toggleClassOnMediaQueryChange(element: HTMLElement, className: string, mediaQuery: string): void;
  • toggleClassOnCopy(element: HTMLElement, className: string): void;
  • removeClassOnInterval(element: any, className: any, interval?: number): void;
Tooltip Function
  • Tooltip(targetElement: HTMLElement, tooltipContent: string, callback: any): void
Modal Class
  • createModal(options: any): HTMLElement
  • openModal(modalId: string): void
  • closeModal(modalId: string): void
  • destroyModal(modalId: string): void
  • setModalContent(modalId: string, content: string): void
  • getModalContent(modalId: string): string
Color Class
  • rgbToHex(r: number, g: number, b: number): string
  • hexToRgb(hex: string): { r: number; g: number; b: number } | null
  • rgbaToHex(r: number, g: number, b: number, a: number): string
  • hexToRgba(hex: string, a: number): string | null
  • colorBrightness(color: string): number | null
  • colorContrast(color1: string, color2: string): number | null
  • generateRandomColor(): string
  • darkenColor(color: string, percentage: number): string
  • lightenColor(color: string, percentage: number): string
  • calculateLuminance(color: string): number
  • areColorsEqual(color1: string, color2: string): boolean
  • hslToRgb(hue: number, saturation: number, lightness: number): any
  • hueToRgb(p: any, q: any, t: any): any
  • rgbToHsl(red: number, green: number, blue: number): any
  • mixColors(color1: string, color2: string, weight: number): string
  • generateColorGradient(startColor: string, endColor: string, steps: number): any[]
  • invertColor(color: string): string
Style Class
  • addStyles(element: HTMLElement, styles: { [x: string]: string }): void
  • removeStyles(element: HTMLElement, ...properties: string[]): void
  • getAllStyles(element: HTMLElement): { [x: string]: string }
  • hideElement(element: HTMLElement): void
  • showElement(element: HTMLElement): void
  • getComputedStyle(element: HTMLElement, property: string): string
  • getElementDimensions(element: HTMLElement): any
  • copyStyles(sourceElement: HTMLElement, targetElement: HTMLElement): void

Form Utilities

Classes

Methods

FormAction Class
  • generatePassword(length: number, options?: { customCharsets?: string[]; includeSymbols?: boolean; includeNumbers?: boolean; includeUppercase?: boolean; includeLowercase?: boolean; avoidRepeats?: boolean; useCryptoRandom?: boolean; minEntropy?: number; exclude?: string[]; onCharacterSelected?: Function; }): string;
  • encryptText(text: string, key: string): string;
  • decryptText(encryptedText: string, key: string): string;
  • disableForm(formElement: HTMLFormElement): void;
  • enableForm(formElement: HTMLFormElement): void;
  • scrollToError(formElement: HTMLFormElement): void;
  • showErrorMessage(element: HTMLElement, message: string): void;
  • hideErrorMessage(element: HTMLElement): void;
  • resetInput(inputElement: HTMLInputElement): void;
  • disableInput(inputElement: HTMLInputElement): void;
  • enableInput(inputElement: HTMLInputElement): void;
  • toggleInputValidity(inputElement: HTMLInputElement, isValid: boolean): void;
  • highlightInvalidInput(inputElement: HTMLInputElement): void;
SerializeForm Class
  • serializeFormData(formElement: HTMLFormElement): string
  • deserializeFormData(formElement: HTMLFormElement, data: string): void
Validate Class
  • validateEmailAddress(email: string): boolean
  • validatePhoneNumber(phoneNumber: string): boolean
  • validateJWT(userToken: string, secretKey: string): any
  • validatePasswordStrength(password: string): string

Media Utilities

Classes

Methods

Capture Class
  • openCamera(options: { targetElementId: string }): Promise<MediaStream>
  • capturePhoto(options: { targetElementId: string }): Promise<Blob>
  • recordVideo(options: { targetElementId: string; duration: number }): Promise<Blob>
FullScreen Class
  • detectFullscreenSupport(): boolean
  • enterFullscreen(element: Element): void
  • exitFullscreen(): void
  • getFullscreenElement(): Element | null
Image Class
  • resizeImage(file: File, maxWidth: number, maxHeight: number): Promise<Blob>
  • rotateImage(file: File, degrees: number): Promise<Blob>
  • compressImage(file: File, quality: number): Promise<Blob>
  • cropImage(file: File, coordinates: any): Promise<Blob>
  • flipImage(file: File, axis: string): Promise<Blob>
  • convertImageToBase64(file: File): Promise<string>
  • preloadImagesWithCallback(imageUrls: string[], callback: Function): void
  • calculateAspectRatio(width: number, height: number): number
Blob Class
  • convertBase64ToBlob(base64: string, contentType: string, onProgress?: Function): Blob;
  • convertBlobToBase64(blob: Blob, onProgress?: Function): Promise<string>;
  • downloadBlob(blob: Blob, filename: string, fallbackContentType?: string): void;
  • textToBlob(text: string, encoding?: string): Blob;
  • mergeBlobs(blobs: Blob[], contentType?: string, bufferSize?: number): Blob;
  • encryptBlob(blob: Blob, key: CryptoKey): Promise<Blob>;
  • decryptBlob(encryptedBlob: Blob, key: CryptoKey): Promise<Blob>;
  • chunkBlob(blob: Blob, chunkSize: number): Blob[];
  • readBlobAsText(blob: Blob, encoding?: string): Promise<string>;
  • verifyBlob(blob: Blob, { maxSize, allowedTypes }?: { maxSize?: number; allowedTypes?: string[]; }): boolean;
  • blobToHex(blob: Blob): Promise<string>;
File Class
  • validateFileType(file: File, allowedTypes: string[]): boolean;
  • validateFileSize(file: File, maxSize: number): boolean;
  • uploadFile(file: File, url: string, progressCallback: Function): Promise<string>;
  • downloadZip(fileUrl: string, fileName: string): Promise<void>;
  • unzip(zipBlob: Blob): Promise<Array<{ name: string; content: string; }>>;
  • zip(files: Array<{ name: string; content: string; }>, zipFileName: string): Blob;

Device Utilities

Classes

Methods

DetectDevice Class
  • detectBrowser()
  • detectOS()
  • isMobileBrowser()
  • detectMobileDevice()
  • detectTouchDevice()
  • detectDeviceType()
  • detectLanguage()
  • detectTimeZone()
EnvInfo Class
  • getBrowserWindowSize()
  • getScreenResolution()
  • getBatteryStatus(callback: Function)
  • getNetworkStatus(callback: Function)
  • getDeviceOrientation(callback: Function)
  • getDeviceMotion(callback: Function)
  • getMediaDevices(callback: Function)
  • getGeolocation(callback: Function)
DetectFeature Class
  • detectAdBlocker(): boolean;
  • detectWebGLSupport(): boolean;
  • detectWebP(): Promise<boolean>;
  • detectCookiesEnabled(): boolean;
  • detectDoNotTrack(): boolean;
  • detectLocalStorage(): boolean;
  • detectSessionStorage(): boolean;
  • detectWebSockets(): boolean;
  • detectSVGSupport(): boolean;
  • detectInlineSVGSupport(): boolean;
  • detectCanvasSupport(): boolean;
  • detectAudioFormatSupport(): boolean;
  • detectVideoFormatSupport(): boolean;
  • detectSpeechRecognitionAPI(): boolean;
  • detectWebRTC(): boolean;
  • detectRetinaDisplay(): boolean;
  • detectFullscreenAPI(): boolean;
  • detectOrientationAPI(): boolean;
  • detectGamepadAPI(): boolean;
  • detectFileSystemAPI(): boolean;
  • detectPointerLockAPI(): boolean;
  • detectMediaSourceExtensions(): boolean;
  • detectPictureInPictureAPI(): boolean;
  • detectWebPImageSupport(): boolean;
  • detectPageVisibilityAPI(): boolean;
  • detectAudioContextAPI(): boolean;
  • detectWebGL2API(): boolean;
  • detectGamepadHapticAPI(): boolean;
DeviceAPIs Class
  • requestBluetoothDevice(filters?: object): Promise<BluetoothDevice>;
  • requestUSBDevice(): Promise<USBDevice>;
  • getWiFiStatus(): Promise<string>;
  • synthesizeSpeech(text: string, options?: object): void;
  • isClipboardSupported(): boolean;
  • writeToClipboard(text: string): Promise<void>;
  • readFromClipboard(): Promise<string>;
BrowserStorage Class
  • setLocal(key: string, value: string, expiresIn?: number): void;
  • getLocal(key: string): string | null;
  • setSession(key: string, value: string, expiresIn?: number): void;
  • getSession(key: string): string | null;
  • isLocalKeyExists(key: string): boolean;
  • isSessionKeyExists(key: string): boolean;
  • getAllLocalKeys(): Array<string>;
  • getAllSessionKeys(): Array<string>;
  • getAllLocalValues(): Array<string>;
  • getAllSessionValues(): Array<string>;
  • getAllLocalItems(): any;
  • getAllSessionItems(): any;
  • syncLocalStorage(data: any, merge?: boolean): void;
  • syncSessionStorage(data: any, merge?: boolean): void;
  • batchProcessLocalStorage(callback: Function): void;
  • batchProcessSessionStorage(callback: Function): void;
DeviceStorage Class
  • getTotalStorageCapacity(): Promise<{ bytes: number; humanReadable: string; }>;
  • getUsedStorageSpace(): Promise<{ bytes: number; humanReadable: string; }>;
  • getAvailableStorageSpace(): Promise<{ bytes: number; humanReadable: string; }>;
  • hasEnoughFreeSpace(requiredSpace: number): Promise<{ hasEnough: boolean; availableSpace: { bytes: number; humanReadable: string; }; }>;
  • getStorageType(): Promise<string>;
  • requestPersistentStorage(): Promise<boolean>;
  • getDefaultPersistentStorageQuota(): Promise<{ quota: number; humanReadable: string; }>;
  • bytesToHumanReadable(bytes: number): string;

Network Utilities

Classes

Methods

URLUtility Class
  • parseQueryStringParameters(queryString: string, decode?: boolean): object;
  • replaceQueryStringParameter(url: string, key: string, value: string, encode?: boolean): string;
  • removeQueryStringParameter(url: string, key: string): string;
  • mergeURL(baseURL: string, relativeURL: string): string;
  • normalizeURL(url: string): string;
  • extractFragment(url: string): string;
  • constructURL(base: string, path?: string, queryParams?: object): string;
RequestServer Class
  • ajax(options: { method: string; url: string; headers?: any; data?: string | FormData; success?: Function; error?: Function }): void
  • get(url: string, data: any, callback: Function): void
  • post(url: string, data: any, callback: Function): void
  • put(url: string, data: any, callback: Function): void
  • patch(url: string, data: any, callback: Function): void
  • deleteRequest(url: string, data: any, callback: Function): void
  • jsonp(url: string, callback: Function): void
  • fetchJson(url: string, options: any): void
IP Class
  • validateIPv4Address(ip: string): boolean
  • validateIPv6Address(ip: string): boolean
  • convertIPv4ToIPv6(ip: string): string
  • convertIPv6ToIPv4(ip: string): string | null
  • normalizeIPv6(ip: string): string | null
  • getIPVersion(ip: string): 4 | 6 | null
  • isPrivateIP(ip: string): boolean
  • getUserIPAddress(req: Request): string | null
  • generateRandomIPv4(): string
  • generateRandomIPv6(): string
  • isValidSubnetMask(mask: string): boolean
  • extractFromCIDR(cidr: string): { ip: string, mask: string } | null
  • calculateNetworkAddress(ip: string, mask: string): string | null
  • areIPsInSameNetwork(ip1: string, ip2: string, mask: string): boolean
  • getLocationByIP(ip: string, callback: Function)
ServiceWorkerManager Class
  • registerServiceWorker(url: string, options?: object): Promise<ServiceWorkerRegistration>;
  • unregisterServiceWorker(scope: string): Promise<boolean>;
  • isServiceWorkerActive(scope: string): Promise<boolean>;
  • postMessageToServiceWorkers(scope: string, message: object): Promise<void>;
  • updateServiceWorkers(scope: string): Promise<void>;
  • getServiceWorkerStates(): Promise<Array<object>>;