dphelper 1.8.25 → 1.8.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/CODE_OF_CONDUCT.md +1 -1
- package/CONTRIBUTING.md +4 -4
- package/LIST.md +571 -0
- package/OBSERVER.md +55 -0
- package/README.md +64 -65
- package/STATE.md +36 -0
- package/STORE.md +64 -0
- package/docs/index.md +64 -65
- package/index.d.ts +7 -6
- package/index.js +1 -1
- package/package.json +4 -5
- package/types/cache.d.ts +8 -5
- package/types/dphelper.d.ts +430 -12
- package/types/idb.d.ts +5 -3
- package/types/jquery.d.ts +5 -3
- package/types/observer.d.ts +9 -7
- package/types/state.d.ts +12 -5
- package/types/store.d.ts +19 -12
- package/module.js +0 -42
- package/types/_array.d.ts +0 -25
- package/types/_console.d.ts +0 -25
- package/types/_cookie.d.ts +0 -50
- package/types/_dispatch.d.ts +0 -21
- package/types/_security.d.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
New minor (feature) releases of this app/software are released every six months and
|
|
6
6
|
patch (bugfix) releases are released every month. More information on the
|
package/CODE_OF_CONDUCT.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Code of Conduct - dphelper
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
## Our Pledge
|
|
6
6
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- omit in toc -->
|
|
2
2
|
# Contributing to dphelper
|
|
3
3
|
|
|
4
|
-

|
|
5
5
|
|
|
6
6
|
First off, thanks for taking the time to contribute! ❤️
|
|
7
7
|
|
|
@@ -38,7 +38,7 @@ to <dariopassariello@gmail.com>.
|
|
|
38
38
|
|
|
39
39
|
## I Have a Question
|
|
40
40
|
|
|
41
|
-
> If you want to ask a question, we assume that you have read the available [Documentation](https://passariello.github.io/
|
|
41
|
+
> If you want to ask a question, we assume that you have read the available [Documentation](https://passariello.github.io/dphelper/).
|
|
42
42
|
|
|
43
43
|
Before you ask a question, it is best to search for existing [Issues](https://github.com/passariello/dphelper/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
|
|
44
44
|
|
|
@@ -78,7 +78,7 @@ Depending on how large the project is, you may want to outsource the questioning
|
|
|
78
78
|
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
|
|
79
79
|
|
|
80
80
|
- Make sure that you are using the latest version.
|
|
81
|
-
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://passariello.github.io/
|
|
81
|
+
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://passariello.github.io/dphelper/). If you are looking for support, you might want to check [this section](#i-have-a-question)).
|
|
82
82
|
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/passariello/dphelper/issues?q=label%3Abug).
|
|
83
83
|
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
|
|
84
84
|
- Collect information about the bug:
|
|
@@ -118,7 +118,7 @@ This section guides you through submitting an enhancement suggestion for dphelpe
|
|
|
118
118
|
#### Before Submitting an Enhancement
|
|
119
119
|
|
|
120
120
|
- Make sure that you are using the latest version.
|
|
121
|
-
- Read the [documentation](https://passariello.github.io/
|
|
121
|
+
- Read the [documentation](https://passariello.github.io/dphelper/) carefully and find out if the functionality is already covered, maybe by an individual configuration.
|
|
122
122
|
- Perform a [search](https://github.com/passariello/dphelper/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
|
123
123
|
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
|
|
124
124
|
|
package/LIST.md
ADDED
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
# dpHelper Functions List
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This document provides a comprehensive list of all available functions in the `dphelper` library along with their descriptions.
|
|
5
|
+
|
|
6
|
+
## Functions
|
|
7
|
+
|
|
8
|
+
### Anchor
|
|
9
|
+
- `toOnClick(el: string): void`
|
|
10
|
+
**Description:** Converts an element's href attribute to an onclick event.
|
|
11
|
+
|
|
12
|
+
### Array
|
|
13
|
+
- `find(array: any[], key: any): any`
|
|
14
|
+
**Description:** Finds an element in an array by key.
|
|
15
|
+
- `unique(array: any[]): any[]`
|
|
16
|
+
**Description:** Returns an array with unique elements.
|
|
17
|
+
- `delete(array: any[], key: any): void`
|
|
18
|
+
**Description:** Deletes an element from an array by key.
|
|
19
|
+
- `merge(arrayA: any[], arrayB: any[]): any[]`
|
|
20
|
+
**Description:** Merges two arrays.
|
|
21
|
+
- `mergeByKey(arrayA: any[], arrayB: any[], key: string): any[]`
|
|
22
|
+
**Description:** Merges two arrays by a specific key.
|
|
23
|
+
- `asc(array: any[]): any[]`
|
|
24
|
+
**Description:** Sorts an array in ascending order.
|
|
25
|
+
- `desc(array: any[]): any[]`
|
|
26
|
+
**Description:** Sorts an array in descending order.
|
|
27
|
+
- `duplicates(array: any[]): any[]`
|
|
28
|
+
**Description:** Returns an array of duplicate elements.
|
|
29
|
+
- `even(array: any[]): any[]`
|
|
30
|
+
**Description:** Returns an array of even numbers.
|
|
31
|
+
- `odd(array: any[]): any[]`
|
|
32
|
+
**Description:** Returns an array of odd numbers.
|
|
33
|
+
- `toObj(array: any[]): object`
|
|
34
|
+
**Description:** Converts an array to an object.
|
|
35
|
+
- `sumColumn(array: any[], column: number): number`
|
|
36
|
+
**Description:** Sums the values of a specific column in an array.
|
|
37
|
+
- `shuffle(array: any[]): any[]`
|
|
38
|
+
**Description:** Shuffles the elements of an array.
|
|
39
|
+
- `generate(num: number): any[]`
|
|
40
|
+
**Description:** Generates an array with a specified number of elements.
|
|
41
|
+
- `testArrayInt(array: any[]): number[]`
|
|
42
|
+
**Description:** Tests if the elements of an array are integers.
|
|
43
|
+
- `rand32(number: number): any`
|
|
44
|
+
**Description:** Generates a random 32-bit number.
|
|
45
|
+
- `findindex(array: any[], key: any): number`
|
|
46
|
+
**Description:** Finds the index of an element in an array by key.
|
|
47
|
+
- `pathToJson(array: any[], separator?: string): object`
|
|
48
|
+
**Description:** Converts an array to a JSON object using a separator.
|
|
49
|
+
- `deepClone(src: any): any`
|
|
50
|
+
**Description:** Creates a deep clone of an object.
|
|
51
|
+
- `match(arrayWords: any[], arrayToCheck: any[]): boolean`
|
|
52
|
+
**Description:** Checks if two arrays match.
|
|
53
|
+
|
|
54
|
+
### Audio
|
|
55
|
+
- `play(url: string): void`
|
|
56
|
+
**Description:** Plays an audio file from a URL.
|
|
57
|
+
|
|
58
|
+
### Avoid
|
|
59
|
+
- `cache(uri: string): string`
|
|
60
|
+
**Description:** Caches a URI.
|
|
61
|
+
|
|
62
|
+
### Browser
|
|
63
|
+
- `state(state: any, title: any, url: any): void`
|
|
64
|
+
**Description:** Changes the browser state.
|
|
65
|
+
- `forw(times: number): void`
|
|
66
|
+
**Description:** Moves forward in the browser history.
|
|
67
|
+
- `back(times: number): void`
|
|
68
|
+
**Description:** Moves backward in the browser history.
|
|
69
|
+
- `reload(): void`
|
|
70
|
+
**Description:** Reloads the current page.
|
|
71
|
+
- `href(url: string): void`
|
|
72
|
+
**Description:** Navigates to a URL.
|
|
73
|
+
- `offLine(text?: string): void`
|
|
74
|
+
**Description:** Displays an offline message.
|
|
75
|
+
- `zoom(): number`
|
|
76
|
+
**Description:** Gets the current zoom level.
|
|
77
|
+
- `status(code: number): string`
|
|
78
|
+
**Description:** Gets the status text for a status code.
|
|
79
|
+
|
|
80
|
+
### Check
|
|
81
|
+
- `url(url: string): any`
|
|
82
|
+
**Description:** Checks if a URL is valid.
|
|
83
|
+
- `version(v1: string, v2: string, opts: any): any`
|
|
84
|
+
**Description:** Compares two version strings.
|
|
85
|
+
- `npmVer(npm: string): any`
|
|
86
|
+
**Description:** Gets the version of an npm package.
|
|
87
|
+
|
|
88
|
+
### Color
|
|
89
|
+
- `hex(c: any): string`
|
|
90
|
+
**Description:** Converts a color to hex format.
|
|
91
|
+
- `toHex(rgb: any): string`
|
|
92
|
+
**Description:** Converts RGB to hex format.
|
|
93
|
+
- `toRGB(c: any): Array`
|
|
94
|
+
**Description:** Converts a color to RGB format.
|
|
95
|
+
- `oleColor(c: any): string`
|
|
96
|
+
**Description:** Converts a color to OLE format.
|
|
97
|
+
- `gradient(colorStart: any, colorEnd: any, colorCount: any): any`
|
|
98
|
+
**Description:** Generates a gradient between two colors.
|
|
99
|
+
|
|
100
|
+
### Console
|
|
101
|
+
- `info(name: string, message: string, fn: Function): void`
|
|
102
|
+
**Description:** Logs an info message to the console.
|
|
103
|
+
- `stop(options?: string[]): void`
|
|
104
|
+
**Description:** Stops the console.
|
|
105
|
+
- `toHtml(el: string): void`
|
|
106
|
+
**Description:** Converts console output to HTML.
|
|
107
|
+
|
|
108
|
+
### Cookie
|
|
109
|
+
- `set(pars: { name: any, value: any, time?: any, path?: "/", sameSite?: "Lax", secure?: "Secure" | "false" }): any`
|
|
110
|
+
**Description:** Sets a cookie.
|
|
111
|
+
- `get(name: string): any`
|
|
112
|
+
**Description:** Gets a cookie by name.
|
|
113
|
+
- `delete(name: string): any`
|
|
114
|
+
**Description:** Deletes a cookie by name.
|
|
115
|
+
- `clearAll(): any`
|
|
116
|
+
**Description:** Clears all cookies.
|
|
117
|
+
|
|
118
|
+
### Coords
|
|
119
|
+
- `degreesToRadians(degrees: any): any`
|
|
120
|
+
**Description:** Converts degrees to radians.
|
|
121
|
+
- `latToMeters(points: any): any`
|
|
122
|
+
**Description:** Converts latitude to meters.
|
|
123
|
+
- `toVector(points: any): any`
|
|
124
|
+
**Description:** Converts points to a vector.
|
|
125
|
+
- `convertToDecDegrees(deg: any, minutes: any, sec: any, direction: any): any`
|
|
126
|
+
**Description:** Converts coordinates to decimal degrees.
|
|
127
|
+
- `distance(point1: any, point2: any): any`
|
|
128
|
+
**Description:** Calculates the distance between two points.
|
|
129
|
+
- `polarToCartesian(centerX: any, centerY: any, radius: any, angleInDegrees: any): any`
|
|
130
|
+
**Description:** Converts polar coordinates to Cartesian coordinates.
|
|
131
|
+
- `mapDegreesToPixels(degree: number, minDegree: number, maxDegree: number, minPixel: number, maxPixel: number, padding: number): number`
|
|
132
|
+
**Description:** Maps degrees to pixels.
|
|
133
|
+
|
|
134
|
+
### Credits
|
|
135
|
+
- `credits: Function`
|
|
136
|
+
**Description:** Displays credits.
|
|
137
|
+
|
|
138
|
+
### Date
|
|
139
|
+
- `days(lang?: string): string[]`
|
|
140
|
+
**Description:** Returns the days of the week in a specified language.
|
|
141
|
+
- `months(lang?: string): string[]`
|
|
142
|
+
**Description:** Returns the months of the year in a specified language.
|
|
143
|
+
- `year(): number`
|
|
144
|
+
**Description:** Returns the current year.
|
|
145
|
+
- `toIso(value: any, int?: string): string | null`
|
|
146
|
+
**Description:** Converts a date to ISO format.
|
|
147
|
+
- `toMMDDYYYY(value: any): string`
|
|
148
|
+
**Description:** Converts a date to MM/DD/YYYY format.
|
|
149
|
+
- `toYYYYMMDD(value: any): string | undefined`
|
|
150
|
+
**Description:** Converts a date to YYYY/MM/DD format.
|
|
151
|
+
- `toHuman(value: any): string`
|
|
152
|
+
**Description:** Converts a date to a human-readable format.
|
|
153
|
+
- `convert(value: any, format: string[]): string | null`
|
|
154
|
+
**Description:** Converts a date to a specified format.
|
|
155
|
+
- `iso2Epoch(value: any): number`
|
|
156
|
+
**Description:** Converts an ISO date to epoch time.
|
|
157
|
+
- `localIsoTime(value: any): string`
|
|
158
|
+
**Description:** Converts a date to local ISO time.
|
|
159
|
+
- `utc(): string`
|
|
160
|
+
**Description:** Returns the current UTC time.
|
|
161
|
+
- `parse(value: any, separator?: string): string | null`
|
|
162
|
+
**Description:** Parses a date string.
|
|
163
|
+
- `addDays(date: any, days: number): Date`
|
|
164
|
+
**Description:** Adds days to a date.
|
|
165
|
+
- `dateTimeToString(dateObject: any): string`
|
|
166
|
+
**Description:** Converts a date object to a string.
|
|
167
|
+
- `isoToHuman(value: any, symbol?: string): string | null`
|
|
168
|
+
**Description:** Converts an ISO date to a human-readable format.
|
|
169
|
+
- `fullDate(): string`
|
|
170
|
+
**Description:** Returns the full date.
|
|
171
|
+
- `epoch(): number`
|
|
172
|
+
**Description:** Returns the current epoch time.
|
|
173
|
+
- `diffInDays(d1: any, d2: any): number`
|
|
174
|
+
**Description:** Calculates the difference in days between two dates.
|
|
175
|
+
- `diffInWeeks(d1: any, d2: any): number`
|
|
176
|
+
**Description:** Calculates the difference in weeks between two dates.
|
|
177
|
+
- `diffInMonths(d1: any, d2: any): number`
|
|
178
|
+
**Description:** Calculates the difference in months between two dates.
|
|
179
|
+
- `diffInYears(d1: any, d2: any): number`
|
|
180
|
+
**Description:** Calculates the difference in years between two dates.
|
|
181
|
+
- `dateToYMD(date: any): string`
|
|
182
|
+
**Description:** Converts a date to YYYY-MM-DD format.
|
|
183
|
+
- `collection(params: { date?: Date; type: string; locale?: string }): string | undefined`
|
|
184
|
+
**Description:** Returns a collection of dates.
|
|
185
|
+
- `timeZones(): string[]`
|
|
186
|
+
**Description:** Returns a list of time zones.
|
|
187
|
+
|
|
188
|
+
### Disable
|
|
189
|
+
- `select(el?: string): void`
|
|
190
|
+
**Description:** Disables text selection.
|
|
191
|
+
- `spellCheck(tmr?: number): void`
|
|
192
|
+
**Description:** Disables spell check.
|
|
193
|
+
- `rightClick(el?: string): void`
|
|
194
|
+
**Description:** Disables right-click.
|
|
195
|
+
- `copy(el?: string): void`
|
|
196
|
+
**Description:** Disables copy.
|
|
197
|
+
- `paste(el?: string): void`
|
|
198
|
+
**Description:** Disables paste.
|
|
199
|
+
- `cut(el?: string): void`
|
|
200
|
+
**Description:** Disables cut.
|
|
201
|
+
- `drag(el?: string): void`
|
|
202
|
+
**Description:** Disables drag.
|
|
203
|
+
|
|
204
|
+
### Dispatch
|
|
205
|
+
- `set(name: string, value?: any): void`
|
|
206
|
+
**Description:** Sets a dispatch event.
|
|
207
|
+
- `listen(name: string, cb?: (e: Event) => void, flag?: boolean): void`
|
|
208
|
+
**Description:** Listens for a dispatch event.
|
|
209
|
+
- `remove(name: string): void`
|
|
210
|
+
**Description:** Removes a dispatch event.
|
|
211
|
+
|
|
212
|
+
### Element
|
|
213
|
+
- `fitScale(el: any, scale?: number, fit?: boolean): void`
|
|
214
|
+
**Description:** Fits an element to a scale.
|
|
215
|
+
- `scaleBasedOnWindow(elm: any, scale: number, fit: boolean): void`
|
|
216
|
+
**Description:** Scales an element based on the window size.
|
|
217
|
+
|
|
218
|
+
### Events
|
|
219
|
+
- `list(el: Element): any`
|
|
220
|
+
**Description:** Lists all events on an element.
|
|
221
|
+
- `multi(element: Element, eventNames: string, listener: EventListener): void`
|
|
222
|
+
**Description:** Adds multiple event listeners to an element.
|
|
223
|
+
- `copy(el: string): void`
|
|
224
|
+
**Description:** Copies an element.
|
|
225
|
+
- `onDrag(elem: string): void`
|
|
226
|
+
**Description:** Adds a drag event to an element.
|
|
227
|
+
- `keys(e: KeyboardEvent): { key: string; ctrl: boolean; alt: boolean; shift: boolean }`
|
|
228
|
+
**Description:** Gets the key, ctrl, alt, and shift status from a keyboard event.
|
|
229
|
+
|
|
230
|
+
### Form
|
|
231
|
+
- `serialize(form: HTMLFormElement): { [key: string]: any }`
|
|
232
|
+
**Description:** Serializes a form to an object.
|
|
233
|
+
- `confirmType(type: string, value: any): boolean`
|
|
234
|
+
**Description:** Confirms the type of a value.
|
|
235
|
+
- `required(value: any): string | undefined`
|
|
236
|
+
**Description:** Checks if a value is required.
|
|
237
|
+
- `minLength(value: any, num?: number): string | undefined`
|
|
238
|
+
**Description:** Checks if a value meets the minimum length.
|
|
239
|
+
- `maxLength(value: any, num?: number): string | undefined`
|
|
240
|
+
**Description:** Checks if a value exceeds the maximum length.
|
|
241
|
+
- `maxPhoneNumber(value: any, num?: number): string | undefined`
|
|
242
|
+
**Description:** Checks if a phone number exceeds the maximum length.
|
|
243
|
+
- `isNumeric(value: any): boolean`
|
|
244
|
+
**Description:** Checks if a value is numeric.
|
|
245
|
+
- `isEmail(value: any): boolean`
|
|
246
|
+
**Description:** Checks if a value is an email.
|
|
247
|
+
- `pattern(e: Event): void`
|
|
248
|
+
**Description:** Validates a pattern.
|
|
249
|
+
- `noSpecialChars(e: Event): void`
|
|
250
|
+
**Description:** Disallows special characters.
|
|
251
|
+
- `table(size: [number, number], id: string, elem: HTMLElement): void`
|
|
252
|
+
**Description:** Creates a table.
|
|
253
|
+
- `sanitize(str: string): string | undefined`
|
|
254
|
+
**Description:** Sanitizes a string.
|
|
255
|
+
|
|
256
|
+
### Format
|
|
257
|
+
- `currency(value: number, locale?: string, currency?: string): string`
|
|
258
|
+
**Description:** Formats a value as currency.
|
|
259
|
+
- `phoneNumber(value: string, countryCode?: string): string`
|
|
260
|
+
**Description:** Formats a phone number.
|
|
261
|
+
|
|
262
|
+
### Imports
|
|
263
|
+
- `file(elem: string, file: string): Promise<void>`
|
|
264
|
+
**Description:** Imports a file.
|
|
265
|
+
|
|
266
|
+
### Json
|
|
267
|
+
- `counter(json: any, key?: string, val?: any): number | null`
|
|
268
|
+
**Description:** Counts occurrences in a JSON object.
|
|
269
|
+
- `toCsv(jsonInput: any): string`
|
|
270
|
+
**Description:** Converts JSON to CSV.
|
|
271
|
+
- `saveCsvAs(csvData: string, fileName: string): void`
|
|
272
|
+
**Description:** Saves CSV data as a file.
|
|
273
|
+
- `is(str: string): boolean`
|
|
274
|
+
**Description:** Checks if a string is valid JSON.
|
|
275
|
+
- `parse(file: string): any`
|
|
276
|
+
**Description:** Parses a JSON file.
|
|
277
|
+
- `sanitize(str: string): string`
|
|
278
|
+
**Description:** Sanitizes a JSON string.
|
|
279
|
+
- `sanitizeJsonValue(str: string): string`
|
|
280
|
+
**Description:** Sanitizes a JSON value.
|
|
281
|
+
|
|
282
|
+
### Load
|
|
283
|
+
- `all(context: __WebpackModuleApi.RequireContext, cacheName?: string): void`
|
|
284
|
+
**Description:** Loads all modules in a context.
|
|
285
|
+
- `file(filePath: string): Promise<string>`
|
|
286
|
+
**Description:** Loads a file.
|
|
287
|
+
- `fileToElement(elementSelector: string, filePath: string): Promise<void>`
|
|
288
|
+
**Description:** Loads a file into an element.
|
|
289
|
+
- `json(filePath: string): Promise<any>`
|
|
290
|
+
**Description:** Loads a JSON file.
|
|
291
|
+
- `remote(path: string, method?: string, headers?: HeadersInit): Promise<any>`
|
|
292
|
+
**Description:** Loads data from a remote URL.
|
|
293
|
+
- `script(scripts: string[], elementSelector?: string): void`
|
|
294
|
+
**Description:** Loads scripts.
|
|
295
|
+
- `toJson(context: __WebpackModuleApi.RequireContext, cacheName?: string): void`
|
|
296
|
+
**Description:** Converts a context to JSON.
|
|
297
|
+
|
|
298
|
+
### Logging
|
|
299
|
+
- `list: { type: string; message: string }`
|
|
300
|
+
**Description:** List of log messages.
|
|
301
|
+
- `reg(txt: string): void`
|
|
302
|
+
**Description:** Logs a regular message.
|
|
303
|
+
- `debug(txt: string): void`
|
|
304
|
+
**Description:** Logs a debug message.
|
|
305
|
+
- `error(txt: string): void`
|
|
306
|
+
**Description:** Logs an error message.
|
|
307
|
+
|
|
308
|
+
### Math
|
|
309
|
+
- `rnd(): number`
|
|
310
|
+
**Description:** Generates a random number.
|
|
311
|
+
- `tmr(): number`
|
|
312
|
+
**Description:** Returns the current time in milliseconds.
|
|
313
|
+
- `add(a: number, b: number): number`
|
|
314
|
+
**Description:** Adds two numbers.
|
|
315
|
+
- `sub(a: number, b: number): number`
|
|
316
|
+
**Description:** Subtracts two numbers.
|
|
317
|
+
- `multi(a: number, b: number): number`
|
|
318
|
+
**Description:** Multiplies two numbers.
|
|
319
|
+
- `div(a: number, b: number): number`
|
|
320
|
+
**Description:** Divides two numbers.
|
|
321
|
+
- `rem(a: number, b: number): number`
|
|
322
|
+
**Description:** Returns the remainder of two numbers.
|
|
323
|
+
- `exp(a: number, b: number): number`
|
|
324
|
+
**Description:** Returns the exponent of two numbers.
|
|
325
|
+
- `isOdd(a: number): boolean`
|
|
326
|
+
**Description:** Checks if a number is odd.
|
|
327
|
+
- `float2int(a: number): number`
|
|
328
|
+
**Description:** Converts a float to an integer.
|
|
329
|
+
- `percent(n: number, tot: number): number`
|
|
330
|
+
**Description:** Calculates the percentage.
|
|
331
|
+
- `isPrime(n: number): boolean`
|
|
332
|
+
**Description:** Checks if a number is prime.
|
|
333
|
+
|
|
334
|
+
### Memory
|
|
335
|
+
- `lock(obj: string): void`
|
|
336
|
+
**Description:** Locks an object in memory.
|
|
337
|
+
- `unlock(obj: string): void`
|
|
338
|
+
**Description:** Unlocks an object in memory.
|
|
339
|
+
|
|
340
|
+
### Object
|
|
341
|
+
- `toArray(object: Record<string, any>): [string, any][]`
|
|
342
|
+
**Description:** Converts an object to an array.
|
|
343
|
+
- `replaceNullObjects(data: Record<string, any>): Record<string, any>`
|
|
344
|
+
**Description:** Replaces null objects in a record.
|
|
345
|
+
- `serialize(value: any): any`
|
|
346
|
+
**Description:** Serializes a value.
|
|
347
|
+
- `deSerialize(valueNew: any): any`
|
|
348
|
+
**Description:** Deserializes a value.
|
|
349
|
+
- `sort(o: Record<string, any>): Record<string, any>`
|
|
350
|
+
**Description:** Sorts an object.
|
|
351
|
+
- `toXML(obj: Record<string, any>): string`
|
|
352
|
+
**Description:** Converts an object to XML.
|
|
353
|
+
- `find(array: any[], key: string, value: any): any`
|
|
354
|
+
**Description:** Finds an element in an array by key and value.
|
|
355
|
+
- `instance(obj: any): any`
|
|
356
|
+
**Description:** Returns the instance of an object.
|
|
357
|
+
- `updateByKey(obj: Record<string, any>, key: string, newValue: any): Record<string, any>`
|
|
358
|
+
**Description:** Updates an object by key.
|
|
359
|
+
- `findindex(array: any[], key: string): number`
|
|
360
|
+
**Description:** Finds the index of an element in an array by key.
|
|
361
|
+
- `parse(val: any): any`
|
|
362
|
+
**Description:** Parses a value.
|
|
363
|
+
- `isObject(val: any): boolean`
|
|
364
|
+
**Description:** Checks if a value is an object.
|
|
365
|
+
- `diff(obj1: Record<string, any>, obj2: Record<string, any>): Record<string, { obj1: any, obj2: any }>`
|
|
366
|
+
**Description:** Finds the difference between two objects.
|
|
367
|
+
- `path(prop: string, array: string[], separator?: string): string`
|
|
368
|
+
**Description:** Converts a property path to a string.
|
|
369
|
+
|
|
370
|
+
### Observer
|
|
371
|
+
- `(stateName: string, callBack?: Function, option?: object): void`
|
|
372
|
+
**Description:** Observes a state.
|
|
373
|
+
- `list(): any`
|
|
374
|
+
**Description:** Lists all observers.
|
|
375
|
+
- `remove(name: string): void`
|
|
376
|
+
**Description:** Removes an observer.
|
|
377
|
+
- `removeAll(): void`
|
|
378
|
+
**Description:** Removes all observers.
|
|
379
|
+
|
|
380
|
+
### Path
|
|
381
|
+
- `rail(): string[]`
|
|
382
|
+
**Description:** Returns the rail path.
|
|
383
|
+
- `hash(): string[]`
|
|
384
|
+
**Description:** Returns the hash path.
|
|
385
|
+
- `query(url: string): Record<string, string>`
|
|
386
|
+
**Description:** Parses the query string of a URL.
|
|
387
|
+
|
|
388
|
+
### Promise
|
|
389
|
+
- `check(p: any): boolean`
|
|
390
|
+
**Description:** Checks if a value is a promise.
|
|
391
|
+
- `resolve(data: any): Promise<any>`
|
|
392
|
+
**Description:** Resolves a promise with data.
|
|
393
|
+
|
|
394
|
+
### Sanitize
|
|
395
|
+
- `html(s: string): string`
|
|
396
|
+
**Description:** Sanitizes HTML.
|
|
397
|
+
|
|
398
|
+
### Screen
|
|
399
|
+
- `fullScreen(el: string): void`
|
|
400
|
+
**Description:** Enables full screen mode for an element.
|
|
401
|
+
- `toggle(el: string): void`
|
|
402
|
+
**Description:** Toggles full screen mode for an element.
|
|
403
|
+
- `info(): { width: number; height: number; availWidth: number; availHeight: number; colorDepth: number; pixelDepth: number }`
|
|
404
|
+
**Description:** Gets screen information.
|
|
405
|
+
|
|
406
|
+
### Scrollbar
|
|
407
|
+
- `custom(el: string, options: any): void`
|
|
408
|
+
**Description:** Customizes a scrollbar.
|
|
409
|
+
- `indicator(props: any): void`
|
|
410
|
+
**Description:** Adds a scrollbar indicator.
|
|
411
|
+
- `position: { get(el: any): void; set(el: any): void }`
|
|
412
|
+
**Description:** Gets and sets scrollbar position.
|
|
413
|
+
- `smooth(target: any, speed: any, smooth: any): void`
|
|
414
|
+
**Description:** Smooth scrolls to a target.
|
|
415
|
+
- `scrollTo(container: string, element: string, gap?: number): void`
|
|
416
|
+
**Description:** Scrolls to an element within a container.
|
|
417
|
+
|
|
418
|
+
### Security
|
|
419
|
+
- `uuid: { byVal(string: string): string; v4: string; v5: string }`
|
|
420
|
+
**Description:** Generates UUIDs.
|
|
421
|
+
- `hashPass(u: string, p: string, t?: string): Promise<string>`
|
|
422
|
+
**Description:** Hashes a password.
|
|
423
|
+
- `crypt(u: string, p: string, mode?: string): string`
|
|
424
|
+
**Description:** Encrypts data.
|
|
425
|
+
- `deCrypt(u: string, p: string, mode?: string): string`
|
|
426
|
+
**Description:** Decrypts data.
|
|
427
|
+
- `AES_KeyGen(passKey?: string): string`
|
|
428
|
+
**Description:** Generates an AES key.
|
|
429
|
+
- `SHA256_Hex(passKey: string): string`
|
|
430
|
+
**Description:** Generates a SHA256 hash.
|
|
431
|
+
|
|
432
|
+
### Shortcut
|
|
433
|
+
- `keys(e: any, trigger: any): void`
|
|
434
|
+
**Description:** Adds a keyboard shortcut.
|
|
435
|
+
|
|
436
|
+
### Socket
|
|
437
|
+
- `info(): string`
|
|
438
|
+
**Description:** Gets socket information.
|
|
439
|
+
- `start(element: any, server: any): void`
|
|
440
|
+
**Description:** Starts a socket connection.
|
|
441
|
+
- `conn(id: any, server: any): [WebSocket, any]`
|
|
442
|
+
**Description:** Connects to a socket server.
|
|
443
|
+
- `connect(server: any): void`
|
|
444
|
+
**Description:** Connects to a server.
|
|
445
|
+
- `open(id: any, server: any): void`
|
|
446
|
+
**Description:** Opens a socket connection.
|
|
447
|
+
- `send(mex: any, type?: string): void`
|
|
448
|
+
**Description:** Sends a message through a socket.
|
|
449
|
+
- `ping(): void`
|
|
450
|
+
**Description:** Sends a ping through a socket.
|
|
451
|
+
- `receive(el?: any): void`
|
|
452
|
+
**Description:** Receives a message through a socket.
|
|
453
|
+
- `keepAlive(): void`
|
|
454
|
+
**Description:** Keeps a socket connection alive.
|
|
455
|
+
- `check(): void`
|
|
456
|
+
**Description:** Checks the status of a socket connection.
|
|
457
|
+
- `list(): WebSocket[]`
|
|
458
|
+
**Description:** Lists all socket connections.
|
|
459
|
+
|
|
460
|
+
### SVG
|
|
461
|
+
- `init(container: HTMLElement, source1: [HTMLElement, string], source2: [HTMLElement, string], cb?: Function): void`
|
|
462
|
+
**Description:** Initializes an SVG container.
|
|
463
|
+
- `check(): boolean`
|
|
464
|
+
**Description:** Checks if SVG is supported.
|
|
465
|
+
- `update(rect1: HTMLElement, rect2: HTMLElement, cxn: HTMLElement): void`
|
|
466
|
+
**Description:** Updates an SVG element.
|
|
467
|
+
- `getCurve(p1: [number, number], p2: [number, number], dx: number): string`
|
|
468
|
+
**Description:** Gets a curve path between two points.
|
|
469
|
+
- `getIntersection(dx: number, dy: number, cx: number, cy: number, w: number, h: number): [number, number]`
|
|
470
|
+
**Description:** Gets the intersection point of a curve.
|
|
471
|
+
- `setConnector(source: HTMLElement, side: string): HTMLElement`
|
|
472
|
+
**Description:** Sets a connector for an SVG element.
|
|
473
|
+
- `removeConnection(container: HTMLElement): void`
|
|
474
|
+
**Description:** Removes a connection from an SVG container.
|
|
475
|
+
- `makeScrollable(svgContainer: HTMLElement, scrollContainer: HTMLElement, elm1: HTMLElement, elm2: HTMLElement, rect1: HTMLElement, rect2: HTMLElement): void`
|
|
476
|
+
**Description:** Makes an SVG container scrollable.
|
|
477
|
+
- `makeDraggable(evt: Event): void`
|
|
478
|
+
**Description:** Makes an SVG element draggable.
|
|
479
|
+
- `toggle(evt: Event, container: HTMLElement, source1: HTMLElement, source2: HTMLElement): void`
|
|
480
|
+
**Description:** Toggles an SVG element.
|
|
481
|
+
- `convert(options: ConvertOptions): string | void`
|
|
482
|
+
**Description:** Converts an SVG element.
|
|
483
|
+
|
|
484
|
+
### System
|
|
485
|
+
- `multiSplit(): any`
|
|
486
|
+
**Description:** Splits a string into multiple parts.
|
|
487
|
+
|
|
488
|
+
### Termina
|
|
489
|
+
- `termina(): Terminal`
|
|
490
|
+
**Description:** Initializes a terminal.
|
|
491
|
+
|
|
492
|
+
### Text
|
|
493
|
+
- `trim(s: string, c: string, b: number, e: number): string`
|
|
494
|
+
**Description:** Trims a string.
|
|
495
|
+
- `capitalize(txt: string): string`
|
|
496
|
+
**Description:** Capitalizes a string.
|
|
497
|
+
- `lower(txt: string): string`
|
|
498
|
+
**Description:** Converts a string to lowercase.
|
|
499
|
+
- `upper(txt: string): string`
|
|
500
|
+
**Description:** Converts a string to uppercase.
|
|
501
|
+
- `nl2br(str: string): string`
|
|
502
|
+
**Description:** Converts newlines to <br> tags.
|
|
503
|
+
- `sanitize(str: string): string`
|
|
504
|
+
**Description:** Sanitizes a string.
|
|
505
|
+
- `camelCase: { toSpace(string: string): string; toUnderscore(string: string): string }`
|
|
506
|
+
**Description:** Converts camelCase to space or underscore.
|
|
507
|
+
- `fitContainer(el: string): void`
|
|
508
|
+
**Description:** Fits a text element to its container.
|
|
509
|
+
|
|
510
|
+
### Timer
|
|
511
|
+
- `sleep(ms: number): Promise<void>`
|
|
512
|
+
**Description:** Pauses execution for a specified time.
|
|
513
|
+
- `percentage(start: string, end: string): string`
|
|
514
|
+
**Description:** Calculates the percentage of time elapsed.
|
|
515
|
+
|
|
516
|
+
### Tools
|
|
517
|
+
- `getip(): Promise<void>`
|
|
518
|
+
**Description:** Gets the IP address.
|
|
519
|
+
- `byteSize(bytes: number): string`
|
|
520
|
+
**Description:** Converts bytes to a human-readable format.
|
|
521
|
+
- `zIndex(): number`
|
|
522
|
+
**Description:** Gets the z-index.
|
|
523
|
+
- `zeroToFalse(value: number): boolean | number`
|
|
524
|
+
**Description:** Converts zero to false.
|
|
525
|
+
|
|
526
|
+
### Translators
|
|
527
|
+
- `convertMatrixToScale(values: any): number`
|
|
528
|
+
**Description:** Converts a matrix to a scale.
|
|
529
|
+
|
|
530
|
+
### Trigger
|
|
531
|
+
- `click(elem: string): void`
|
|
532
|
+
**Description:** Triggers a click event.
|
|
533
|
+
- `change(elem: string): void`
|
|
534
|
+
**Description:** Triggers a change event.
|
|
535
|
+
- `input(elem: string): void`
|
|
536
|
+
**Description:** Triggers an input event.
|
|
537
|
+
|
|
538
|
+
### Type
|
|
539
|
+
- `of(p: any): string`
|
|
540
|
+
**Description:** Gets the type of a value.
|
|
541
|
+
- `instOfObj(p: any): boolean`
|
|
542
|
+
**Description:** Checks if a value is an instance of an object.
|
|
543
|
+
- `isNull(p: any): (i: any) => boolean`
|
|
544
|
+
**Description:** Checks if a value is null.
|
|
545
|
+
- `isBool(val: any): boolean`
|
|
546
|
+
**Description:** Checks if a value is a boolean.
|
|
547
|
+
|
|
548
|
+
### UI
|
|
549
|
+
- `ui: null`
|
|
550
|
+
**Description:** User interface operations.
|
|
551
|
+
|
|
552
|
+
### Window
|
|
553
|
+
- `enhancement(): void`
|
|
554
|
+
**Description:** Enhances the window.
|
|
555
|
+
- `animationframe(): any`
|
|
556
|
+
**Description:** Gets the animation frame.
|
|
557
|
+
- `center(params: { url: string; title: string; name: string; w: number; h: number }): void`
|
|
558
|
+
**Description:** Centers a window.
|
|
559
|
+
- `onBeforeUnLoad(e: any): void`
|
|
560
|
+
**Description:** Handles the before unload event.
|
|
561
|
+
- `purge(d?: Document, time?: number): void`
|
|
562
|
+
**Description:** Purges the document.
|
|
563
|
+
- `stopZoomWheel(e: any): void`
|
|
564
|
+
**Description:** Stops the zoom wheel.
|
|
565
|
+
- `setZoom(element?: string, zoom?: number): string`
|
|
566
|
+
**Description:** Sets the zoom level.
|
|
567
|
+
- `getZoom(element?: string): number`
|
|
568
|
+
**Description:** Gets the zoom level.
|
|
569
|
+
|
|
570
|
+
## License
|
|
571
|
+
This project is licensed under the MIT License.
|
package/OBSERVER.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# dpHelper Observer
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This document provides a comprehensive list of all available observer functions in the `dphelper` library along with their descriptions and examples.
|
|
5
|
+
|
|
6
|
+
## Functions
|
|
7
|
+
|
|
8
|
+
### observer
|
|
9
|
+
- **Description:** Sets up an observer to monitor state changes and trigger a callback.
|
|
10
|
+
- **Parameters:**
|
|
11
|
+
- `stateName` (string): The name of the state to monitor.
|
|
12
|
+
- `callBack` (Function): The callback function to run when the state changes.
|
|
13
|
+
- `option` (object): Additional options for the observer.
|
|
14
|
+
- **Example:**
|
|
15
|
+
```javascript
|
|
16
|
+
observer('state.test', (newValue) => {
|
|
17
|
+
console.log('State changed:', newValue);
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### recall
|
|
22
|
+
- **Description:** Recall the observer previously generated.
|
|
23
|
+
- **Returns:** Console log with a note
|
|
24
|
+
- **Example:**
|
|
25
|
+
```javascript
|
|
26
|
+
observer('state.test');
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### list
|
|
30
|
+
- **Description:** See the list of all your observer (eventListener) actually installed.
|
|
31
|
+
- **Returns:** The list of all installed observers.
|
|
32
|
+
- **Example:**
|
|
33
|
+
```javascript
|
|
34
|
+
observer.list();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### remove
|
|
38
|
+
- **Description:** Remove an observer.
|
|
39
|
+
- **Parameters:**
|
|
40
|
+
- `name` (string): The name of the observer to remove.
|
|
41
|
+
- **Example:**
|
|
42
|
+
```javascript
|
|
43
|
+
observer.remove('state.test');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### removeAll
|
|
47
|
+
- **Description:** Remove all observers.
|
|
48
|
+
- **Returns:** void
|
|
49
|
+
- **Example:**
|
|
50
|
+
```javascript
|
|
51
|
+
observer.removeAll();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
This project is licensed under the MIT License.
|