@gesslar/toolkit 1.5.0 → 1.6.0

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 (46) hide show
  1. package/package.json +2 -2
  2. package/src/browser/lib/Data.js +0 -7
  3. package/src/browser/lib/Disposer.js +1 -24
  4. package/src/browser/lib/Util.js +1 -11
  5. package/src/types/browser/lib/Data.d.ts.map +1 -1
  6. package/src/types/browser/lib/Disposer.d.ts +0 -6
  7. package/src/types/browser/lib/Disposer.d.ts.map +1 -1
  8. package/src/types/browser/lib/Util.d.ts +0 -1
  9. package/src/types/browser/lib/Util.d.ts.map +1 -1
  10. package/src/browser/lib/Hook.js +0 -82
  11. package/src/browser/lib/test.js +0 -25
  12. package/src/browser/lib/test2.js +0 -46
  13. package/src/types/Cache.d.ts +0 -30
  14. package/src/types/Collection.d.ts +0 -321
  15. package/src/types/Contract.d.ts +0 -162
  16. package/src/types/Data.d.ts +0 -175
  17. package/src/types/DirectoryObject.d.ts +0 -135
  18. package/src/types/FS.d.ts +0 -40
  19. package/src/types/FileObject.d.ts +0 -388
  20. package/src/types/Glog.d.ts +0 -345
  21. package/src/types/Sass.d.ts +0 -24
  22. package/src/types/Schemer.d.ts +0 -179
  23. package/src/types/Tantrum.d.ts +0 -81
  24. package/src/types/Term.d.ts +0 -16
  25. package/src/types/Terms.d.ts +0 -145
  26. package/src/types/Type.d.ts +0 -26
  27. package/src/types/Util.d.ts +0 -275
  28. package/src/types/Valid.d.ts +0 -13
  29. package/src/types/browser/lib/Disposable.d.ts +0 -35
  30. package/src/types/browser/lib/Disposable.d.ts.map +0 -10
  31. package/src/types/browser/lib/Hook.d.ts +0 -11
  32. package/src/types/browser/lib/Hook.d.ts.map +0 -1
  33. package/src/types/browser/lib/test.d.ts +0 -2
  34. package/src/types/browser/lib/test.d.ts.map +0 -1
  35. package/src/types/browser/lib/test2.d.ts +0 -2
  36. package/src/types/browser/lib/test2.d.ts.map +0 -1
  37. package/src/types/lib/Chide.d.ts +0 -37
  38. package/src/types/lib/Chide.d.ts.map +0 -1
  39. package/src/types/lib/Collection.d.ts +0 -246
  40. package/src/types/lib/Collection.d.ts.map +0 -1
  41. package/src/types/lib/Data.d.ts +0 -206
  42. package/src/types/lib/Data.d.ts.map +0 -1
  43. package/src/types/lib/Disposable.d.ts +0 -33
  44. package/src/types/lib/Disposable.d.ts.map +0 -10
  45. package/src/types/lib/TypeSpec.d.ts +0 -92
  46. package/src/types/lib/TypeSpec.d.ts.map +0 -1
@@ -1,246 +0,0 @@
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
- * @returns {boolean} Whether all elements are of the specified type
81
- */
82
- static isArrayUniform(arr: Array<unknown>, type?: string): boolean;
83
- /**
84
- * Checks if an array is unique
85
- *
86
- * @param {Array<unknown>} arr - The array of which to remove duplicates
87
- * @returns {Array<unknown>} The unique elements of the array
88
- */
89
- static isArrayUnique(arr: Array<unknown>): Array<unknown>;
90
- /**
91
- * Returns the intersection of two arrays.
92
- *
93
- * @param {Array<unknown>} arr1 - The first array.
94
- * @param {Array<unknown>} arr2 - The second array.
95
- * @returns {Array<unknown>} The intersection of the two arrays.
96
- */
97
- static intersection(arr1: Array<unknown>, arr2: Array<unknown>): Array<unknown>;
98
- /**
99
- * Checks whether two arrays have any elements in common.
100
- *
101
- * This function returns `true` if at least one element from `arr1` exists in
102
- * `arr2`, and `false` otherwise. It optimizes by iterating over the shorter
103
- * array for efficiency.
104
- *
105
- * Example:
106
- * Collection.intersects([1, 2, 3], [3, 4, 5]) // returns true
107
- * Collection.intersects(["a", "b"], ["c", "d"]) // returns false
108
- *
109
- * @param {Array<unknown>} arr1 - The first array to check for intersection.
110
- * @param {Array<unknown>} arr2 - The second array to check for intersection.
111
- * @returns {boolean} True if any element is shared between the arrays, false otherwise.
112
- */
113
- static intersects(arr1: Array<unknown>, arr2: Array<unknown>): boolean;
114
- /**
115
- * Pads an array to a specified length with a value. This operation
116
- * occurs in-place.
117
- *
118
- * @param {Array<unknown>} arr - The array to pad.
119
- * @param {number} length - The length to pad the array to.
120
- * @param {unknown} value - The value to pad the array with.
121
- * @param {number} [position] - The position to pad the array at. Defaults to 0
122
- * @returns {Array<unknown>} The padded array.
123
- */
124
- static arrayPad(arr: Array<unknown>, length: number, value: unknown, position?: number): Array<unknown>;
125
- /**
126
- * Filters an array asynchronously using a predicate function.
127
- * Applies the predicate to all items in parallel and returns filtered results.
128
- *
129
- * @param {Array<unknown>} arr - The array to filter
130
- * @param {(value: unknown, index: number, array: Array<unknown>) => Promise<boolean>} predicate - Async predicate function that returns a promise resolving to boolean
131
- * @returns {Promise<Array<unknown>>} Promise resolving to the filtered array
132
- */
133
- static asyncFilter(arr: Array<unknown>, predicate: (value: unknown, index: number, array: Array<unknown>) => Promise<boolean>): Promise<Array<unknown>>;
134
- /**
135
- * Clones an object
136
- *
137
- * @param {object} obj - The object to clone
138
- * @param {boolean} freeze - Whether to freeze the cloned object
139
- * @returns {object} The cloned object
140
- */
141
- static cloneObject(obj: object, freeze?: boolean): object;
142
- /**
143
- * Checks if an object is empty
144
- *
145
- * @param {object} obj - The object to check
146
- * @returns {boolean} Whether the object is empty
147
- */
148
- static isObjectEmpty(obj: object): boolean;
149
- /**
150
- * Ensures that a nested path of objects exists within the given object.
151
- * Creates empty objects along the path if they don't exist.
152
- *
153
- * @param {object} obj - The object to check/modify
154
- * @param {Array<string>} keys - Array of keys representing the path to ensure
155
- * @returns {object} Reference to the deepest nested object in the path
156
- */
157
- static assureObjectPath(obj: object, keys: Array<string>): object;
158
- /**
159
- * Sets a value in a nested object structure using an array of keys; creating
160
- * the structure if it does not exist.
161
- *
162
- * @param {object} obj - The target object to set the value in
163
- * @param {Array<string>} keys - Array of keys representing the path to the target property
164
- * @param {unknown} value - The value to set at the target location
165
- */
166
- static setNestedValue(obj: object, keys: Array<string>, value: unknown): void;
167
- /**
168
- * Deeply merges two or more objects. Arrays are replaced, not merged.
169
- *
170
- * @param {...object} sources - Objects to merge (left to right)
171
- * @returns {object} The merged object
172
- */
173
- static mergeObject(...sources: object[]): object;
174
- /**
175
- * Freezes an object and all of its properties recursively.
176
- *
177
- * @param {object} obj The object to freeze.
178
- * @returns {object} The frozen object.
179
- */
180
- static deepFreezeObject(obj: object): object;
181
- /**
182
- * Maps an object using a transformer function
183
- *
184
- * @param {object} original The original object
185
- * @param {function(unknown): unknown} transformer The transformer function
186
- * @param {boolean} mutate Whether to mutate the original object
187
- * @returns {Promise<object>} The mapped object
188
- */
189
- static mapObject(original: object, transformer: (arg0: unknown) => unknown, mutate?: boolean): Promise<object>;
190
- /**
191
- * Allocates an object from a source array and a spec array or function.
192
- *
193
- * @param {unknown} source The source array
194
- * @param {Array<unknown>|function(Array<unknown>): Promise<Array<unknown>>|Array<unknown>} spec The spec array or function
195
- * @returns {Promise<object>} The allocated object
196
- */
197
- static allocateObject(source: unknown, spec: Array<unknown> | ((arg0: Array<unknown>) => Promise<Array<unknown>> | Array<unknown>)): Promise<object>;
198
- /**
199
- * Trims falsy values from both ends of an array (in-place).
200
- * Optionally preserves specific falsy values.
201
- *
202
- * @param {Array<unknown>} arr - The array to trim
203
- * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
204
- * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
205
- * @throws {Sass} If arr is not an Array or except is not an Array
206
- */
207
- static trimArray(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
208
- /**
209
- * Trims falsy values from the right end of an array (in-place).
210
- * Optionally preserves specific falsy values.
211
- *
212
- * @param {Array<unknown>} arr - The array to trim
213
- * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
214
- * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
215
- * @throws {Sass} If arr is not an Array or except is not an Array
216
- */
217
- static trimArrayRight(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
218
- /**
219
- * Trims falsy values from the left end of an array (in-place).
220
- * Optionally preserves specific falsy values.
221
- *
222
- * @param {Array<unknown>} arr - The array to trim
223
- * @param {Array<unknown>} [except] - Values to preserve even if falsy. Defaults to empty array
224
- * @returns {Array<unknown>} The trimmed array (same reference, modified in-place)
225
- * @throws {Sass} If arr is not an Array or except is not an Array
226
- */
227
- static trimArrayLeft(arr: Array<unknown>, except?: Array<unknown>): Array<unknown>;
228
- /**
229
- * Transposes an array of objects into an object of arrays.
230
- * Collects values for each key across all objects into arrays.
231
- *
232
- * @param {Array<object>} objects - Array of plain objects to transpose
233
- * @returns {object} Object with keys from input objects, values as arrays
234
- * @throws {Sass} If objects is not an Array or contains non-plain objects
235
- */
236
- static transposeObjects(objects: Array<object>): object;
237
- /**
238
- * Flattens an array (or nested array) of objects and transposes them.
239
- * Combines flat() and transposeObjects() operations.
240
- *
241
- * @param {Array<object>|Array<Array<object>>} input - Array or nested array of objects
242
- * @returns {object} Transposed object with arrays of values
243
- */
244
- static flattenObjectArray(input: Array<object> | Array<Array<object>>): object;
245
- }
246
- //# sourceMappingURL=Collection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../lib/Collection.js"],"names":[],"mappings":"AAaA;;;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,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AAC,CAAC,GAChC,MAAM,CAMlB;CACF"}
@@ -1,206 +0,0 @@
1
- export default 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 appendString(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 prependString(string: string, prepend: string): string;
48
- /**
49
- * Creates a type spec from a string. A type spec is an array of objects
50
- * defining the type of a value and whether an array is expected.
51
- *
52
- * @param {string} string - The string to parse into a type spec.
53
- * @param {object} options - Additional options for parsing.
54
- * @returns {Array<object>} An array of type specs.
55
- */
56
- static newTypeSpec(string: string, options: object): Array<object>;
57
- /**
58
- * Checks if a value is of a specified type
59
- *
60
- * @param {unknown} value The value to check
61
- * @param {string|TypeSpec} type The type to check for
62
- * @param {object} options Additional options for checking
63
- * @returns {boolean} Whether the value is of the specified type
64
- */
65
- static isType(value: unknown, type: string | TypeSpec, options?: object): boolean;
66
- /**
67
- * Checks if a type is valid
68
- *
69
- * @param {string} type - The type to check
70
- * @returns {boolean} Whether the type is valid
71
- */
72
- static isValidType(type: string): boolean;
73
- /**
74
- * Checks if a value is of a specified type. Unlike the type function, this
75
- * function does not parse the type string, and only checks for primitive
76
- * or constructor types.
77
- *
78
- * @param {unknown} value - The value to check
79
- * @param {string} type - The type to check for
80
- * @returns {boolean} Whether the value is of the specified type
81
- */
82
- static isBaseType(value: unknown, type: string): boolean;
83
- /**
84
- * Returns the type of a value, whether it be a primitive, object, or function.
85
- *
86
- * @param {unknown} value - The value to check
87
- * @returns {string} The type of the value
88
- */
89
- static typeOf(value: unknown): string;
90
- /**
91
- * Checks a value is undefined or null.
92
- *
93
- * @param {unknown} value The value to check
94
- * @returns {boolean} Whether the value is undefined or null
95
- */
96
- static isNothing(value: unknown): boolean;
97
- /**
98
- * Checks if a value is empty. This function is used to check if an object,
99
- * array, or string is empty. Null and undefined values are considered empty.
100
- *
101
- * @param {unknown} value The value to check
102
- * @param {boolean} checkForNothing Whether to check for null or undefined
103
- * values
104
- * @returns {boolean} Whether the value is empty
105
- */
106
- static isEmpty(value: unknown, checkForNothing?: boolean): boolean;
107
- /**
108
- * Freezes an object and all of its properties recursively.
109
- *
110
- * @param {object} obj The object to freeze.
111
- * @returns {object} The frozen object.
112
- */
113
- static deepFreezeObject(obj: object): object;
114
- /**
115
- * Ensures that a nested path of objects exists within the given object.
116
- * Creates empty objects along the path if they don't exist.
117
- *
118
- * @param {object} obj - The object to check/modify
119
- * @param {Array<string>} keys - Array of keys representing the path to ensure
120
- * @returns {object} Reference to the deepest nested object in the path
121
- */
122
- static assureObjectPath(obj: object, keys: Array<string>): object;
123
- /**
124
- * Sets a value in a nested object structure using an array of keys; creating
125
- * the structure if it does not exist.
126
- *
127
- * @param {object} obj - The target object to set the value in
128
- * @param {Array<string>} keys - Array of keys representing the path to the target property
129
- * @param {unknown} value - The value to set at the target location
130
- */
131
- static setNestedValue(obj: object, keys: Array<string>, value: unknown): void;
132
- /**
133
- * Deeply merges two or more objects. Arrays are replaced, not merged.
134
- *
135
- * @param {...object} sources - Objects to merge (left to right)
136
- * @returns {object} The merged object
137
- */
138
- static mergeObject(...sources: object[]): object;
139
- /**
140
- * Filters an array asynchronously using a predicate function.
141
- * Applies the predicate to all items in parallel and returns filtered results.
142
- *
143
- * @param {Array<unknown>} arr - The array to filter
144
- * @param {(value: unknown) => Promise<boolean>} predicate - Async predicate function that returns a promise resolving to boolean
145
- * @returns {Promise<Array<unknown>>} Promise resolving to the filtered array
146
- */
147
- static asyncFilter(arr: Array<unknown>, predicate: (value: unknown) => Promise<boolean>): Promise<Array<unknown>>;
148
- /**
149
- * Ensures a value is within a specified range.
150
- *
151
- * @param {number} val - The value to check.
152
- * @param {number} min - The minimum value.
153
- * @param {number} max - The maximum value.
154
- * @returns {number} The value, constrained within the range of `min` to `max`.
155
- */
156
- static clamp(val: number, min: number, max: number): number;
157
- /**
158
- * Checks if a value is within a specified range (inclusive).
159
- *
160
- * @param {number} val - The value to check.
161
- * @param {number} min - The minimum value (inclusive).
162
- * @param {number} max - The maximum value (inclusive).
163
- * @returns {boolean} True if the value is within the range, false otherwise.
164
- */
165
- static clamped(val: number, min: number, max: number): boolean;
166
- /**
167
- * Checks if a value is a plain object - created with object literals {},
168
- * new Object(), or Object.create(null).
169
- *
170
- * Distinguishes plain objects from objects created by custom constructors, built-ins,
171
- * or primitives. Plain objects only have Object.prototype or null in their prototype chain.
172
- *
173
- * @param {unknown} value - The value to check
174
- * @returns {boolean} True if the value is a plain object, false otherwise
175
- *
176
- * @example
177
- * isPlainObject({}) // true
178
- * isPlainObject(new Object()) // true
179
- * isPlainObject(Object.create(null)) // true
180
- * isPlainObject([]) // false
181
- * isPlainObject(new Date()) // false
182
- * isPlainObject(null) // false
183
- * isPlainObject("string") // false
184
- * isPlainObject(class Person{}) // false
185
- */
186
- static isPlainObject(value: unknown): boolean;
187
- /**
188
- * Checks if a value is binary data.
189
- * Returns true for ArrayBuffer, TypedArrays (Uint8Array, Int16Array, etc.),
190
- * Blob, and Node Buffer instances.
191
- *
192
- * @param {unknown} value - The value to check
193
- * @returns {boolean} True if the value is binary data, false otherwise
194
- * @example
195
- * Data.isBinary(new Uint8Array([1, 2, 3])) // true
196
- * Data.isBinary(new ArrayBuffer(10)) // true
197
- * Data.isBinary(Buffer.from('hello')) // true
198
- * Data.isBinary(new Blob(['text'])) // true
199
- * Data.isBinary('string') // false
200
- * Data.isBinary({}) // false
201
- * Data.isBinary(undefined) // false
202
- */
203
- static isBinary(value: unknown): boolean;
204
- }
205
- import TypeSpec from "./TypeSpec.js";
206
- //# sourceMappingURL=Data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../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,CAE6C;IAEpE;;;;;;OAMG;IACH,4BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAIlB;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,CA2BnB;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;qBA5aoB,eAAe"}
@@ -1,33 +0,0 @@
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 default class Disposer {
6
- /**
7
- * Registers a disposer callback to be executed when disposed.
8
- *
9
- * @param {...(() => void)|Array<() => void>} disposers - Cleanup callbacks.
10
- * @returns {(() => void)|Array<() => void>} Function(s) to unregister the disposer(s).
11
- */
12
- register(...disposers: Array<(() => void) | Array<() => void>>): (() => void) | Array<() => void>;
13
- /**
14
- * Runs all registered disposers in reverse order.
15
- *
16
- * @returns {void}
17
- */
18
- dispose(): void;
19
- /**
20
- * Whether disposal has run.
21
- *
22
- * @returns {boolean} True when dispose() has already been called.
23
- */
24
- get disposed(): boolean;
25
- /**
26
- * Read-only list of registered disposers.
27
- *
28
- * @returns {Array<() => void>} Snapshot of disposer callbacks.
29
- */
30
- get disposers(): Array<() => void>;
31
- #private;
32
- }
33
- //# sourceMappingURL=Disposer.d.ts.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "file": "Disposer.d.ts",
4
- "sourceRoot": "",
5
- "sources": [
6
- "../../lib/Disposer.js"
7
- ],
8
- "names": [],
9
- "mappings": "AAAA;;;GAGG;AACH;IAIE;;;;;OAKG;IACH,2BAHW,MAAM,IAAI,GACR,MAAM,IAAI,CAStB;IAED;;;;OAIG;IACH,WAFa,IAAI,CAoBhB;IAED;;;;OAIG;IACH,gBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,iBAFa,KAAK,CAAC,MAAM,IAAI,CAAC,CAI7B;;CAQF"
10
- }
@@ -1,92 +0,0 @@
1
- /**
2
- * Type specification class for parsing and validating complex type definitions.
3
- * Supports union types, array types, and validation options.
4
- */
5
- export default class TypeSpec {
6
- /**
7
- * Creates a new TypeSpec instance.
8
- *
9
- * @param {string} string - The type specification string (e.g., "string|number", "object[]")
10
- * @param {object} options - Additional parsing options
11
- */
12
- constructor(string: string, options: object);
13
- specs: any[];
14
- length: number;
15
- stringRepresentation: string;
16
- /**
17
- * Returns a string representation of the type specification.
18
- *
19
- * @returns {string} The type specification as a string (e.g., "string|number[]")
20
- */
21
- toString(): string;
22
- /**
23
- * Returns a JSON representation of the TypeSpec.
24
- *
25
- * @returns {object} Object containing specs, length, and string representation
26
- */
27
- toJSON(): object;
28
- /**
29
- * Executes a provided function once for each type specification.
30
- *
31
- * @param {function(unknown): void} callback - Function to execute for each spec
32
- */
33
- forEach(callback: (arg0: unknown) => void): void;
34
- /**
35
- * Tests whether all type specifications pass the provided test function.
36
- *
37
- * @param {function(unknown): boolean} callback - Function to test each spec
38
- * @returns {boolean} True if all specs pass the test
39
- */
40
- every(callback: (arg0: unknown) => boolean): boolean;
41
- /**
42
- * Tests whether at least one type specification passes the provided test function.
43
- *
44
- * @param {function(unknown): boolean} callback - Function to test each spec
45
- * @returns {boolean} True if at least one spec passes the test
46
- */
47
- some(callback: (arg0: unknown) => boolean): boolean;
48
- /**
49
- * Creates a new array with all type specifications that pass the provided test function.
50
- *
51
- * @param {function(unknown): boolean} callback - Function to test each spec
52
- * @returns {Array<unknown>} New array with filtered specs
53
- */
54
- filter(callback: (arg0: unknown) => boolean): Array<unknown>;
55
- /**
56
- * Creates a new array populated with the results of calling the provided function on every spec.
57
- *
58
- * @param {function(unknown): unknown} callback - Function to call on each spec
59
- * @returns {Array<unknown>} New array with mapped values
60
- */
61
- map(callback: (arg0: unknown) => unknown): Array<unknown>;
62
- /**
63
- * Executes a reducer function on each spec, resulting in a single output value.
64
- *
65
- * @param {function(unknown, unknown): unknown} callback - Function to execute on each spec
66
- * @param {unknown} initialValue - Initial value for the accumulator
67
- * @returns {unknown} The final accumulated value
68
- */
69
- reduce(callback: (arg0: unknown, arg1: unknown) => unknown, initialValue: unknown): unknown;
70
- /**
71
- * Returns the first type specification that satisfies the provided testing function.
72
- *
73
- * @param {function(unknown): boolean} callback - Function to test each spec
74
- * @returns {object|undefined} The first spec that matches, or undefined
75
- */
76
- find(callback: (arg0: unknown) => boolean): object | undefined;
77
- /**
78
- * Tests whether a value matches any of the type specifications.
79
- * Handles array types, union types, and empty value validation.
80
- *
81
- * @param {unknown} value - The value to test against the type specifications
82
- * @param {object} options - Validation options
83
- * @param {boolean} options.allowEmpty - Whether empty values are allowed
84
- * @returns {boolean} True if the value matches any type specification
85
- */
86
- matches(value: unknown, options: {
87
- allowEmpty: boolean;
88
- }): boolean;
89
- match(value: any, options: any): unknown[];
90
- #private;
91
- }
92
- //# sourceMappingURL=TypeSpec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../lib/TypeSpec.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAGE;;;;;OAKG;IACH,oBAHW,MAAM,WACN,MAAM,EAUhB;IAJC,aAAwB;IACxB,eAAgC;IAChC,6BAA2C;IAI7C;;;;OAIG;IACH,YAFa,MAAM,CAQlB;IAED;;;;OAIG;IACH,UAFa,MAAM,CASlB;IAED;;;;OAIG;IACH,kBAFW,CAAS,IAAO,EAAP,OAAO,KAAG,IAAI,QAIjC;IAED;;;;;OAKG;IACH,gBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,iBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;OAKG;IACH,cAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,iBAJW,CAAS,IAAO,EAAP,OAAO,EAAE,IAAO,EAAP,OAAO,KAAG,OAAO,gBACnC,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,MAAM,GAAC,SAAS,CAI5B;IAED;;;;;;;;OAQG;IACH,eALW,OAAO,WAEf;QAAyB,UAAU,EAA3B,OAAO;KACf,GAAU,OAAO,CAInB;IAED,2CAkDC;;CAiCF"}