@gesslar/toolkit 3.14.0 → 3.14.1

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.
Files changed (61) hide show
  1. package/package.json +10 -9
  2. package/types/browser/index.d.ts +13 -0
  3. package/types/browser/index.d.ts.map +1 -0
  4. package/types/browser/lib/Collection.d.ts +248 -0
  5. package/types/browser/lib/Collection.d.ts.map +1 -0
  6. package/types/browser/lib/Data.d.ts +250 -0
  7. package/types/browser/lib/Data.d.ts.map +1 -0
  8. package/types/browser/lib/Disposer.d.ts +33 -0
  9. package/types/browser/lib/Disposer.d.ts.map +1 -0
  10. package/types/browser/lib/HTML.d.ts +40 -0
  11. package/types/browser/lib/HTML.d.ts.map +1 -0
  12. package/types/browser/lib/Notify.d.ts +60 -0
  13. package/types/browser/lib/Notify.d.ts.map +1 -0
  14. package/types/browser/lib/Promised.d.ts +119 -0
  15. package/types/browser/lib/Promised.d.ts.map +1 -0
  16. package/types/browser/lib/Sass.d.ts +63 -0
  17. package/types/browser/lib/Sass.d.ts.map +1 -0
  18. package/types/browser/lib/Tantrum.d.ts +52 -0
  19. package/types/browser/lib/Tantrum.d.ts.map +1 -0
  20. package/types/browser/lib/Time.d.ts +42 -0
  21. package/types/browser/lib/Time.d.ts.map +1 -0
  22. package/types/browser/lib/TypeSpec.d.ts +90 -0
  23. package/types/browser/lib/TypeSpec.d.ts.map +1 -0
  24. package/types/browser/lib/Util.d.ts +62 -0
  25. package/types/browser/lib/Util.d.ts.map +1 -0
  26. package/types/browser/lib/Valid.d.ts +33 -0
  27. package/types/browser/lib/Valid.d.ts.map +1 -0
  28. package/types/browser/lib/vendor/dompurify.esm.d.ts +29 -0
  29. package/types/browser/lib/vendor/dompurify.esm.d.ts.map +1 -0
  30. package/types/node/index.d.ts +21 -0
  31. package/types/node/index.d.ts.map +1 -0
  32. package/types/node/lib/Cache.d.ts +27 -0
  33. package/types/node/lib/Cache.d.ts.map +1 -0
  34. package/types/node/lib/DirectoryObject.d.ts +277 -0
  35. package/types/node/lib/DirectoryObject.d.ts.map +1 -0
  36. package/types/node/lib/FileObject.d.ts +209 -0
  37. package/types/node/lib/FileObject.d.ts.map +1 -0
  38. package/types/node/lib/FileSystem.d.ts +188 -0
  39. package/types/node/lib/FileSystem.d.ts.map +1 -0
  40. package/types/node/lib/Glog.d.ts +228 -0
  41. package/types/node/lib/Glog.d.ts.map +1 -0
  42. package/types/node/lib/Logger.d.ts +46 -0
  43. package/types/node/lib/Logger.d.ts.map +1 -0
  44. package/types/node/lib/Notify.d.ts +54 -0
  45. package/types/node/lib/Notify.d.ts.map +1 -0
  46. package/types/node/lib/Sass.d.ts +9 -0
  47. package/types/node/lib/Sass.d.ts.map +1 -0
  48. package/types/node/lib/Tantrum.d.ts +9 -0
  49. package/types/node/lib/Tantrum.d.ts.map +1 -0
  50. package/types/node/lib/TempDirectoryObject.d.ts +42 -0
  51. package/types/node/lib/TempDirectoryObject.d.ts.map +1 -0
  52. package/types/node/lib/Term.d.ts +127 -0
  53. package/types/node/lib/Term.d.ts.map +1 -0
  54. package/types/node/lib/Util.d.ts +100 -0
  55. package/types/node/lib/Util.d.ts.map +1 -0
  56. package/types/node/lib/VDirectoryObject.d.ts +132 -0
  57. package/types/node/lib/VDirectoryObject.d.ts.map +1 -0
  58. package/types/node/lib/VFileObject.d.ts +33 -0
  59. package/types/node/lib/VFileObject.d.ts.map +1 -0
  60. package/types/node/lib/Valid.d.ts +35 -0
  61. package/types/node/lib/Valid.d.ts.map +1 -0
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "3.14.0",
8
+ "version": "3.14.1",
9
9
  "license": "Unlicense",
10
10
  "homepage": "https://github.com/gesslar/toolkit#readme",
11
11
  "repository": {
@@ -24,27 +24,28 @@
24
24
  "browser",
25
25
  "node"
26
26
  ],
27
- "main": "./src/index.js",
27
+ "main": "./src/node/index.js",
28
28
  "type": "module",
29
- "types": "./src/types/index.d.ts",
29
+ "types": "./types/node/index.d.ts",
30
30
  "exports": {
31
31
  ".": {
32
- "types": "./src/types/index.d.ts",
32
+ "types": "./types/node/index.d.ts",
33
33
  "browser": "./src/browser/index.js",
34
- "node": "./src/index.js",
35
- "default": "./src/index.js"
34
+ "node": "./src/node/index.js",
35
+ "default": "./src/node/index.js"
36
36
  },
37
37
  "./browser": {
38
- "types": "./src/types/index.d.ts",
38
+ "types": "./types/browser/index.d.ts",
39
39
  "default": "./src/browser/index.js"
40
40
  },
41
41
  "./node": {
42
- "types": "./src/types/index.d.ts",
43
- "default": "./src/index.js"
42
+ "types": "./types/node/index.d.ts",
43
+ "default": "./src/node/index.js"
44
44
  }
45
45
  },
46
46
  "files": [
47
47
  "src/",
48
+ "types/",
48
49
  "UNLICENSE.txt"
49
50
  ],
50
51
  "engines": {
@@ -0,0 +1,13 @@
1
+ export { default as Collection } from "./lib/Collection.js";
2
+ export { default as Data } from "./lib/Data.js";
3
+ export { default as Notify } from "./lib/Notify.js";
4
+ export { default as Promised } from "./lib/Promised.js";
5
+ export { default as Sass } from "./lib/Sass.js";
6
+ export { default as Tantrum } from "./lib/Tantrum.js";
7
+ export { default as Time } from "./lib/Time.js";
8
+ export { default as Type } from "./lib/TypeSpec.js";
9
+ export { default as Util } from "./lib/Util.js";
10
+ export { default as Valid } from "./lib/Valid.js";
11
+ export { default as Disposer, Disposer as DisposerClass } from "./lib/Disposer.js";
12
+ export { default as HTML, HTML as HTMLClass } from "./lib/HTML.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,248 @@
1
+ /**
2
+ * Utility class for collection operations.
3
+ * Provides static methods for working with arrays, objects, sets, and maps.
4
+ */
5
+ export default class Collection {
6
+ /**
7
+ * Evaluates an array with a predicate function, optionally in reverse order.
8
+ * Returns the first truthy result from the predicate.
9
+ *
10
+ * @param {Array<unknown>} collection - The array to evaluate
11
+ * @param {(value: unknown, index: number, array: Array<unknown>) => unknown} predicate - Function to evaluate each element
12
+ * @param {boolean} [forward] - Whether to iterate forward (true) or backward (false). Defaults to true
13
+ * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
14
+ * @throws {Sass} If collection is not an array or predicate is not a function
15
+ */
16
+ static evalArray(collection: Array<unknown>, predicate: (value: unknown, index: number, array: Array<unknown>) => unknown, forward?: boolean): unknown | undefined;
17
+ /**
18
+ * Evaluates an object with a predicate function.
19
+ * Returns the first truthy result from the predicate.
20
+ *
21
+ * @param {object} collection - The object to evaluate
22
+ * @param {(value: unknown, key: string, object: object) => unknown} predicate - Function to evaluate each property
23
+ * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
24
+ * @throws {Sass} If collection is not an object or predicate is not a function
25
+ */
26
+ static evalObject(collection: object, predicate: (value: unknown, key: string, object: object) => unknown): unknown | undefined;
27
+ /**
28
+ * Evaluates a Set with a predicate function.
29
+ * Returns the first truthy result from the predicate.
30
+ *
31
+ * @param {Set<unknown>} collection - The Set to evaluate
32
+ * @param {(value: unknown, set: Set<unknown>) => unknown} predicate - Function to evaluate each element
33
+ * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
34
+ * @throws {Sass} If collection is not a Set or predicate is not a function
35
+ */
36
+ static evalSet(collection: Set<unknown>, predicate: (value: unknown, set: Set<unknown>) => unknown): unknown | undefined;
37
+ /**
38
+ * Evaluates a Map with a predicate function, optionally in reverse order.
39
+ * Returns the first truthy result from the predicate.
40
+ *
41
+ * @param {Map<unknown, unknown>} collection - The Map to evaluate
42
+ * @param {(value: unknown, key: unknown, map: Map<unknown, unknown>) => unknown} predicate - Function to evaluate each entry
43
+ * @param {boolean} [forward] - Whether to iterate forward (true) or backward (false). Defaults to true
44
+ * @returns {unknown|undefined} The first truthy result from the predicate, or undefined
45
+ * @throws {Sass} If collection is not a Map or predicate is not a function
46
+ */
47
+ static evalMap(collection: Map<unknown, unknown>, predicate: (value: unknown, key: unknown, map: Map<unknown, unknown>) => unknown, forward?: boolean): unknown | undefined;
48
+ /**
49
+ * Zips two arrays together into an array of pairs.
50
+ * The resulting array length equals the shorter input array.
51
+ *
52
+ * @param {Array<unknown>} array1 - The first array
53
+ * @param {Array<unknown>} array2 - The second array
54
+ * @returns {Array<[unknown, unknown]>} Array of paired elements
55
+ */
56
+ static zip(array1: Array<unknown>, array2: Array<unknown>): Array<[unknown, unknown]>;
57
+ /**
58
+ * Unzips an array of pairs into separate arrays.
59
+ * Transposes a 2D array structure.
60
+ *
61
+ * @param {Array<Array<unknown>>} array - Array of arrays to unzip
62
+ * @returns {Array<Array<unknown>>} Array of unzipped arrays, or empty array for invalid input
63
+ */
64
+ static unzip(array: Array<Array<unknown>>): Array<Array<unknown>>;
65
+ /**
66
+ * Maps an array using an async function, processing items sequentially.
67
+ * Unlike Promise.all(array.map()), this processes one item at a time.
68
+ *
69
+ * @param {Array<unknown>} array - The array to map
70
+ * @param {(item: unknown) => Promise<unknown>} asyncFn - Async function to apply to each element
71
+ * @returns {Promise<Array<unknown>>} Promise resolving to the mapped array
72
+ * @throws {Sass} If array is not an Array or asyncFn is not a function
73
+ */
74
+ static asyncMap(array: Array<unknown>, asyncFn: (item: unknown) => Promise<unknown>): Promise<Array<unknown>>;
75
+ /**
76
+ * Checks if all elements in an array are of a specified type
77
+ *
78
+ * @param {Array<unknown>} arr - The array to check
79
+ * @param {string} [type] - The type to check for (optional, defaults to the type of the first element)
80
+ * @param {unknown} options - Options for checking types
81
+ * @param {boolean} [options.strict] - Whether to use strict type or looser TypeSpec checking
82
+ * @returns {boolean} Whether all elements are of the specified type
83
+ */
84
+ static isArrayUniform(arr: Array<unknown>, type?: string, options?: unknown): boolean;
85
+ /**
86
+ * Checks if an array is unique
87
+ *
88
+ * @param {Array<unknown>} arr - The array of which to remove duplicates
89
+ * @returns {Array<unknown>} The unique elements of the array
90
+ */
91
+ static isArrayUnique(arr: Array<unknown>): Array<unknown>;
92
+ /**
93
+ * Returns the intersection of two arrays.
94
+ *
95
+ * @param {Array<unknown>} arr1 - The first array.
96
+ * @param {Array<unknown>} arr2 - The second array.
97
+ * @returns {Array<unknown>} The intersection of the two arrays.
98
+ */
99
+ static intersection(arr1: Array<unknown>, arr2: Array<unknown>): Array<unknown>;
100
+ /**
101
+ * Checks whether two arrays have any elements in common.
102
+ *
103
+ * This function returns `true` if at least one element from `arr1` exists in
104
+ * `arr2`, and `false` otherwise. It optimizes by iterating over the shorter
105
+ * array for efficiency.
106
+ *
107
+ * Example:
108
+ * Collection.intersects([1, 2, 3], [3, 4, 5]) // returns true
109
+ * Collection.intersects(["a", "b"], ["c", "d"]) // returns false
110
+ *
111
+ * @param {Array<unknown>} arr1 - The first array to check for intersection.
112
+ * @param {Array<unknown>} arr2 - The second array to check for intersection.
113
+ * @returns {boolean} True if any element is shared between the arrays, false otherwise.
114
+ */
115
+ static intersects(arr1: Array<unknown>, arr2: Array<unknown>): boolean;
116
+ /**
117
+ * Pads an array to a specified length with a value. This operation
118
+ * occurs in-place.
119
+ *
120
+ * @param {Array<unknown>} arr - The array to pad.
121
+ * @param {number} length - The length to pad the array to.
122
+ * @param {unknown} value - The value to pad the array with.
123
+ * @param {number} [position] - The position to pad the array at. Defaults to 0
124
+ * @returns {Array<unknown>} The padded array.
125
+ */
126
+ static arrayPad(arr: Array<unknown>, length: number, value: unknown, position?: number): Array<unknown>;
127
+ /**
128
+ * Filters an array asynchronously using a predicate function.
129
+ * Applies the predicate to all items in parallel and returns filtered results.
130
+ *
131
+ * @param {Array<unknown>} arr - The array to filter
132
+ * @param {(value: unknown, index: number, array: Array<unknown>) => Promise<boolean>} predicate - Async predicate function that returns a promise resolving to boolean
133
+ * @returns {Promise<Array<unknown>>} Promise resolving to the filtered array
134
+ */
135
+ static asyncFilter(arr: Array<unknown>, predicate: (value: unknown, index: number, array: Array<unknown>) => Promise<boolean>): Promise<Array<unknown>>;
136
+ /**
137
+ * Clones an object
138
+ *
139
+ * @param {object} obj - The object to clone
140
+ * @param {boolean} freeze - Whether to freeze the cloned object
141
+ * @returns {object} The cloned object
142
+ */
143
+ static cloneObject(obj: object, freeze?: boolean): object;
144
+ /**
145
+ * Checks if an object is empty
146
+ *
147
+ * @param {object} obj - The object to check
148
+ * @returns {boolean} Whether the object is empty
149
+ */
150
+ static isObjectEmpty(obj: object): boolean;
151
+ /**
152
+ * Ensures that a nested path of objects exists within the given object.
153
+ * Creates empty objects along the path if they don't exist.
154
+ *
155
+ * @param {object} obj - The object to check/modify
156
+ * @param {Array<string>} keys - Array of keys representing the path to ensure
157
+ * @returns {object} Reference to the deepest nested object in the path
158
+ */
159
+ static assureObjectPath(obj: object, keys: Array<string>): object;
160
+ /**
161
+ * Sets a value in a nested object structure using an array of keys; creating
162
+ * the structure if it does not exist.
163
+ *
164
+ * @param {object} obj - The target object to set the value in
165
+ * @param {Array<string>} keys - Array of keys representing the path to the target property
166
+ * @param {unknown} value - The value to set at the target location
167
+ */
168
+ static setNestedValue(obj: object, keys: Array<string>, value: unknown): void;
169
+ /**
170
+ * Deeply merges two or more objects. Arrays are replaced, not merged.
171
+ *
172
+ * @param {...object} sources - Objects to merge (left to right)
173
+ * @returns {object} The merged object
174
+ */
175
+ static mergeObject(...sources: object[]): object;
176
+ /**
177
+ * Freezes an object and all of its properties recursively.
178
+ *
179
+ * @param {object} obj The object to freeze.
180
+ * @returns {object} The frozen object.
181
+ */
182
+ static deepFreezeObject(obj: object): object;
183
+ /**
184
+ * Maps an object using a transformer function
185
+ *
186
+ * @param {object} original The original object
187
+ * @param {function(unknown): unknown} transformer The transformer function
188
+ * @param {boolean} mutate Whether to mutate the original object
189
+ * @returns {Promise<object>} The mapped object
190
+ */
191
+ static mapObject(original: object, transformer: (arg0: unknown) => unknown, mutate?: boolean): Promise<object>;
192
+ /**
193
+ * Allocates an object from a source array and a spec array or function.
194
+ *
195
+ * @param {Array<unknown>} source The source array
196
+ * @param {Array<unknown>|function(Array<unknown>): Promise<Array<unknown>>|Array<unknown>} spec The spec array or function
197
+ * @returns {Promise<object>} The allocated object
198
+ */
199
+ static allocateObject(source: Array<unknown>, spec: Array<unknown> | ((arg0: Array<unknown>) => Promise<Array<unknown>> | Array<unknown>)): Promise<object>;
200
+ /**
201
+ * Trims falsy values from both ends of an array (in-place).
202
+ * Optionally preserves specific falsy values.
203
+ *
204
+ * @param {Array<unknown>} arr - The array to trim
205
+ * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
206
+ * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
207
+ * @throws {Sass} If arr is not an Array or except is not an Array
208
+ */
209
+ static trimArray(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
210
+ /**
211
+ * Trims falsy values from the right end of an array (in-place).
212
+ * Optionally preserves specific falsy values.
213
+ *
214
+ * @param {Array<unknown>} arr - The array to trim
215
+ * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
216
+ * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
217
+ * @throws {Sass} If arr is not an Array or except is not an Array
218
+ */
219
+ static trimArrayRight(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
220
+ /**
221
+ * Trims falsy values from the left end of an array (in-place).
222
+ * Optionally preserves specific falsy values.
223
+ *
224
+ * @param {Array<unknown>} arr - The array to trim
225
+ * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
226
+ * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
227
+ * @throws {Sass} If arr is not an Array or except is not an Array
228
+ */
229
+ static trimArrayLeft(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
230
+ /**
231
+ * Transposes an array of objects into an object of arrays.
232
+ * Collects values for each key across all objects into arrays.
233
+ *
234
+ * @param {Array<object>} objects - Array of plain objects to transpose
235
+ * @returns {object} Object with keys from input objects, values as arrays
236
+ * @throws {Sass} If objects is not an Array or contains non-plain objects
237
+ */
238
+ static transposeObjects(objects: Array<object>): object;
239
+ /**
240
+ * Flattens an array (or nested array) of objects and transposes them.
241
+ * Combines flat() and transposeObjects() operations.
242
+ *
243
+ * @param {Array<object>|Array<Array<object>>} input - Array or nested array of objects
244
+ * @returns {object} Transposed object with arrays of values
245
+ */
246
+ static flattenObjectArray(input: Array<object> | Array<Array<object>>): object;
247
+ }
248
+ //# sourceMappingURL=Collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Collection.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IACE;;;;;;;;;OASG;IACH,6BANW,KAAK,CAAC,OAAO,CAAC,aACd,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,YACjE,OAAO,GACL,OAAO,GAAC,SAAS,CAqB7B;IAED;;;;;;;;OAQG;IACH,8BALW,MAAM,aACN,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GACtD,OAAO,GAAC,SAAS,CAmB7B;IAED;;;;;;;;OAQG;IACH,2BALW,GAAG,CAAC,OAAO,CAAC,aACZ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,OAAO,GAC5C,OAAO,GAAC,SAAS,CAmB7B;IAED;;;;;;;;;OASG;IACH,2BANW,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,aACrB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,OAAO,YACrE,OAAO,GACL,OAAO,GAAC,SAAS,CAqB7B;IAED;;;;;;;OAOG;IACH,mBAJW,KAAK,CAAC,OAAO,CAAC,UACd,KAAK,CAAC,OAAO,CAAC,GACZ,KAAK,CAAC,CAAC,OAAO,EAA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class Data {
2
+ /**
3
+ * Array of JavaScript primitive type names.
4
+ * Includes basic types and object categories from the typeof operator.
5
+ *
6
+ * @type {Array<string>}
7
+ */
8
+ static primitives: Array<string>;
9
+ /**
10
+ * Array of JavaScript constructor names for built-in objects.
11
+ * Includes common object types and typed arrays.
12
+ *
13
+ * @type {Array<string>}
14
+ */
15
+ static constructors: Array<string>;
16
+ /**
17
+ * Combined array of all supported data types (primitives and constructors in
18
+ * lowercase).
19
+ *
20
+ * Used for type validation throughout the utility functions.
21
+ *
22
+ * @type {Array<string>}
23
+ */
24
+ static dataTypes: Array<string>;
25
+ /**
26
+ * Array of type names that can be checked for emptiness.
27
+ * These types have meaningful empty states that can be tested.
28
+ *
29
+ * @type {Array<string>}
30
+ */
31
+ static emptyableTypes: Array<string>;
32
+ /**
33
+ * Appends a string to another string if it does not already end with it.
34
+ *
35
+ * @param {string} string - The string to append to
36
+ * @param {string} append - The string to append
37
+ * @returns {string} The appended string
38
+ */
39
+ static append(string: string, append: string): string;
40
+ /**
41
+ * Prepends a string to another string if it does not already start with it.
42
+ *
43
+ * @param {string} string - The string to prepend to
44
+ * @param {string} prepend - The string to prepend
45
+ * @returns {string} The prepended string
46
+ */
47
+ static prepend(string: string, prepend: string): string;
48
+ /**
49
+ * Remove a suffix from the end of a string if present.
50
+ *
51
+ * @param {string} string - The string to process
52
+ * @param {string} toChop - The suffix to remove from the end
53
+ * @param {boolean} [caseInsensitive=false] - Whether to perform case-insensitive matching
54
+ * @returns {string} The string with suffix removed, or original if suffix not found
55
+ * @example
56
+ * Data.chopRight("hello.txt", ".txt") // "hello"
57
+ * Data.chopRight("Hello", "o") // "Hell"
58
+ * Data.chopRight("HELLO", "lo", true) // "HEL"
59
+ */
60
+ static chopRight(string: string, toChop: string, caseInsensitive?: boolean): string;
61
+ /**
62
+ * Remove a prefix from the beginning of a string if present.
63
+ *
64
+ * @param {string} string - The string to process
65
+ * @param {string} toChop - The prefix to remove from the beginning
66
+ * @param {boolean} [caseInsensitive=false] - Whether to perform case-insensitive matching
67
+ * @returns {string} The string with prefix removed, or original if prefix not found
68
+ * @example
69
+ * Data.chopLeft("hello.txt", "hello") // ".txt"
70
+ * Data.chopLeft("Hello", "H") // "ello"
71
+ * Data.chopLeft("HELLO", "he", true) // "LLO"
72
+ */
73
+ static chopLeft(string: string, toChop: string, caseInsensitive?: boolean): string;
74
+ /**
75
+ * Chop a string after the first occurence of another string.
76
+ *
77
+ * @param {string} string - The string to search
78
+ * @param {string} needle - The bit to chop after
79
+ * @param {boolean} caseInsensitive - Whether to search insensitive to case
80
+ * @returns {string} The remaining string
81
+ */
82
+ static chopAfter(string: string, needle: string, caseInsensitive?: boolean): string;
83
+ /**
84
+ * Chop a string before the first occurrence of another string.
85
+ *
86
+ * @param {string} string - The string to search
87
+ * @param {string} needle - The bit to chop before
88
+ * @param {boolean} caseInsensitive - Whether to search insensitive to case
89
+ * @returns {string} The remaining string
90
+ */
91
+ static chopBefore(string: string, needle: string, caseInsensitive?: boolean): string;
92
+ /**
93
+ * Creates a type spec from a string. A type spec is an array of objects
94
+ * defining the type of a value and whether an array is expected.
95
+ *
96
+ * @param {string} string - The string to parse into a type spec.
97
+ * @param {object} options - Additional options for parsing.
98
+ * @returns {Array<object>} An array of type specs.
99
+ */
100
+ static newTypeSpec(string: string, options: object): Array<object>;
101
+ /**
102
+ * Checks if a value is of a specified type
103
+ *
104
+ * @param {unknown} value The value to check
105
+ * @param {string|TypeSpec} type The type to check for
106
+ * @param {object} options Additional options for checking
107
+ * @returns {boolean} Whether the value is of the specified type
108
+ */
109
+ static isType(value: unknown, type: string | TypeSpec, options?: object): boolean;
110
+ /**
111
+ * Checks if a type is valid
112
+ *
113
+ * @param {string} type - The type to check
114
+ * @returns {boolean} Whether the type is valid
115
+ */
116
+ static isValidType(type: string): boolean;
117
+ /**
118
+ * Checks if a value is of a specified type. Unlike the type function, this
119
+ * function does not parse the type string, and only checks for primitive
120
+ * or constructor types.
121
+ *
122
+ * @param {unknown} value - The value to check
123
+ * @param {string} type - The type to check for
124
+ * @returns {boolean} Whether the value is of the specified type
125
+ */
126
+ static isBaseType(value: unknown, type: string): boolean;
127
+ /**
128
+ * Returns the type of a value, whether it be a primitive, object, or function.
129
+ *
130
+ * @param {unknown} value - The value to check
131
+ * @returns {string} The type of the value
132
+ */
133
+ static typeOf(value: unknown): string;
134
+ /**
135
+ * Checks a value is undefined or null.
136
+ *
137
+ * @param {unknown} value The value to check
138
+ * @returns {boolean} Whether the value is undefined or null
139
+ */
140
+ static isNothing(value: unknown): boolean;
141
+ /**
142
+ * Checks if a value is empty. This function is used to check if an object,
143
+ * array, or string is empty. Null and undefined values are considered empty.
144
+ *
145
+ * @param {unknown} value The value to check
146
+ * @param {boolean} checkForNothing Whether to check for null or undefined
147
+ * values
148
+ * @returns {boolean} Whether the value is empty
149
+ */
150
+ static isEmpty(value: unknown, checkForNothing?: boolean): boolean;
151
+ /**
152
+ * Freezes an object and all of its properties recursively.
153
+ *
154
+ * @param {object} obj The object to freeze.
155
+ * @returns {object} The frozen object.
156
+ */
157
+ static deepFreezeObject(obj: object): object;
158
+ /**
159
+ * Ensures that a nested path of objects exists within the given object.
160
+ * Creates empty objects along the path if they don't exist.
161
+ *
162
+ * @param {object} obj - The object to check/modify
163
+ * @param {Array<string>} keys - Array of keys representing the path to ensure
164
+ * @returns {object} Reference to the deepest nested object in the path
165
+ */
166
+ static assureObjectPath(obj: object, keys: Array<string>): object;
167
+ /**
168
+ * Sets a value in a nested object structure using an array of keys; creating
169
+ * the structure if it does not exist.
170
+ *
171
+ * @param {object} obj - The target object to set the value in
172
+ * @param {Array<string>} keys - Array of keys representing the path to the target property
173
+ * @param {unknown} value - The value to set at the target location
174
+ */
175
+ static setNestedValue(obj: object, keys: Array<string>, value: unknown): void;
176
+ /**
177
+ * Deeply merges two or more objects. Arrays are replaced, not merged.
178
+ *
179
+ * @param {...object} sources - Objects to merge (left to right)
180
+ * @returns {object} The merged object
181
+ */
182
+ static mergeObject(...sources: object[]): object;
183
+ /**
184
+ * Filters an array asynchronously using a predicate function.
185
+ * Applies the predicate to all items in parallel and returns filtered results.
186
+ *
187
+ * @param {Array<unknown>} arr - The array to filter
188
+ * @param {(value: unknown) => Promise<boolean>} predicate - Async predicate function that returns a promise resolving to boolean
189
+ * @returns {Promise<Array<unknown>>} Promise resolving to the filtered array
190
+ */
191
+ static asyncFilter(arr: Array<unknown>, predicate: (value: unknown) => Promise<boolean>): Promise<Array<unknown>>;
192
+ /**
193
+ * Ensures a value is within a specified range.
194
+ *
195
+ * @param {number} val - The value to check.
196
+ * @param {number} min - The minimum value.
197
+ * @param {number} max - The maximum value.
198
+ * @returns {number} The value, constrained within the range of `min` to `max`.
199
+ */
200
+ static clamp(val: number, min: number, max: number): number;
201
+ /**
202
+ * Checks if a value is within a specified range (inclusive).
203
+ *
204
+ * @param {number} val - The value to check.
205
+ * @param {number} min - The minimum value (inclusive).
206
+ * @param {number} max - The maximum value (inclusive).
207
+ * @returns {boolean} True if the value is within the range, false otherwise.
208
+ */
209
+ static clamped(val: number, min: number, max: number): boolean;
210
+ /**
211
+ * Checks if a value is a plain object - created with object literals {},
212
+ * new Object(), or Object.create(null).
213
+ *
214
+ * Distinguishes plain objects from objects created by custom constructors, built-ins,
215
+ * or primitives. Plain objects only have Object.prototype or null in their prototype chain.
216
+ *
217
+ * @param {unknown} value - The value to check
218
+ * @returns {boolean} True if the value is a plain object, false otherwise
219
+ *
220
+ * @example
221
+ * isPlainObject({}) // true
222
+ * isPlainObject(new Object()) // true
223
+ * isPlainObject(Object.create(null)) // true
224
+ * isPlainObject([]) // false
225
+ * isPlainObject(new Date()) // false
226
+ * isPlainObject(null) // false
227
+ * isPlainObject("string") // false
228
+ * isPlainObject(class Person{}) // false
229
+ */
230
+ static isPlainObject(value: unknown): boolean;
231
+ /**
232
+ * Checks if a value is binary data.
233
+ * Returns true for ArrayBuffer, TypedArrays (Uint8Array, Int16Array, etc.),
234
+ * Blob, and Node Buffer instances.
235
+ *
236
+ * @param {unknown} value - The value to check
237
+ * @returns {boolean} True if the value is binary data, false otherwise
238
+ * @example
239
+ * Data.isBinary(new Uint8Array([1, 2, 3])) // true
240
+ * Data.isBinary(new ArrayBuffer(10)) // true
241
+ * Data.isBinary(Buffer.from('hello')) // true
242
+ * Data.isBinary(new Blob(['text'])) // true
243
+ * Data.isBinary('string') // false
244
+ * Data.isBinary({}) // false
245
+ * Data.isBinary(undefined) // false
246
+ */
247
+ static isBinary(value: unknown): boolean;
248
+ }
249
+ import TypeSpec from "./TypeSpec.js";
250
+ //# sourceMappingURL=Data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Data.js"],"names":[],"mappings":"AAUA;IACA;;;;;OAKG;IACD,mBAFQ,KAAK,CAAC,MAAM,CAAC,CAgBnB;IAEF;;;;;OAKG;IACH,qBAFU,KAAK,CAAC,MAAM,CAAC,CAmBrB;IAEF;;;;;;;OAOG;IACH,kBAFU,KAAK,CAAC,MAAM,CAAC,CAKrB;IAEF;;;;;OAKG;IACH,uBAFU,KAAK,CAAC,MAAM,CAAC,CAE2D;IAElF;;;;;;OAMG;IACH,sBAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;OAMG;IACH,uBAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;;;OAWG;IACH,yBATW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;;;;;OAWG;IACH,wBATW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,yBALW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,0BALW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAYlB;IAED;;;;;;;OAOG;IACH,2BAJW,MAAM,WACN,MAAM,GACJ,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;;;OAOG;IACH,qBALW,OAAO,QACP,MAAM,GAAC,QAAQ,YACf,MAAM,GACJ,OAAO,CAQnB;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GACJ,OAAO,CASnB;IAED;;;;;;;;OAQG;IACH,yBAJW,OAAO,QACP,MAAM,GACJ,OAAO,CAwBnB;IAED;;;;;OAKG;IACH,qBAHW,OAAO,GACL,MAAM,CAclB;IAED;;;;;OAKG;IACH,wBAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;;;;;OAQG;IACH,sBALW,OAAO,oBACP,OAAO,GAEL,OAAO,CA8BnB;IAED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,QACN,KAAK,CAAC,MAAM,CAAC,GACX,MAAM,CAiBlB;IAED;;;;;;;OAOG;IACH,2BAJW,MAAM,QACN,KAAK,CAAC,MAAM,CAAC,SACb,OAAO,QAMjB;IAED;;;;;OAKG;IACH,+BAHc,MAAM,EAAA,GACP,MAAM,CAqBlB;IAED;;;;;;;OAOG;IACH,wBAJW,KAAK,CAAC,OAAO,CAAC,aACd,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAClC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAMnC;IAED;;;;;;;OAOG;IACH,kBALW,MAAM,OACN,MAAM,OACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,oBALW,MAAM,OACN,MAAM,OACN,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,4BAbW,OAAO,GACL,OAAO,CA+BnB;IAED;;;;;;;;;;;;;;;OAeG;IACH,uBAXW,OAAO,GACL,OAAO,CAgBnB;CACF;qBAhgBoB,eAAe"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Simple lifecycle helper that tracks disposer callbacks.
3
+ * Register any teardown functions and call dispose() to run them in reverse.
4
+ */
5
+ export class Disposer {
6
+ /**
7
+ * Registers a disposer callback to be executed when disposed.
8
+ *
9
+ * Accepts one or more callbacks (or a single array) and returns matching
10
+ * unregisters. A single disposer returns a single unregister for
11
+ * convenience.
12
+ *
13
+ * @param {...(() => void)|Array<() => void>} disposers - Cleanup callbacks.
14
+ * @returns {(() => void)|Array<() => void>} Unregister function(s).
15
+ */
16
+ register(...disposers: ((() => void) | Array<() => void>)[]): (() => void) | Array<() => void>;
17
+ /**
18
+ * Runs all registered disposers in reverse order.
19
+ *
20
+ * @returns {void}
21
+ */
22
+ dispose(): void;
23
+ /**
24
+ * Read-only list of registered disposers.
25
+ *
26
+ * @returns {Array<() => void>} Snapshot of disposer callbacks.
27
+ */
28
+ get disposers(): Array<() => void>;
29
+ #private;
30
+ }
31
+ declare const _default: Disposer;
32
+ export default _default;
33
+ //# sourceMappingURL=Disposer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Disposer.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Disposer.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IAGE;;;;;;;;;OASG;IACH,uBAHW,CAAG,CAAC,MAAM,IAAI,CAAC,GAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAA,GAC/B,CAAC,MAAM,IAAI,CAAC,GAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAS1C;IAWD;;;;OAIG;IACH,WAFa,IAAI,CAehB;IAcD;;;;OAIG;IACH,iBAFa,KAAK,CAAC,MAAM,IAAI,CAAC,CAI7B;;CAQF"}
@@ -0,0 +1,40 @@
1
+ export class HTML {
2
+ /**
3
+ * Lightweight HTML helper utilities for browser contexts.
4
+ *
5
+ * @param {object|(() => unknown)} domPurify - Optional DOMPurify instance or factory.
6
+ */
7
+ constructor(domPurify?: object | (() => unknown));
8
+ /**
9
+ * Fetches an HTML fragment and returns the contents inside the <body> tag when present.
10
+ *
11
+ * @param {string} url - Location of the HTML resource to load.
12
+ * @param {boolean} filterBodyContent - If true, returns only content found between the <body> tags. Defaults to false.
13
+ * @returns {Promise<string>} Sanitized HTML string or empty string on missing content.
14
+ */
15
+ loadHTML(url: string, filterBodyContent?: boolean): Promise<string>;
16
+ /**
17
+ * Sanitizes arbitrary HTML using DOMPurify.
18
+ *
19
+ * @param {string} text - HTML string to sanitize. Defaults to "".
20
+ * @returns {string} Sanitized HTML.
21
+ */
22
+ sanitise(text?: string): string;
23
+ /**
24
+ * Sanitizes an HTML string and replaces the element's children with the result.
25
+ *
26
+ * @param {Element} element - Target element to replace content within.
27
+ * @param {string} htmlString - HTML string to sanitize and insert.
28
+ */
29
+ setHTMLContent(element: Element, htmlString: string): void;
30
+ /**
31
+ * Removes all child nodes from the given element.
32
+ *
33
+ * @param {Element} element - Element to clear.
34
+ */
35
+ clearHTMLContent(element: Element): void;
36
+ #private;
37
+ }
38
+ declare const _default: HTML;
39
+ export default _default;
40
+ //# sourceMappingURL=HTML.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/HTML.js"],"names":[],"mappings":"AAGA;IAGE;;;;OAIG;IACH,wBAFW,MAAM,GAAC,CAAC,MAAM,OAAO,CAAC,EAIhC;IAED;;;;;;OAMG;IACH,cAJW,MAAM,sBACN,OAAO,GACL,OAAO,CAAC,MAAM,CAAC,CAmB3B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,wBAHW,OAAO,cACP,MAAM,QA+BhB;IAED;;;;OAIG;IACH,0BAFW,OAAO,QAmBjB;;CAwBF"}