All Functions
Overview
This document provides a comprehensive list of all available functions in the dphelper
library along with their descriptions.
Functions
Anchor
dphelper.anchor.toOnClick(el: string): void
Description: Converts an element's href attribute to an onclick event.
Array
dphelper.array.find(array: any[], key: any): any
Description: Finds an element in an array by key.dphelper.array.unique(array: any[]): any[]
Description: Returns an array with unique elements.dphelper.array.delete(array: any[], key: any): void
Description: Deletes an element from an array by key.dphelper.array.merge(arrayA: any[], arrayB: any[]): any[]
Description: Merges two arrays.dphelper.array.mergeByKey(arrayA: any[], arrayB: any[], key: string): any[]
Description: Merges two arrays by a specific key.dphelper.array.asc(array: any[]): any[]
Description: Sorts an array in ascending order.dphelper.array.desc(array: any[]): any[]
Description: Sorts an array in descending order.dphelper.array.duplicates(array: any[]): any[]
Description: Returns an array of duplicate elements.dphelper.array.even(array: any[]): any[]
Description: Returns an array of even numbers.dphelper.array.odd(array: any[]): any[]
Description: Returns an array of odd numbers.dphelper.array.toObj(array: any[]): object
Description: Converts an array to an object.dphelper.array.sumColumn(array: any[], column: number): number
Description: Sums the values of a specific column in an array.dphelper.array.shuffle(array: any[]): any[]
Description: Shuffles the elements of an array.dphelper.array.generate(num: number): any[]
Description: Generates an array with a specified number of elements.dphelper.array.testArrayInt(array: any[]): number[]
Description: Tests if the elements of an array are integers.dphelper.array.rand32(number: number): any
Description: Generates a random 32-bit number.dphelper.array.findindex(array: any[], key: any): number
Description: Finds the index of an element in an array by key.dphelper.array.pathToJson(array: any[], separator?: string): object
Description: Converts an array to a JSON object using a separator.deepClone(src: any): any
Description: Creates a deep clone of an object.dphelper.array.match(arrayWords: any[], arrayToCheck: any[]): boolean
Description: Checks if two arrays match.dphelper.array.shallow(array: any[]): any[]
Description: Generate a shallow copy of an object.dphelper.array.deeCopy(array: any[]): any[]
Description: Generate a structured copy of an object.
Audio
dphelper.audio.play(url: string): void
Description: Plays an audio file from a URL.
Avoid
dphelper.avoid.cache(uri: string): string
Description: Caches a URI.
Browser
dphelper.browser.state(state: any, title: any, url: any): void
Description: Changes the browser state.dphelper.browser.forw(times: number): void
Description: Moves forward in the browser history.dphelper.browser.back(times: number): void
Description: Moves backward in the browser history.dphelper.browser.reload(): void
Description: Reloads the current page.dphelper.browser.href(url: string): void
Description: Navigates to a URL.dphelper.browser.offLine(text?: string): void
Description: Displays an offline message.dphelper.browser.zoom(): number
Description: Gets the current zoom level.dphelper.browser.status(code: number): string
Description: Gets the status text for a status code.
Check
dphelper.check.url(url: string): any
Description: Checks if a URL is valid.dphelper.check.version(v1: string, v2: string, opts: any): any
Description: Compares two version strings.dphelper.check.npmVer(npm: string): any
Description: Gets the version of an npm package.
Color
dphelper.color.hex(c: any): string
Description: Converts a color to hex format.dphelper.color.toHex(rgb: any): string
Description: Converts RGB to hex format.dphelper.color.toRGB(c: any): Array
Description: Converts a color to RGB format.dphelper.color.oleColor(c: any): string
Description: Converts a color to OLE format.dphelper.color.gradient(colorStart: any, colorEnd: any, colorCount: any): any
Description: Generates a gradient between two colors.
Console
dphelper.console.info(name: string, message: string, fn: Function): void
Description: Logs an info message to the console.dphelper.console.stop(options?: string[]): void
Description: Stops the console.dphelper.console.toHtml(el: string): void
Description: Converts console output to HTML.
Cookie
dphelper.cookie.set(pars: { name: any, value: any, time?: any, path?: "/", sameSite?: "Lax", secure?: "Secure" | "false" }): any
Description: Sets a cookie.dphelper.cookie.get(name: string): any
Description: Gets a cookie by name.dphelper.cookie.delete(name: string): any
Description: Deletes a cookie by name.dphelper.cookie.clearAll(): any
Description: Clears all cookies.
Coords
dphelper.coods.degreesToRadians(degrees: any): any
Description: Converts degrees to radians.dphelper.coods.latToMeters(points: any): any
Description: Converts latitude to meters.dphelper.coods.toVector(points: any): any
Description: Converts points to a vector.dphelper.coods.convertToDecDegrees(deg: any, minutes: any, sec: any, direction: any): any
Description: Converts coordinates to decimal degrees.dphelper.coods.distance(point1: any, point2: any): any
Description: Calculates the distance between two points.dphelper.coods.polarToCartesian(centerX: any, centerY: any, radius: any, angleInDegrees: any): any
Description: Converts polar coordinates to Cartesian coordinates.dphelper.coods.mapDegreesToPixels(degree: number, minDegree: number, maxDegree: number, minPixel: number, maxPixel: number, padding: number): number
Description: Maps degrees to pixels.
Date
dphelper.date.days(lang?: string): string[]
Description: Returns the days of the week in a specified language.dphelper.date.months(lang?: string): string[]
Description: Returns the months of the year in a specified language.dphelper.date.year(): number
Description: Returns the current year.dphelper.date.toIso(value: any, int?: string): string | null
Description: Converts a date to ISO format.dphelper.date.toMMDDYYYY(value: any): string
Description: Converts a date to MM/DD/YYYY format.dphelper.date.toYYYYMMDD(value: any): string | undefined
Description: Converts a date to YYYY/MM/DD format.dphelper.date.toHuman(value: any): string
Description: Converts a date to a human-readable format.dphelper.date.convert(value: any, format: string[]): string | null
Description: Converts a date to a specified format.dphelper.date.iso2Epoch(value: any): number
Description: Converts an ISO date to epoch time.dphelper.date.localIsoTime(value: any): string
Description: Converts a date to local ISO time.dphelper.date.utc(): string
Description: Returns the current UTC time.dphelper.date.parse(value: any, separator?: string): string | null
Description: Parses a date string.dphelper.date.addDays(date: any, days: number): Date
Description: Adds days to a date.dphelper.date.dateTimeToString(dateObject: any): string
Description: Converts a date object to a string.dphelper.date.isoToHuman(value: any, symbol?: string): string | null
Description: Converts an ISO date to a human-readable format.dphelper.date.fullDate(): string
Description: Returns the full date.dphelper.date.epoch(): number
Description: Returns the current epoch time.dphelper.date.diffInDays(d1: any, d2: any): number
Description: Calculates the difference in days between two dates.dphelper.date.diffInWeeks(d1: any, d2: any): number
Description: Calculates the difference in weeks between two dates.dphelper.date.diffInMonths(d1: any, d2: any): number
Description: Calculates the difference in months between two dates.dphelper.date.diffInYears(d1: any, d2: any): number
Description: Calculates the difference in years between two dates.dphelper.date.dateToYMD(date: any): string
Description: Converts a date to YYYY-MM-DD format.dphelper.date.collection(params: { date?: Date; type: string; locale?: string }): string | undefined
Description: Returns a collection of dates.dphelper.date.timeZones(): string[]
Description: Returns a list of time zones.
Disable
dphelper.disable.select(el?: string): void
Description: Disables text selection.dphelper.disable.spellCheck(tmr?: number): void
Description: Disables spell check.dphelper.disable.rightClick(el?: string): void
Description: Disables right-click.dphelper.disable.copy(el?: string): void
Description: Disables copy.dphelper.disable.paste(el?: string): void
Description: Disables paste.dphelper.disable.cut(el?: string): void
Description: Disables cut.dphelper.disable.drag(el?: string): void
Description: Disables drag.
Dispatch
dphelper.dispatch.set(name: string, value?: any): void
Description: Sets a dispatch event.dphelper.dispatch.listen(name: string, cb?: (e: Event) => void, flag?: boolean): void
Description: Listens for a dispatch event.dphelper.dispatch.remove(name: string): void
Description: Removes a dispatch event.
Element
dphelper.element.fitScale(el: any, scale?: number, fit?: boolean): void
Description: Fits an element to a scale.dphelper.element.scaleBasedOnWindow(elm: any, scale: number, fit: boolean): void
Description: Scales an element based on the window size.
Events
dphelper.events.list(el: Element): any
Description: Lists all events on an element.dphelper.events.multi(element: Element, eventNames: string, listener: EventListener): void
Description: Adds multiple event listeners to an element.dphelper.events.copy(el: string): void
Description: Copies an element.dphelper.events.onDrag(elem: string): void
Description: Adds a drag event to an element.dphelper.events.keys(e: KeyboardEvent): { key: string; ctrl: boolean; alt: boolean; shift: boolean }
Description: Gets the key, ctrl, alt, and shift status from a keyboard event.
Form
dphelper.form.serialize(form: HTMLFormElement): { [key: string]: any }
Description: Serializes a form to an object.dphelper.form.confirmType(type: string, value: any): boolean
Description: Confirms the type of a value.dphelper.form.required(value: any): string | undefined
Description: Checks if a value is required.dphelper.form.minLength(value: any, num?: number): string | undefined
Description: Checks if a value meets the minimum length.dphelper.form.maxLength(value: any, num?: number): string | undefined
Description: Checks if a value exceeds the maximum length.dphelper.form.maxPhoneNumber(value: any, num?: number): string | undefined
Description: Checks if a phone number exceeds the maximum length.dphelper.form.isNumeric(value: any): boolean
Description: Checks if a value is numeric.dphelper.form.isEmail(value: any): boolean
Description: Checks if a value is an email.dphelper.form.pattern(e: Event): void
Description: Validates a pattern.dphelper.form.noSpecialChars(e: Event): void
Description: Disallows special characters.dphelper.form.table(size: [number, number], id: string, elem: HTMLElement): void
Description: Creates a table.dphelper.form.sanitize(str: string): string | undefined
Description: Sanitizes a string.
Format
dphelper.format.currency(value: number, locale?: string, currency?: string): string
Description: Formats a value as currency.dphelper.format.phoneNumber(value: string, countryCode?: string): string
Description: Formats a phone number.
Imports
dphelper.imports.file(elem: string, file: string): Promise<void>
Description: Imports a file.
Json
dphelper.json.counter(json: any, key?: string, val?: any): number | null
Description: Counts occurrences in a JSON object.dphelper.json.toCsv(jsonInput: any): string
Description: Converts JSON to CSV.dphelper.json.saveCsvAs(csvData: string, fileName: string): void
Description: Saves CSV data as a file.dphelper.json.is(str: string): boolean
Description: Checks if a string is valid JSON.dphelper.json.parse(file: string): any
Description: Parses a JSON file.dphelper.json.sanitize(str: string): string
Description: Sanitizes a JSON string.dphelper.json.sanitizeJsonValue(str: string): string
Description: Sanitizes a JSON value.
Load
dphelper.load.all(context: __WebpackModuleApi.RequireContext, cacheName?: string): void
Description: Loads all modules in a context.dphelper.load.file(filePath: string): Promise<string>
Description: Loads a file.dphelper.load.fileToElement(elementSelector: string, filePath: string): Promise<void>
Description: Loads a file into an element.dphelper.load.json(filePath: string): Promise<any>
Description: Loads a JSON file.dphelper.load.remote(path: string, method?: string, headers?: HeadersInit): Promise<any>
Description: Loads data from a remote URL.dphelper.load.script(scripts: string[], elementSelector?: string): void
Description: Loads scripts.dphelper.load.toJson(context: __WebpackModuleApi.RequireContext, cacheName?: string): void
Description: Converts a context to JSON.
Logging
dphelper.logging.list: { type: string; message: string }
Description: List of log messages.dphelper.logging.reg(txt: string): void
Description: Logs a regular message.dphelper.logging.debug(txt: string): void
Description: Logs a debug message.dphelper.logging.error(txt: string): void
Description: Logs an error message.
Math
dphelper.math.rnd(): number
Description: Generates a random number.dphelper.math.tmr(): number
Description: Returns the current time in milliseconds.dphelper.math.add(a: number, b: number): number
Description: Adds two numbers.dphelper.math.sub(a: number, b: number): number
Description: Subtracts two numbers.dphelper.math.multi(a: number, b: number): number
Description: Multiplies two numbers.dphelper.math.div(a: number, b: number): number
Description: Divides two numbers.dphelper.math.rem(a: number, b: number): number
Description: Returns the remainder of two numbers.dphelper.math.exp(a: number, b: number): number
Description: Returns the exponent of two numbers.dphelper.math.isOdd(a: number): boolean
Description: Checks if a number is odd.dphelper.math.float2int(a: number): number
Description: Converts a float to an integer.dphelper.math.percent(n: number, tot: number): number
Description: Calculates the percentage.dphelper.math.isPrime(n: number): boolean
Description: Checks if a number is prime.
Memory
dphelper.memory.lock(obj: string): void
Description: Locks an object in memory.dphelper.memory.unlock(obj: string): void
Description: Unlocks an object in memory.
Object
dphelper.obj.toArray(object: Record<string, any>): [string, any][]
Description: Converts an object to an array.dphelper.obj.replaceNullObjects(data: Record<string, any>): Record<string, any>
Description: Replaces null objects in a record.dphelper.obj.serialize(value: any): any
Description: Serializes a value.dphelper.obj.deSerialize(valueNew: any): any
Description: Deserializes a value.dphelper.obj.sort(o: Record<string, any>): Record<string, any>
Description: Sorts an object.dphelper.obj.toXML(obj: Record<string, any>): string
Description: Converts an object to XML.dphelper.obj.find(object: any[], key: string, value: any): any
Description: Finds an element in an object by key and value.dphelper.obj.instance(obj: any): any
Description: Returns the instance of an object.dphelper.obj.updateByKey(obj: Record<string, any>, key: string, newValue: any): Record<string, any>
Description: Updates an object by key.dphelper.obj.findindex(object: any[], key: string): number
Description: Finds the index of an element in an object by key.dphelper.obj.parse(val: any): any
Description: Parses a value.dphelper.obj.isObject(val: any): boolean
Description: Checks if a value is an object.dphelper.obj.diff(obj1: Record<string, any>, obj2: Record<string, any>): Record<string, { obj1: any, obj2: any }>
Description: Finds the difference between two objects.dphelper.obj.path(prop: string, object: string[], separator?: string): string
Description: Converts a property path to a string.dphelper.obj.shallow(object: Object): Object
Description: Generate a shallow copy of an object.dphelper.obj.deeCopy(object: Object): Object
Description: Generate a structured copy of an object.
Path
dphelper.path.rail(): string[]
Description: Returns the rail path.dphelper.path.hash(): string[]
Description: Returns the hash path.dphelper.path.query(url: string): Record<string, string>
Description: Parses the query string of a URL.
Promise
dphelper.promise.check(p: any): boolean
Description: Checks if a value is a promise.dphelper.promise.resolve(data: any): Promise<any>
Description: Resolves a promise with data.
Sanitize
dphelper.sanitize.html(s: string): string
Description: Sanitizes HTML.
Screen
dphelper.screen.fullScreen(el: string): void
Description: Enables full screen mode for an element.dphelper.screen.toggle(el: string): void
Description: Toggles full screen mode for an element.dphelper.screen.info(): { width: number; height: number; availWidth: number; availHeight: number; colorDepth: number; pixelDepth: number }
Description: Gets screen information.
Scrollbar
dphelper.scrollbar.custom(el: string, options: any): void
Description: Customizes a scrollbar.dphelper.scrollbar.indicator(props: any): void
Description: Adds a scrollbar indicator.dphelper.scrollbar.position: { get(el: any): void; set(el: any): void }
Description: Gets and sets scrollbar position.dphelper.scrollbar.smooth(target: any, speed: any, smooth: any): void
Description: Smooth scrolls to a target.dphelper.scrollbar.scrollTo(container: string, element: string, gap?: number): void
Description: Scrolls to an element within a container.
Security
dphelper.security.uuid: { byVal(string: string): string; v4: string; v5: string }
Description: Generates UUIDs.dphelper.security.hashPass(u: string, p: string, t?: string): Promise<string>
Description: Hashes a password.dphelper.security.crypt(u: string, p: string, mode?: string): string
Description: Encrypts data.dphelper.security.deCrypt(u: string, p: string, mode?: string): string
Description: Decrypts data.dphelper.security.AES_KeyGen(passKey?: string): string
Description: Generates an AES key.dphelper.security.SHA256_Hex(passKey: string): string
Description: Generates a SHA256 hash.dphelper.security.ulid(): string
Description: Generates ULID (Universally Unique Lexicographically Sortable Identifier).
Shortcut
dphelper.shortcut.keys(e: any, trigger: any): void
Description: Adds a keyboard shortcut.
Socket
dphelper.socket.info(): string
Description: Gets socket information.dphelper.socket.start(element: any, server: any): void
Description: Starts a socket connection.dphelper.socket.conn(id: any, server: any): [WebSocket, any]
Description: Connects to a socket server.dphelper.socket.connect(server: any): void
Description: Connects to a server.dphelper.socket.open(id: any, server: any): void
Description: Opens a socket connection.dphelper.socket.send(mex: any, type?: string): void
Description: Sends a message through a socket.dphelper.socket.ping(): void
Description: Sends a ping through a socket.dphelper.socket.receive(el?: any): void
Description: Receives a message through a socket.dphelper.socket.keepAlive(): void
Description: Keeps a socket connection alive.dphelper.socket.check(): void
Description: Checks the status of a socket connection.dphelper.socket.list(): WebSocket[]
Description: Lists all socket connections.
SVG
dphelper.svg.init(container: HTMLElement, source1: [HTMLElement, string], source2: [HTMLElement, string], cb?: Function): void
Description: Initializes an SVG container.dphelper.svg.check(): boolean
Description: Checks if SVG is supported.dphelper.svg.update(rect1: HTMLElement, rect2: HTMLElement, cxn: HTMLElement): void
Description: Updates an SVG element.dphelper.svg.getCurve(p1: [number, number], p2: [number, number], dx: number): string
Description: Gets a curve path between two points.dphelper.svg.getIntersection(dx: number, dy: number, cx: number, cy: number, w: number, h: number): [number, number]
Description: Gets the intersection point of a curve.dphelper.svg.setConnector(source: HTMLElement, side: string): HTMLElement
Description: Sets a connector for an SVG element.dphelper.svg.removeConnection(container: HTMLElement): void
Description: Removes a connection from an SVG container.dphelper.svg.makeScrollable(svgContainer: HTMLElement, scrollContainer: HTMLElement, elm1: HTMLElement, elm2: HTMLElement, rect1: HTMLElement, rect2: HTMLElement): void
Description: Makes an SVG container scrollable.dphelper.svg.makeDraggable(evt: Event): void
Description: Makes an SVG element draggable.dphelper.svg.toggle(evt: Event, container: HTMLElement, source1: HTMLElement, source2: HTMLElement): void
Description: Toggles an SVG element.dphelper.svg.convert(options: ConvertOptions): string | void
Description: Converts an SVG element.
System
dphelper.svg.multiSplit(): any
Description: Splits a string into multiple parts.
Terminal
dphelper.terminal(): Terminal
Description: Initializes a terminal.
Text
dphelper.text.trim(s: string, c: string, b: number, e: number): string
Description: Trims a string.dphelper.text.capitalize(txt: string): string
Description: Capitalizes a string.dphelper.text.lower(txt: string): string
Description: Converts a string to lowercase.dphelper.text.upper(txt: string): string
Description: Converts a string to uppercase.dphelper.text.nl2br(str: string): string
Description: Converts newlines to tags.dphelper.text.sanitize(str: string): string
Description: Sanitizes a string.dphelper.text.camelCase: { toSpace(string: string): string; toUnderscore(string: string): string }
Description: Converts camelCase to space or underscore.dphelper.text.fitContainer(el: string): void
Description: Fits a text element to its container.
Timer
dphelper.timer.sleep(ms: number): Promise<void>
Description: Pauses execution for a specified time.dphelper.timer.percentage(start: string, end: string): string
Description: Calculates the percentage of time elapsed.
Tools
dphelper.tools.getip(): Promise<void>
Description: Gets the IP address.dphelper.tools.byteSize(bytes: number): string
Description: Converts bytes to a human-readable format.dphelper.tools.zIndex(): number
Description: Gets the z-index.dphelper.tools.zeroToFalse(value: number): boolean | number
Description: Converts zero to false.
Translators
dphelper.translator.convertMatrixToScale(values: any): number
Description: Converts a matrix to a scale.
Trigger
dphelper.trigger.click(elem: string): void
Description: Triggers a click event.dphelper.trigger.change(elem: string): void
Description: Triggers a change event.dphelper.trigger.input(elem: string): void
Description: Triggers an input event.
Type
dphelper.type.of(p: any): string
Description: Gets the type of a value.dphelper.type.instOfObj(p: any): boolean
Description: Checks if a value is an instance of an object.dphelper.type.isNull(p: any): (i: any) => boolean
Description: Checks if a value is null.dphelper.type.isBool(val: any): boolean
Description: Checks if a value is a boolean.
UI
dphelper.ui: null
Description: User interface operations.
Window
dphelper.window.enhancement(): void
Description: Enhances the window.dphelper.window.animationframe(): any
Description: Gets the animation frame.dphelper.window.center(params: { url: string; title: string; name: string; w: number; h: number }): void
Description: Centers a window.dphelper.window.onBeforeUnLoad(e: any): void
Description: Handles the before unload event.dphelper.window.purge(d?: Document, time?: number): void
Description: Purges the document.dphelper.window.stopZoomWheel(e: any): void
Description: Stops the zoom wheel.dphelper.window.setZoom(element?: string, zoom?: number): string
Description: Sets the zoom level.dphelper.window.getZoom(element?: string): number
Description: Gets the zoom level.
License
This project is licensed under the MIT License.
Last updated