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) Converts an element's href attribute to an onclick event.

Array

  • dphelper.array.find(array, key) Finds an element in an array by key.

  • dphelper.array.unique(array) Returns an array with unique elements.

  • dphelper.array.delete(array, key) Deletes an element from an array by key.

  • dphelper.array.merge(arrayA, arrayB) Merges two arrays.

  • dphelper.array.mergeByKey(arrayA, arrayB, key) Merges two arrays by a specific key.

  • dphelper.array.asc(array) Sorts an array in ascending order.

  • dphelper.array.desc(array) Sorts an array in descending order.

  • dphelper.array.duplicates(array) Returns an array of duplicate elements.

  • dphelper.array.even(array) Returns an array of even numbers.

  • dphelper.array.odd(array) Returns an array of odd numbers.

  • dphelper.array.toObj(array) Converts an array to an object.

  • dphelper.array.sumColumn(array, column) Sums the values of a specific column in an array.

  • dphelper.array.shuffle(array) Shuffles the elements of an array.

  • dphelper.array.generate(num) Generates an array with a specified number of elements.

  • dphelper.array.testArrayInt(array) Tests if the elements of an array are integers.

  • dphelper.array.rand32(number) Generates a random 32-bit number.

  • dphelper.array.findindex(array, key) Finds the index of an element in an array by key.

  • dphelper.array.pathToJson(array, separator?) Converts an array to a JSON object using a separator.

  • deepClone(src) Creates a deep clone of an object.

  • dphelper.array.match(arrayWords, arrayToCheck) Checks if two arrays match.

  • dphelper.array.shallow(array) Generate a shallow copy of an object.

  • dphelper.array.deeCopy(array) Generate a structured copy of an object.

  • dphelper.array.groupBy(array, key) Generate a structured copy of an object.

Audio

  • dphelper.audio.play(url) Plays an audio file from a URL.

Avoid

  • dphelper.avoid.cache(uri) Caches a URI.

Browser

  • dphelper.browser.state(state, title, url) Changes the browser state.

  • dphelper.browser.forw(times) Moves forward in the browser history.

  • dphelper.browser.back(times) Moves backward in the browser history.

  • dphelper.browser.reload() Reloads the current page.

  • dphelper.browser.href(url) Navigates to a URL.

  • dphelper.browser.offLine(text?) Displays an offline message.

  • dphelper.browser.zoom() Gets the current zoom level.

  • dphelper.browser.status(code) Gets the status text for a status code.

Check

  • dphelper.check.url(url) Checks if a URL is valid.

  • dphelper.check.version(v1, v2, opts) Compares two version strings.

  • dphelper.check.npmVer(npm) Gets the version of an npm package.

Color

  • dphelper.color.hex(c) Converts a color to hex format.

  • dphelper.color.toHex(rgb) Converts RGB to hex format.

  • dphelper.color.toRGB(c) Converts a color to RGB format.

  • dphelper.color.oleColor(c) Converts a color to OLE format.

  • dphelper.color.gradient(colorStart, colorEnd, colorCount) Generates a gradient between two colors.

Console

  • dphelper.console.info(name, message, fn) Logs an info message to the console.

  • dphelper.console.stop(options?[]) Stops the console.

  • dphelper.console.toHtml(el) Converts console output to HTML.

  • dphelper.cookie.set(params: { name, value, time?, path?: "/", sameSite?: "Lax", secure?: "Secure" | "false" }) Sets a cookie.

  • dphelper.cookie.get(name) Gets a cookie by name.

  • dphelper.cookie.delete(name) Deletes a cookie by name.

  • dphelper.cookie.removeAll() Clears all cookies.

Coords

  • dphelper.coods.degreesToRadians(degrees) Converts degrees to radians.

  • dphelper.coods.latToMeters(points) Converts latitude to meters.

  • dphelper.coods.toVector(points) Converts points to a vector.

  • dphelper.coods.convertToDecDegrees(deg, minutes, sec, direction) Converts coordinates to decimal degrees.

  • dphelper.coods.distance(point1, point2) Calculates the distance between two points.

  • dphelper.coods.polarToCartesian(centerX, centerY, radius, angleInDegrees) Converts polar coordinates to Cartesian coordinates.

  • dphelper.coods.mapDegreesToPixels(degree, minDegree, maxDegree, minPixel, maxPixel, padding) Maps degrees to pixels.

Date

  • dphelper.date.days(lang?) Returns the days of the week in a specified language.

  • dphelper.date.months(lang?) Returns the months of the year in a specified language.

  • dphelper.date.year() Returns the current year.

  • dphelper.date.toIso(value, int?) Converts a date to ISO format.

  • dphelper.date.toMMDDYYYY(value) Converts a date to MM/DD/YYYY format.

  • dphelper.date.toYYYYMMDD(value) Converts a date to YYYY/MM/DD format.

  • dphelper.date.toHuman(value) Converts a date to a human-readable format.

  • dphelper.date.convert(value, format[]) Converts a date to a specified format.

  • dphelper.date.iso2Epoch(value) Converts an ISO date to epoch time.

  • dphelper.date.localIsoTime(value) Converts a date to local ISO time.

  • dphelper.date.utc() Returns the current UTC time.

  • dphelper.date.parse(value, separator?) Parses a date string.

  • dphelper.date.addDays(date, days) Adds days to a date.

  • dphelper.date.dateTimeToString(dateObject) Converts a date object to a string.

  • dphelper.date.isoToHuman(value, symbol?) Converts an ISO date to a human-readable format.

  • dphelper.date.fullDate() Returns the full date.

  • dphelper.date.epoch() Returns the current epoch time.

  • dphelper.date.diffInDays(d1, d2) Calculates the difference in days between two dates.

  • dphelper.date.diffInWeeks(d1, d2) Calculates the difference in weeks between two dates.

  • dphelper.date.diffInMonths(d1, d2) Calculates the difference in months between two dates.

  • dphelper.date.diffInYears(d1, d2) Calculates the difference in years between two dates.

  • dphelper.date.dateToYMD(date) Converts a date to YYYY-MM-DD format.

  • dphelper.date.collection(params: { date?; type; locale? }) Returns a collection of dates.

  • dphelper.date.timeZones() Returns a list of time zones.

Disable

  • dphelper.disable.select(el?) Disables text selection.

  • dphelper.disable.spellCheck(tmr?) Disables spell check.

  • dphelper.disable.rightClick(el?) Disables right-click.

  • dphelper.disable.copy(el?) Disables copy.

  • dphelper.disable.paste(el?) Disables paste.

  • dphelper.disable.cut(el?) Disables cut.

  • dphelper.disable.drag(el?) Disables drag.

Dispatch

  • dphelper.dispatch.set(name, value?) Sets a dispatch event.

  • dphelper.dispatch.listen(name, cb?, flag?) Listens for a dispatch event.

  • dphelper.dispatch.remove(name) Removes a dispatch event.

Element

  • dphelper.element.fitScale(el, scale?, fit?) Fits an element to a scale.

  • dphelper.element.scaleBasedOnWindow(elm, scale, fit) Scales an element based on the window size.

Events

  • dphelper.events.list(el) Lists all events on an element.

  • dphelper.events.multi(element, eventNames, listenerListener) Adds multiple event listeners to an element.

  • dphelper.events.copy(el) Copies an element.

  • dphelper.events.onDrag(elem) Adds a drag event to an element.

  • dphelper.events.keys(e): { key; ctrl; alt; shift } Gets the key, ctrl, alt, and shift status from a keyboard event.

Form

  • dphelper.form.serialize(form): { [key] } Serializes a form to an object.

  • dphelper.form.confirmType(type, value) Confirms the type of a value.

  • dphelper.form.required(value) Checks if a value is required.

  • dphelper.form.minLength(value, num?) Checks if a value meets the minimum length.

  • dphelper.form.maxLength(value, num?) Checks if a value exceeds the maximum length.

  • dphelper.form.maxPhoneNumber(value, num?) Checks if a phone number exceeds the maximum length.

  • dphelper.form.isNumeric(value) Checks if a value is numeric.

  • dphelper.form.isEmail(value) Checks if a value is an email.

  • dphelper.form.pattern(e) Validates a pattern.

  • dphelper.form.noSpecialChars(e) Disallows special characters.

  • dphelper.form.table(size, id, elem) Creates a table.

  • dphelper.form.sanitize(str) Sanitizes a string.

Format

  • dphelper.format.currency(value, locale?, currency?) Formats a value as currency.

  • dphelper.format.phoneNumber(value, countryCode?) Formats a phone number.

Imports

  • dphelper.imports.file(elem, file) Imports a file.

Json

  • dphelper.json.counter(json, key?, val?) Counts occurrences in a JSON object.

  • dphelper.json.toCsv(jsonInput) Converts JSON to CSV.

  • dphelper.json.saveCsvAs(csvData, fileName) Saves CSV data as a file.

  • dphelper.json.is(str) Checks if a string is valid JSON.

  • dphelper.json.parse(file) Parses a JSON file.

  • dphelper.json.sanitize(str) Sanitizes a JSON string.

  • dphelper.json.sanitizeJsonValue(str) Sanitizes a JSON value.

Load

  • dphelper.load.all(context, cacheName?) Loads all modules in a context.

  • dphelper.load.file(filePath) Loads a file.

  • dphelper.load.fileToElement(elementSelector, filePath) Loads a file into an element.

  • dphelper.load.json(filePath) Loads a JSON file.

  • dphelper.load.remote(path, method?, headers?) Loads data from a remote URL.

  • dphelper.load.script(scripts[], elementSelector?) Loads scripts.

  • dphelper.load.toJson(context, cacheName?) Converts a context to JSON.

Logging

  • dphelper.logging.list: { type; message } List of log messages.

  • dphelper.logging.reg(txt) Logs a regular message.

  • dphelper.logging.debug(txt) Logs a debug message.

  • dphelper.logging.error(txt) Logs an error message.

Math

  • dphelper.math.rnd() Generates a random number.

  • dphelper.math.tmr() Returns the current time in milliseconds.

  • dphelper.math.add(a, b) Adds two numbers.

  • dphelper.math.sub(a, b) Subtracts two numbers.

  • dphelper.math.multi(a, b) Multiplies two numbers.

  • dphelper.math.div(a, b) Divides two numbers.

  • dphelper.math.rem(a, b) Returns the remainder of two numbers.

  • dphelper.math.exp(a, b) Returns the exponent of two numbers.

  • dphelper.math.isOdd(a) Checks if a number is odd.

  • dphelper.math.float2int(a) Converts a float to an integer.

  • dphelper.math.percent(n, tot) Calculates the percentage.

  • dphelper.math.isPrime(n) Checks if a number is prime.

Memory

  • dphelper.memory.lock(obj) Locks an object in memory.

  • dphelper.memory.unlock(obj) Unlocks an object in memory.

Object

  • dphelper.obj.toArray(object) Converts an object to an array.

  • dphelper.obj.replaceNullObjects(data) Replaces null objects in a record.

  • dphelper.obj.serialize(value) Serializes a value.

  • dphelper.obj.deSerialize(valueNew) Deserializes a value.

  • dphelper.obj.sort(o) Sorts an object.

  • dphelper.obj.toXML(obj) Converts an object to XML.

  • dphelper.obj.find(object, key, value) Finds an element in an object by key and value.

  • dphelper.obj.instance(obj) Returns the instance of an object.

  • dphelper.obj.updateByKey(obj, key, newValue) Updates an object by key.

  • dphelper.obj.findindex(object, key) Finds the index of an element in an object by key.

  • dphelper.obj.parse(val) Parses a value.

  • dphelper.obj.isObject(val) Checks if a value is an object.

  • dphelper.obj.diff(obj1, obj2) Finds the difference between two objects.

  • dphelper.obj.path(prop, object[], separator?) Converts a property path to a string.

  • dphelper.obj.shallow(object) Generate a shallow copy of an object.

  • dphelper.obj.deeCopy(object) Generate a structured copy of an object.

Path

  • dphelper.path.rail() Returns the rail path.

  • dphelper.path.hash() Returns the hash path.

  • dphelper.path.query(url) Parses the query string of a URL.

Promise

  • dphelper.promise.check(p) Checks if a value is a promise.

  • dphelper.promise.resolve(data) Resolves a promise with data.

Sanitize

  • dphelper.sanitize.html(s) Sanitizes HTML.

Screen

  • dphelper.screen.fullScreen(el) Enables full screen mode for an element.

  • dphelper.screen.toggle(el) Toggles full screen mode for an element.

  • dphelper.screen.info(): { width; height; availWidth; availHeight; colorDepth; pixelDepth } Gets screen information.

Scrollbar

  • dphelper.scrollbar.custom(el, options) Customizes a scrollbar.

  • dphelper.scrollbar.indicator(props) Adds a scrollbar indicator.

  • dphelper.scrollbar.position: { get(el); set(el) } Gets and sets scrollbar position.

  • dphelper.scrollbar.smooth(target, speed, smooth) Smooth scrolls to a target.

  • dphelper.scrollbar.scrollTo(container, element, gap?) Scrolls to an element within a container.

Security

  • dphelper.security.uuid: { byVal(string); v4; v5 } Generates UUIDs.

  • dphelper.security.hashPass(u, p, t?) Hashes a password.

  • dphelper.security.crypt(u, p, mode?) Encrypts data.

  • dphelper.security.deCrypt(u, p, mode?) Decrypts data.

  • dphelper.security.AES_KeyGen(passKey?) Generates an AES key.

  • dphelper.security.SHA256_Hex(passKey) Generates a SHA256 hash.

  • dphelper.security.ulid() Generates ULID (Universally Unique Lexicographically Sortable Identifier).

Shortcut

  • dphelper.shortcut.keys(e, trigger) Adds a keyboard shortcut.

Socket

  • dphelper.socket.info() Gets socket information.

  • dphelper.socket.start(element, server) Starts a socket connection.

  • dphelper.socket.conn(id, server) Connects to a socket server.

  • dphelper.socket.connect(server) Connects to a server.

  • dphelper.socket.open(id, server) Opens a socket connection.

  • dphelper.socket.send(mex, type?) Sends a message through a socket.

  • dphelper.socket.ping() Sends a ping through a socket.

  • dphelper.socket.receive(el?) Receives a message through a socket.

  • dphelper.socket.keepAlive() Keeps a socket connection alive.

  • dphelper.socket.check() Checks the status of a socket connection.

  • dphelper.socket.list() Lists all socket connections.

SVG

  • dphelper.svg.init(container, source1, source2, cb?) Initializes an SVG container.

  • dphelper.svg.check() Checks if SVG is supported.

  • dphelper.svg.update(rect1, rect2, cxn) Updates an SVG element.

  • dphelper.svg.getCurve(p1, p2, dx) Gets a curve path between two points.

  • dphelper.svg.getIntersection(dx, dy, cx, cy, w, h) Gets the intersection point of a curve.

  • dphelper.svg.setConnector(source, side) Sets a connector for an SVG element.

  • dphelper.svg.removeConnection(container) Removes a connection from an SVG container.

  • dphelper.svg.makeScrollable(svgContainer, scrollContainer, elm1, elm2, rect1, rect2) Makes an SVG container scrollable.

  • dphelper.svg.makeDraggable(evt) Makes an SVG element draggable.

  • dphelper.svg.toggle(evt, container, source1, source2) Toggles an SVG element.

  • dphelper.svg.convert(options) Converts an SVG element.

System

  • dphelper.svg.multiSplit() Splits a string into multiple parts.

Terminal

  • dphelper.terminal() Initializes a terminal.

Text

  • dphelper.text.trim(s, c, b, e) Trims a string.

  • dphelper.text.capitalize(txt) Capitalizes a string.

  • dphelper.text.lower(txt) Converts a string to lowercase.

  • dphelper.text.upper(txt) Converts a string to uppercase.

  • dphelper.text.nl2br(str) Converts newlines to tags.

  • dphelper.text.sanitize(str) Sanitizes a string.

  • dphelper.text.camelCase(str) Converts camelCase to space or underscore.

  • dphelper.text.fitContainer(el) Fits a text element to its container.

Timer

  • dphelper.timer.sleep(ms) Pauses execution for a specified time.

  • dphelper.timer.percentage(start, end) Calculates the percentage of time elapsed.

Tools

  • dphelper.tools.getip() Gets the IP address.

  • dphelper.tools.byteSize(bytes) Converts bytes to a human-readable format.

  • dphelper.tools.zIndex() Gets the z-index.

  • dphelper.tools.zeroToFalse(value) Converts zero to false.

Translators

  • dphelper.translator.convertMatrixToScale(values) Converts a matrix to a scale.

Trigger

  • dphelper.trigger.click(elem) Triggers a click event.

  • dphelper.trigger.change(elem) Triggers a change event.

  • dphelper.trigger.input(elem) Triggers an input event.

Type

  • dphelper.type.of(p) Gets the type of a value.

  • dphelper.type.instOfObj(p) Checks if a value is an instance of an object.

  • dphelper.type.isNull(p) Checks if a value is null.

  • dphelper.type.isBool(val) Checks if a value is a boolean.

UI

  • dphelper.ui: null User interface operations.

Window

  • dphelper.window.enhancement() Enhances the window.

  • dphelper.window.animationframe() Gets the animation frame.

  • dphelper.window.center(params: { url; title; name; w; h }) Centers a window.

  • dphelper.window.onBeforeUnLoad(e) Handles the before unload event.

  • dphelper.window.purge(d?, time?) Purges the document.

  • dphelper.window.stopZoomWheel(e) Stops the zoom wheel.

  • dphelper.window.setZoom(element?, zoom?) Sets the zoom level.

  • dphelper.window.getZoom(element?) Gets the zoom level.

License

This project is licensed under the MIT License.

Last updated