@gesslar/toolkit 0.8.0 → 1.0.2

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 (55) hide show
  1. package/README.md +39 -0
  2. package/package.json +22 -8
  3. package/src/browser/index.js +10 -0
  4. package/src/browser/lib/Sass.js +168 -0
  5. package/src/browser/lib/Tantrum.js +115 -0
  6. package/src/browser/lib/Util.js +257 -0
  7. package/src/browser/lib/Valid.js +76 -0
  8. package/src/index.js +14 -12
  9. package/src/lib/Cache.js +2 -3
  10. package/src/lib/Contract.js +3 -4
  11. package/src/lib/FS.js +15 -20
  12. package/src/lib/FileObject.js +1 -1
  13. package/src/lib/Glog.js +2 -2
  14. package/src/lib/Sass.js +2 -91
  15. package/src/lib/Schemer.js +2 -2
  16. package/src/lib/Tantrum.js +3 -70
  17. package/src/lib/Terms.js +2 -3
  18. package/src/lib/Util.js +2 -252
  19. package/src/lib/Valid.js +17 -20
  20. package/src/types/browser/index.d.ts +8 -0
  21. package/src/types/browser/index.d.ts.map +1 -0
  22. package/src/types/browser/lib/Collection.d.ts +246 -0
  23. package/src/types/browser/lib/Collection.d.ts.map +1 -0
  24. package/src/types/browser/lib/Data.d.ts +206 -0
  25. package/src/types/browser/lib/Data.d.ts.map +1 -0
  26. package/src/types/browser/lib/Sass.d.ts +62 -0
  27. package/src/types/browser/lib/Sass.d.ts.map +1 -0
  28. package/src/types/browser/lib/Tantrum.d.ts +51 -0
  29. package/src/types/browser/lib/Tantrum.d.ts.map +1 -0
  30. package/src/types/browser/lib/TypeSpec.d.ts +92 -0
  31. package/src/types/browser/lib/TypeSpec.d.ts.map +1 -0
  32. package/src/types/browser/lib/Util.d.ts +129 -0
  33. package/src/types/browser/lib/Util.d.ts.map +1 -0
  34. package/src/types/browser/lib/Valid.d.ts +33 -0
  35. package/src/types/browser/lib/Valid.d.ts.map +1 -0
  36. package/src/types/index.d.ts +10 -10
  37. package/src/types/lib/Cache.d.ts +2 -3
  38. package/src/types/lib/Cache.d.ts.map +1 -1
  39. package/src/types/lib/Contract.d.ts +3 -4
  40. package/src/types/lib/Contract.d.ts.map +1 -1
  41. package/src/types/lib/FS.d.ts +2 -2
  42. package/src/types/lib/FS.d.ts.map +1 -1
  43. package/src/types/lib/Sass.d.ts +2 -55
  44. package/src/types/lib/Sass.d.ts.map +1 -1
  45. package/src/types/lib/Tantrum.d.ts +3 -44
  46. package/src/types/lib/Tantrum.d.ts.map +1 -1
  47. package/src/types/lib/Terms.d.ts +2 -3
  48. package/src/types/lib/Terms.d.ts.map +1 -1
  49. package/src/types/lib/Util.d.ts +2 -123
  50. package/src/types/lib/Util.d.ts.map +1 -1
  51. package/src/types/lib/Valid.d.ts +1 -1
  52. package/src/types/lib/Valid.d.ts.map +1 -1
  53. /package/src/{lib → browser/lib}/Collection.js +0 -0
  54. /package/src/{lib → browser/lib}/Data.js +0 -0
  55. /package/src/{lib → browser/lib}/TypeSpec.js +0 -0
@@ -0,0 +1,206 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../browser/lib/Data.js"],"names":[],"mappings":"AAUA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AC,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"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Custom error class for toolkit errors.
3
+ * Provides error chaining, trace management, and formatted error reporting.
4
+ */
5
+ export default class Sass extends Error {
6
+ /**
7
+ * Creates an Sass from an existing Error object with additional
8
+ * trace message.
9
+ *
10
+ * @param {Error} error - The original error object
11
+ * @param {string} message - Additional trace message to add
12
+ * @returns {Sass} New Sass instance with trace from the original error
13
+ * @throws {Sass} If the first parameter is not an Error instance
14
+ */
15
+ static from(error: Error, message: string): Sass;
16
+ /**
17
+ * Factory method to create or enhance Sass instances.
18
+ * If error parameter is provided, enhances existing Sass or wraps
19
+ * other errors. Otherwise creates a new Sass instance.
20
+ *
21
+ * @param {string} message - The error message
22
+ * @param {Error|Sass|Tantrum} [error] - Optional existing error to wrap or enhance
23
+ * @returns {Sass} New or enhanced Sass instance
24
+ */
25
+ static "new"(message: string, error?: Error | Sass | Tantrum): Sass;
26
+ /**
27
+ * Creates a new Sass instance.
28
+ *
29
+ * @param {string} message - The error message
30
+ * @param {...unknown} [arg] - Additional arguments passed to parent Error constructor
31
+ */
32
+ constructor(message: string, ...arg?: unknown[]);
33
+ /**
34
+ * Adds a message to the beginning of the trace array.
35
+ *
36
+ * @param {string} message - The trace message to add
37
+ */
38
+ set trace(message: string);
39
+ /**
40
+ * Gets the error trace array.
41
+ *
42
+ * @returns {Array<string>} Array of trace messages
43
+ */
44
+ get trace(): Array<string>;
45
+ /**
46
+ * Adds a trace message and returns this instance for chaining.
47
+ *
48
+ * @param {string} message - The trace message to add
49
+ * @returns {this} This Sass instance for method chaining
50
+ */
51
+ addTrace(message: string): this;
52
+ /**
53
+ * Reports the error to the console with formatted output.
54
+ * Optionally includes detailed stack trace information.
55
+ *
56
+ * @param {boolean} [nerdMode] - Whether to include detailed stack trace
57
+ */
58
+ report(nerdMode?: boolean): void;
59
+ #private;
60
+ }
61
+ import Tantrum from "./Tantrum.js";
62
+ //# sourceMappingURL=Sass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sass.d.ts","sourceRoot":"","sources":["../../../browser/lib/Sass.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH;IA2GE;;;;;;;;OAQG;IACH,mBALW,KAAK,WACL,MAAM,GACJ,IAAI,CAWhB;IAED;;;;;;;;OAQG;IACH,sBAJW,MAAM,UACN,KAAK,GAAC,IAAI,GAAC,OAAO,GAChB,IAAI,CAchB;IAhJD;;;;;OAKG;IACH,qBAHW,MAAM,WACH,OAAO,EAAA,EAMpB;IAWD;;;;OAIG;IACH,mBAFW,MAAM,EAIhB;IAhBD;;;;OAIG;IACH,aAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IAWD;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,IAAI,CAShB;IAED;;;;;OAKG;IACH,kBAFW,OAAO,QAqBjB;;CA2EF;oBA1JmB,cAAc"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Custom aggregate error class that extends AggregateError.
3
+ * Automatically wraps plain errors in Sass instances for consistent reporting.
4
+ */
5
+ export default class Tantrum extends AggregateError {
6
+ /**
7
+ * Factory method to create a Tantrum instance.
8
+ *
9
+ * @param {string} message - The aggregate error message
10
+ * @param {Array<Error|Sass>} errors - Array of errors to aggregate
11
+ * @returns {Tantrum} New Tantrum instance
12
+ */
13
+ static "new"(message: string, errors?: Array<Error | Sass>): Tantrum;
14
+ /**
15
+ * Creates a new Tantrum instance.
16
+ *
17
+ * @param {string} message - The aggregate error message
18
+ * @param {Array<Error|Sass>} errors - Array of errors to aggregate
19
+ * @param {Sass} sass - Sass constructor
20
+ */
21
+ constructor(message: string, errors?: Array<Error | Sass>, sass?: Sass);
22
+ /**
23
+ * Adds a trace message and returns this instance for chaining.
24
+ *
25
+ * @param {string} message - The trace message to add
26
+ * @param {Error|Sass} [_error] - Optional error (currently unused, reserved for future use)
27
+ * @returns {this} This Tantrum instance for method chaining
28
+ */
29
+ addTrace(message: string, _error?: Error | Sass): this;
30
+ /**
31
+ * Adds a message to the beginning of the trace array.
32
+ *
33
+ * @param {string} message - The trace message to add
34
+ */
35
+ set trace(message: string);
36
+ /**
37
+ * Gets the error trace array.
38
+ *
39
+ * @returns {Array<string>} Array of trace messages
40
+ */
41
+ get trace(): Array<string>;
42
+ /**
43
+ * Reports all aggregated errors to the console with formatted output.
44
+ *
45
+ * @param {boolean} [nerdMode] - Whether to include detailed stack traces
46
+ */
47
+ report(nerdMode?: boolean): void;
48
+ #private;
49
+ }
50
+ import Sass from "./Sass.js";
51
+ //# sourceMappingURL=Tantrum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tantrum.d.ts","sourceRoot":"","sources":["../../../browser/lib/Tantrum.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH;IAoFE;;;;;;OAMG;IACH,sBAJW,MAAM,WACN,KAAK,CAAC,KAAK,GAAC,IAAI,CAAC,GACf,OAAO,CAOnB;IA5FD;;;;;;OAMG;IACH,qBAJW,MAAM,WACN,KAAK,CAAC,KAAK,GAAC,IAAI,CAAC,SACjB,IAAI,EAkBd;IAED;;;;;;OAMG;IACH,kBAJW,MAAM,WACN,KAAK,GAAC,IAAI,GACR,IAAI,CAShB;IAWD;;;;OAIG;IACH,mBAFW,MAAM,EAIhB;IAhBD;;;;OAIG;IACH,aAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IAWD;;;;OAIG;IACH,kBAFW,OAAO,QAgBjB;;CAeF;iBAvGgB,WAAW"}
@@ -0,0 +1,92 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../../browser/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"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Utility class providing common helper functions for string manipulation,
3
+ * timing, and option parsing.
4
+ */
5
+ export default class Util {
6
+ /**
7
+ * Capitalizes the first letter of a string.
8
+ *
9
+ * @param {string} text - The text to capitalize
10
+ * @returns {string} Text with first letter capitalized
11
+ */
12
+ static capitalize(text: string): string;
13
+ /**
14
+ * Measure wall-clock time for an async function.
15
+ *
16
+ * @template T
17
+ * @param {() => Promise<T>} fn - Thunk returning a promise.
18
+ * @returns {Promise<{result: T, cost: number}>} Object containing result and elapsed ms (number, 1 decimal).
19
+ */
20
+ static time<T>(fn: () => Promise<T>): Promise<{
21
+ result: T;
22
+ cost: number;
23
+ }>;
24
+ /**
25
+ * Right-align a string inside a fixed width (left pad with spaces).
26
+ * If the string exceeds width it is returned unchanged.
27
+ *
28
+ * @param {string|number} text - Text to align.
29
+ * @param {number} width - Target field width (default 80).
30
+ * @returns {string} Padded string.
31
+ */
32
+ static rightAlignText(text: string | number, width?: number): string;
33
+ /**
34
+ * Centre-align a string inside a fixed width (pad with spaces on left).
35
+ * If the string exceeds width it is returned unchanged.
36
+ *
37
+ * @param {string|number} text - Text to align.
38
+ * @param {number} width - Target field width (default 80).
39
+ * @returns {string} Padded string with text centred.
40
+ */
41
+ static centreAlignText(text: string | number, width?: number): string;
42
+ /**
43
+ * Asynchronously awaits all promises in parallel.
44
+ * Wrapper around Promise.all for consistency with other utility methods.
45
+ *
46
+ * @param {Array<Promise<unknown>>} promises - Array of promises to await
47
+ * @returns {Promise<Array<unknown>>} Results of all promises
48
+ */
49
+ static awaitAll(promises: Array<Promise<unknown>>): Promise<Array<unknown>>;
50
+ /**
51
+ * Settles all promises (both fulfilled and rejected) in parallel.
52
+ * Wrapper around Promise.allSettled for consistency with other utility methods.
53
+ *
54
+ * @param {Array<Promise<unknown>>} promises - Array of promises to settle
55
+ * @returns {Promise<Array<object>>} Results of all settled promises with status and value/reason
56
+ */
57
+ static settleAll(promises: Array<Promise<unknown>>): Promise<Array<object>>;
58
+ /**
59
+ * Checks if any result in the settled promise array is rejected.
60
+ *
61
+ * @param {Array<object>} result - Array of settled promise results.
62
+ * @returns {boolean} True if any result is rejected, false otherwise.
63
+ */
64
+ static anyRejected(result: Array<object>): boolean;
65
+ /**
66
+ * Filters and returns all rejected results from a settled promise array.
67
+ *
68
+ * @param {Array<object>} result - Array of settled promise results.
69
+ * @returns {Array<object>} Array of rejected results.
70
+ */
71
+ static settledAndRejected(result: Array<object>): Array<object>;
72
+ /**
73
+ * Extracts the rejection reasons from an array of rejected promise results.
74
+ *
75
+ * @param {Array<object>} rejected - Array of rejected results.
76
+ * @returns {Array<unknown>} Array of rejection reasons.
77
+ */
78
+ static rejectedReasons(rejected: Array<object>): Array<unknown>;
79
+ /**
80
+ * Throws a Sass error containing all rejection reasons from settled promises.
81
+ *
82
+ * @param {string} [_message] - Optional error message. Defaults to "GIGO"
83
+ * @param {Array<object>} rejected - Array of rejected results.
84
+ * @throws {Error} Throws a Sass error with rejection reasons.
85
+ */
86
+ static throwRejected(_message?: string, rejected: Array<object>): void;
87
+ /**
88
+ * Filters and returns all fulfilled results from a settled promise array.
89
+ *
90
+ * @param {Array<object>} result - Array of settled promise results.
91
+ * @returns {Array<object>} Array of fulfilled results.
92
+ */
93
+ static settledAndFulfilled(result: Array<object>): Array<object>;
94
+ /**
95
+ * Extracts the values from all fulfilled results in a settled promise array.
96
+ *
97
+ * @param {Array<object>} result - Array of settled promise results.
98
+ * @returns {Array<unknown>} Array of fulfilled values.
99
+ */
100
+ static fulfilledValues(result: Array<object>): Array<unknown>;
101
+ /**
102
+ * Returns the first promise to resolve or reject from an array of promises.
103
+ * Wrapper around Promise.race for consistency with other utility methods.
104
+ *
105
+ * @param {Array<Promise<unknown>>} promises - Array of promises to race
106
+ * @returns {Promise<unknown>} Result of the first settled promise
107
+ */
108
+ static race(promises: Array<Promise<unknown>>): Promise<unknown>;
109
+ /**
110
+ * Determine the Levenshtein distance between two string values
111
+ *
112
+ * @param {string} a The first value for comparison.
113
+ * @param {string} b The second value for comparison.
114
+ * @returns {number} The Levenshtein distance
115
+ */
116
+ static levenshteinDistance(a: string, b: string): number;
117
+ /**
118
+ * Determine the closest match between a string and allowed values
119
+ * from the Levenshtein distance.
120
+ *
121
+ * @param {string} input The input string to resolve
122
+ * @param {Array<string>} allowedValues The values which are permitted
123
+ * @param {number} [threshold] Max edit distance for a "close match"
124
+ * @returns {string} Suggested, probable match.
125
+ */
126
+ static findClosestMatch(input: string, allowedValues: Array<string>, threshold?: number): string;
127
+ static regexify(input: any, trim?: boolean, flags?: any[]): RegExp;
128
+ }
129
+ //# sourceMappingURL=Util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../browser/lib/Util.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;OAMG;IACH,YAJa,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,GACd,OAAO,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,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2
+ * Validation utility class providing type checking and assertion methods.
3
+ */
4
+ export default class Valid {
5
+ /**
6
+ * Validates a value against a type. Uses Data.isType.
7
+ *
8
+ * @param {unknown} value - The value to validate
9
+ * @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
10
+ * @param {object} [options] - Additional options for validation.
11
+ */
12
+ static type(value: unknown, type: string, options?: object): void;
13
+ /**
14
+ * Asserts a condition
15
+ *
16
+ * @param {boolean} condition - The condition to assert
17
+ * @param {string} message - The message to display if the condition is not
18
+ * met
19
+ * @param {number} [arg] - The argument to display if the condition is not
20
+ * met (optional)
21
+ */
22
+ static assert(condition: boolean, message: string, arg?: number): void;
23
+ static "__#private@#restrictedProto": string[];
24
+ /**
25
+ * Protects against prototype pollution by checking keys for dangerous property names.
26
+ * Throws if any restricted prototype properties are found in the keys array.
27
+ *
28
+ * @param {Array<string>} keys - Array of property keys to validate
29
+ * @throws {Sass} If any key matches restricted prototype properties (__proto__, constructor, prototype)
30
+ */
31
+ static prototypePollutionProtection(keys: Array<string>): void;
32
+ }
33
+ //# sourceMappingURL=Valid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../../browser/lib/Valid.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,mBAJW,OAAO,QACP,MAAM,YACN,MAAM,QAQhB;IAED;;;;;;;;OAQG;IACH,yBANW,OAAO,WACP,MAAM,QAEN,MAAM,QAkBhB;IAED,+CAAmE;IAEnE;;;;;;OAMG;IACH,0CAHW,KAAK,CAAC,MAAM,CAAC,QAYvB;CACF"}
@@ -1,17 +1,17 @@
1
- export { default as FileObject } from "./lib/FileObject.js";
2
- export { default as DirectoryObject } from "./lib/DirectoryObject.js";
3
- export { default as FS } from "./lib/FS.js";
1
+ export { default as Collection } from "./browser/lib/Collection.js";
2
+ export { default as Data } from "./browser/lib/Data.js";
3
+ export { default as Type } from "./browser/lib/TypeSpec.js";
4
+ export { default as Valid } from "./lib/Valid.js";
5
+ export { default as Sass } from "./lib/Sass.js";
6
+ export { default as Tantrum } from "./lib/Tantrum.js";
7
+ export { default as Util } from "./lib/Util.js";
4
8
  export { default as Cache } from "./lib/Cache.js";
5
- export { default as Collection } from "./lib/Collection.js";
6
9
  export { default as Contract } from "./lib/Contract.js";
7
- export { default as Data } from "./lib/Data.js";
10
+ export { default as DirectoryObject } from "./lib/DirectoryObject.js";
11
+ export { default as FileObject } from "./lib/FileObject.js";
12
+ export { default as FS } from "./lib/FS.js";
8
13
  export { default as Glog } from "./lib/Glog.js";
9
- export { default as Sass } from "./lib/Sass.js";
10
14
  export { default as Schemer } from "./lib/Schemer.js";
11
- export { default as Tantrum } from "./lib/Tantrum.js";
12
15
  export { default as Term } from "./lib/Term.js";
13
16
  export { default as Terms } from "./lib/Terms.js";
14
- export { default as Type } from "./lib/TypeSpec.js";
15
- export { default as Util } from "./lib/Util.js";
16
- export { default as Valid } from "./lib/Valid.js";
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -17,12 +17,11 @@ export default class Cache {
17
17
  * freshness while optimizing performance for repeated file access during
18
18
  * parallel processing.
19
19
  *
20
- * @param {FileObject} fileObject - The file object to load and cache
20
+ * @param {import("./FileObject.js").FileObject} fileObject - The file object to load and cache
21
21
  * @returns {Promise<unknown>} The parsed file data (JSON5 or YAML)
22
22
  * @throws {Sass} If the file cannot be found or accessed
23
23
  */
24
- loadCachedData(fileObject: FileObject): Promise<unknown>;
24
+ loadCachedData(fileObject: import("./FileObject.js").FileObject): Promise<unknown>;
25
25
  #private;
26
26
  }
27
- import FileObject from "./FileObject.js";
28
27
  //# sourceMappingURL=Cache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../lib/Cache.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH;IAoBE;;;;;;;;;;;;OAYG;IACH,2BAJW,UAAU,GACR,OAAO,CAAC,OAAO,CAAC,CA6B5B;;CACF;uBAxEsB,iBAAiB"}
1
+ {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../lib/Cache.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH;IAoBE;;;;;;;;;;;;OAYG;IACH,2BAJW,OAAO,iBAAiB,EAAE,UAAU,GAClC,OAAO,CAAC,OAAO,CAAC,CA6B5B;;CACF"}