@gesslar/toolkit 0.6.0 → 0.7.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.
- package/package.json +8 -8
- package/src/lib/Collection.js +132 -17
- package/src/lib/Contract.js +1 -1
- package/src/lib/Data.js +4 -4
- package/src/lib/DirectoryObject.js +1 -1
- package/src/lib/FS.js +10 -0
- package/src/lib/Glog.js +9 -7
- package/src/lib/Sass.js +6 -1
- package/src/lib/Tantrum.js +43 -0
- package/src/lib/TypeSpec.js +11 -7
- package/src/lib/Util.js +61 -0
- package/src/lib/Valid.js +24 -6
- package/src/types/index.d.ts +17 -23
- package/src/types/index.d.ts.map +1 -0
- package/src/types/lib/Cache.d.ts +28 -0
- package/src/types/lib/Cache.d.ts.map +1 -0
- package/src/types/lib/Collection.d.ts +246 -0
- package/src/types/lib/Collection.d.ts.map +1 -0
- package/src/types/lib/Contract.d.ts +72 -0
- package/src/types/lib/Contract.d.ts.map +1 -0
- package/src/types/lib/Data.d.ts +189 -0
- package/src/types/lib/Data.d.ts.map +1 -0
- package/src/types/lib/DirectoryObject.d.ts +148 -0
- package/src/types/lib/DirectoryObject.d.ts.map +1 -0
- package/src/types/lib/FS.d.ts +70 -0
- package/src/types/lib/FS.d.ts.map +1 -0
- package/src/types/lib/FileObject.d.ts +189 -0
- package/src/types/lib/FileObject.d.ts.map +1 -0
- package/src/types/lib/Glog.d.ts +113 -0
- package/src/types/lib/Glog.d.ts.map +1 -0
- package/src/types/lib/Logger.d.ts +46 -0
- package/src/types/lib/Logger.d.ts.map +1 -0
- package/src/types/lib/Sass.d.ts +62 -0
- package/src/types/lib/Sass.d.ts.map +1 -0
- package/src/types/lib/Schemer.d.ts +23 -0
- package/src/types/lib/Schemer.d.ts.map +1 -0
- package/src/types/lib/Tantrum.d.ts +50 -0
- package/src/types/lib/Tantrum.d.ts.map +1 -0
- package/src/types/lib/Term.d.ts +103 -0
- package/src/types/lib/Term.d.ts.map +1 -0
- package/src/types/lib/Terms.d.ts +24 -0
- package/src/types/lib/Terms.d.ts.map +1 -0
- package/src/types/lib/TypeSpec.d.ts +92 -0
- package/src/types/lib/TypeSpec.d.ts.map +1 -0
- package/src/types/lib/Util.d.ts +197 -0
- package/src/types/lib/Util.d.ts.map +1 -0
- package/src/types/lib/Valid.d.ts +33 -0
- package/src/types/lib/Valid.d.ts.map +1 -0
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
*/
|
|
20
|
+
constructor(message: string, errors?: Array<Error | Sass>);
|
|
21
|
+
/**
|
|
22
|
+
* Adds a trace message and returns this instance for chaining.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} message - The trace message to add
|
|
25
|
+
* @param {Error|Sass} [_error] - Optional error (currently unused, reserved for future use)
|
|
26
|
+
* @returns {this} This Tantrum instance for method chaining
|
|
27
|
+
*/
|
|
28
|
+
addTrace(message: string, _error?: Error | Sass): this;
|
|
29
|
+
/**
|
|
30
|
+
* Adds a message to the beginning of the trace array.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} message - The trace message to add
|
|
33
|
+
*/
|
|
34
|
+
set trace(message: string);
|
|
35
|
+
/**
|
|
36
|
+
* Gets the error trace array.
|
|
37
|
+
*
|
|
38
|
+
* @returns {Array<string>} Array of trace messages
|
|
39
|
+
*/
|
|
40
|
+
get trace(): Array<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Reports all aggregated errors to the terminal with formatted output.
|
|
43
|
+
*
|
|
44
|
+
* @param {boolean} [nerdMode] - Whether to include detailed stack traces
|
|
45
|
+
*/
|
|
46
|
+
report(nerdMode?: boolean): void;
|
|
47
|
+
#private;
|
|
48
|
+
}
|
|
49
|
+
import Sass from "./Sass.js";
|
|
50
|
+
//# sourceMappingURL=Tantrum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tantrum.d.ts","sourceRoot":"","sources":["../../lib/Tantrum.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IAgFE;;;;;;OAMG;IACH,sBAJW,MAAM,WACN,KAAK,CAAC,KAAK,GAAC,IAAI,CAAC,GACf,OAAO,CAOnB;IAzFD;;;;;OAKG;IACH,qBAHW,MAAM,WACN,KAAK,CAAC,KAAK,GAAC,IAAI,CAAC,EAgB3B;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;iBApGgB,WAAW"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export default class Term {
|
|
2
|
+
/**
|
|
3
|
+
* Log an informational message.
|
|
4
|
+
*
|
|
5
|
+
* @param {...unknown} [arg] - Values to log.
|
|
6
|
+
*/
|
|
7
|
+
static log(...arg?: unknown[]): void;
|
|
8
|
+
/**
|
|
9
|
+
* Log an informational message.
|
|
10
|
+
*
|
|
11
|
+
* @param {...unknown} [arg] - Values to log.
|
|
12
|
+
*/
|
|
13
|
+
static info(...arg?: unknown[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* Log a warning message.
|
|
16
|
+
*
|
|
17
|
+
* @param {...unknown} [arg] - Warning text / object.
|
|
18
|
+
*/
|
|
19
|
+
static warn(...arg?: unknown[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Log an error message (plus optional details).
|
|
22
|
+
*
|
|
23
|
+
* @param {...unknown} [arg] - Values to log.
|
|
24
|
+
*/
|
|
25
|
+
static error(...arg?: unknown[]): void;
|
|
26
|
+
/**
|
|
27
|
+
* Log a debug message (no-op unless console.debug provided/visible by env).
|
|
28
|
+
*
|
|
29
|
+
* @param {...unknown} [arg] - Values to log.
|
|
30
|
+
*/
|
|
31
|
+
static debug(...arg?: unknown[]): void;
|
|
32
|
+
/**
|
|
33
|
+
* Emit a status line to the terminal.
|
|
34
|
+
*
|
|
35
|
+
* Accepts either a plain string or an array of message segments (see
|
|
36
|
+
* `terminalMessage()` for formatting options). If `silent` is true, output
|
|
37
|
+
* is suppressed.
|
|
38
|
+
*
|
|
39
|
+
* This is a convenient shortcut for logging status updates, with optional
|
|
40
|
+
* formatting and easy suppression.
|
|
41
|
+
*
|
|
42
|
+
* @param {string | Array<string | [string, string]>} args - Message or segments.
|
|
43
|
+
* @param {object} [options] - Behaviour flags.
|
|
44
|
+
* @param {boolean} options.silent - When true, suppress output.
|
|
45
|
+
* @returns {void}
|
|
46
|
+
*/
|
|
47
|
+
static status(args: string | Array<string | [string, string]>, { silent }?: {
|
|
48
|
+
silent: boolean;
|
|
49
|
+
}): void;
|
|
50
|
+
/**
|
|
51
|
+
* Constructs a formatted status line.
|
|
52
|
+
*
|
|
53
|
+
* Input forms:
|
|
54
|
+
* - string: printed as-is
|
|
55
|
+
* - array: each element is either:
|
|
56
|
+
* - a plain string (emitted unchanged), or
|
|
57
|
+
* - a tuple: [level, text] where `level` maps to an ansiColors alias
|
|
58
|
+
* (e.g. success, info, warn, error, modified).
|
|
59
|
+
* - a tuple: [level, text, [openBracket,closeBracket]] where `level` maps to an ansiColors alias
|
|
60
|
+
* (e.g. success, info, warn, error, modified). These are rendered as
|
|
61
|
+
* colourised bracketed segments: [TEXT].
|
|
62
|
+
*
|
|
63
|
+
* The function performs a shallow validation: tuple elements must both be
|
|
64
|
+
* strings; otherwise a TypeError is thrown. Nested arrays beyond depth 1 are
|
|
65
|
+
* not supported.
|
|
66
|
+
*
|
|
67
|
+
* Recursion: array input is normalised into a single string then re-dispatched
|
|
68
|
+
* through `status` to leverage the string branch (keeps logic DRY).
|
|
69
|
+
*
|
|
70
|
+
* @param {string | Array<string | [string, string] | [string, string, string]>} argList - Message spec.
|
|
71
|
+
* @returns {void}
|
|
72
|
+
*/
|
|
73
|
+
static terminalMessage(argList: string | Array<string | [string, string] | [string, string, string]>): void;
|
|
74
|
+
/**
|
|
75
|
+
* Construct a single coloured bracketed segment from a tuple specifying
|
|
76
|
+
* the style level and the text. The first element ("level") maps to an
|
|
77
|
+
* `ansiColors` alias (e.g. success, info, warn, error, modified) and is
|
|
78
|
+
* used both for the inner text colour and to locate its matching
|
|
79
|
+
* "-bracket" alias for the surrounding square brackets. The second
|
|
80
|
+
* element is the raw text to display.
|
|
81
|
+
*
|
|
82
|
+
* Input validation: every element of `parts` must be a string; otherwise
|
|
83
|
+
* an `Sass` error is thrown. (Additional elements beyond the first two are
|
|
84
|
+
* ignored – the method destructures only the first pair.)
|
|
85
|
+
*
|
|
86
|
+
* Example:
|
|
87
|
+
* terminalBracket(["success", "COMPILED"]) → "[COMPILED]" with coloured
|
|
88
|
+
* brackets + inner text (assuming colour support is available in the
|
|
89
|
+
* terminal).
|
|
90
|
+
*
|
|
91
|
+
* This method does not append trailing spaces; callers are responsible for
|
|
92
|
+
* joining multiple segments with appropriate separators.
|
|
93
|
+
*
|
|
94
|
+
* @param {Array<string>} parts - Tuple: [level, text]. Additional entries ignored.
|
|
95
|
+
* @returns {string} Colourised bracketed segment (e.g. "[TEXT]").
|
|
96
|
+
* @throws {Sass} If any element of `parts` is not a string.
|
|
97
|
+
*/
|
|
98
|
+
static terminalBracket([level, text, brackets]: Array<string>): string;
|
|
99
|
+
static resetTerminal(): Promise<void>;
|
|
100
|
+
static clearLines(num: any): Promise<void>;
|
|
101
|
+
static directWrite(output: any): Promise<any>;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=Term.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Term.d.ts","sourceRoot":"","sources":["../../lib/Term.js"],"names":[],"mappings":"AAKA;IACE;;;;OAIG;IACH,oBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,qBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,qBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAIpB;IAED;;;;;;;;;;;;;;OAcG;IACH,oBALW,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,eAEjD;QAAyB,MAAM,EAAvB,OAAO;KACf,GAAU,IAAI,CAOhB;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,gCAHW,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,GAClE,IAAI,CA4BhB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gDAJW,KAAK,CAAC,MAAM,CAAC,GACX,MAAM,CASlB;IAED,sCAGC;IAED,2CAEC;IAED,8CAIC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terms represents an interface definition - what an action promises to provide or accept.
|
|
3
|
+
* It's just the specification, not the negotiation. Contract handles the negotiation.
|
|
4
|
+
*/
|
|
5
|
+
export default class Terms {
|
|
6
|
+
/**
|
|
7
|
+
* Parses terms data, handling file references
|
|
8
|
+
*
|
|
9
|
+
* @param {string|object} termsData - Terms data or reference
|
|
10
|
+
* @param {DirectoryObject?} directoryObject - Directory context for file resolution
|
|
11
|
+
* @returns {object} Parsed terms data
|
|
12
|
+
*/
|
|
13
|
+
static parse(termsData: string | object, directoryObject: DirectoryObject | null): object;
|
|
14
|
+
constructor(definition: any);
|
|
15
|
+
/**
|
|
16
|
+
* Get the terms definition
|
|
17
|
+
*
|
|
18
|
+
* @returns {object} The terms definition
|
|
19
|
+
*/
|
|
20
|
+
get definition(): object;
|
|
21
|
+
#private;
|
|
22
|
+
}
|
|
23
|
+
import DirectoryObject from "./DirectoryObject.js";
|
|
24
|
+
//# sourceMappingURL=Terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../lib/Terms.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAOE;;;;;;OAMG;IACH,wBAJW,MAAM,GAAC,MAAM,mBACb,eAAe,OAAC,GACd,MAAM,CAmClB;IA5CD,6BAEC;IA4CD;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;;CAEF;4BArE2B,sBAAsB"}
|
|
@@ -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): false | unknown[];
|
|
90
|
+
#private;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=TypeSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,mDAkDC;;CAiCF"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class providing common helper functions for string manipulation,
|
|
3
|
+
* timing, hashing, 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
|
+
* Compute sha256 hash (hex) of the provided string.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} s - Input string.
|
|
46
|
+
* @returns {string} 64-char hexadecimal digest.
|
|
47
|
+
*/
|
|
48
|
+
static hashOf(s: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Extracts canonical option names from a Commander-style options object.
|
|
51
|
+
*
|
|
52
|
+
* Each key in the input object is a string containing one or more option
|
|
53
|
+
* forms, separated by commas (e.g. "-w, --watch"). This function splits each
|
|
54
|
+
* key, trims whitespace, and parses out the long option name (e.g. "watch")
|
|
55
|
+
* for each entry. If no long option ("--") is present, the short option (e.g.
|
|
56
|
+
* "v" from "-v") will be included in the result array. If both are present,
|
|
57
|
+
* the long option is preferred.
|
|
58
|
+
*
|
|
59
|
+
* Example:
|
|
60
|
+
* generateOptionNames({"-w, --watch": "desc", "-v": "desc"})
|
|
61
|
+
* → ["watch", "v"]
|
|
62
|
+
*
|
|
63
|
+
* Edge cases:
|
|
64
|
+
* - If a key contains only a short option ("-v"), that short name will be
|
|
65
|
+
* included in the result.
|
|
66
|
+
* - If multiple long options are present, only the first is used.
|
|
67
|
+
* - If the option string is malformed, may return undefined for that entry
|
|
68
|
+
* (filtered out).
|
|
69
|
+
*
|
|
70
|
+
* @param {object} object - Mapping of option strings to descriptions.
|
|
71
|
+
* @returns {Array<string>} Array of canonical option names (long preferred, short if no long present).
|
|
72
|
+
*/
|
|
73
|
+
static generateOptionNames(object: object): Array<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Asynchronously awaits all promises in parallel.
|
|
76
|
+
* Wrapper around Promise.all for consistency with other utility methods.
|
|
77
|
+
*
|
|
78
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to await
|
|
79
|
+
* @returns {Promise<Array<unknown>>} Results of all promises
|
|
80
|
+
*/
|
|
81
|
+
static awaitAll(promises: Array<Promise<unknown>>): Promise<Array<unknown>>;
|
|
82
|
+
/**
|
|
83
|
+
* Settles all promises (both fulfilled and rejected) in parallel.
|
|
84
|
+
* Wrapper around Promise.allSettled for consistency with other utility methods.
|
|
85
|
+
*
|
|
86
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to settle
|
|
87
|
+
* @returns {Promise<Array<object>>} Results of all settled promises with status and value/reason
|
|
88
|
+
*/
|
|
89
|
+
static settleAll(promises: Array<Promise<unknown>>): Promise<Array<object>>;
|
|
90
|
+
/**
|
|
91
|
+
* Checks if any result in the settled promise array is rejected.
|
|
92
|
+
*
|
|
93
|
+
* @param {Array<object>} result - Array of settled promise results.
|
|
94
|
+
* @returns {boolean} True if any result is rejected, false otherwise.
|
|
95
|
+
*/
|
|
96
|
+
static anyRejected(result: Array<object>): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Filters and returns all rejected results from a settled promise array.
|
|
99
|
+
*
|
|
100
|
+
* @param {Array<object>} result - Array of settled promise results.
|
|
101
|
+
* @returns {Array<object>} Array of rejected results.
|
|
102
|
+
*/
|
|
103
|
+
static settledAndRejected(result: Array<object>): Array<object>;
|
|
104
|
+
/**
|
|
105
|
+
* Extracts the rejection reasons from an array of rejected promise results.
|
|
106
|
+
*
|
|
107
|
+
* @param {Array<object>} rejected - Array of rejected results.
|
|
108
|
+
* @returns {Array<unknown>} Array of rejection reasons.
|
|
109
|
+
*/
|
|
110
|
+
static rejectedReasons(rejected: Array<object>): Array<unknown>;
|
|
111
|
+
/**
|
|
112
|
+
* Throws a Sass error containing all rejection reasons from settled promises.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} [_message] - Optional error message. Defaults to "GIGO"
|
|
115
|
+
* @param {Array<object>} rejected - Array of rejected results.
|
|
116
|
+
* @throws {Error} Throws a Sass error with rejection reasons.
|
|
117
|
+
*/
|
|
118
|
+
static throwRejected(_message?: string, rejected: Array<object>): void;
|
|
119
|
+
/**
|
|
120
|
+
* Filters and returns all fulfilled results from a settled promise array.
|
|
121
|
+
*
|
|
122
|
+
* @param {Array<object>} result - Array of settled promise results.
|
|
123
|
+
* @returns {Array<object>} Array of fulfilled results.
|
|
124
|
+
*/
|
|
125
|
+
static settledAndFulfilled(result: Array<object>): Array<object>;
|
|
126
|
+
/**
|
|
127
|
+
* Extracts the values from all fulfilled results in a settled promise array.
|
|
128
|
+
*
|
|
129
|
+
* @param {Array<object>} result - Array of settled promise results.
|
|
130
|
+
* @returns {Array<unknown>} Array of fulfilled values.
|
|
131
|
+
*/
|
|
132
|
+
static fulfilledValues(result: Array<object>): Array<unknown>;
|
|
133
|
+
/**
|
|
134
|
+
* Returns the first promise to resolve or reject from an array of promises.
|
|
135
|
+
* Wrapper around Promise.race for consistency with other utility methods.
|
|
136
|
+
*
|
|
137
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to race
|
|
138
|
+
* @returns {Promise<unknown>} Result of the first settled promise
|
|
139
|
+
*/
|
|
140
|
+
static race(promises: Array<Promise<unknown>>): Promise<unknown>;
|
|
141
|
+
/**
|
|
142
|
+
* Private method that performs the actual async emission logic.
|
|
143
|
+
* Handles listener execution, error aggregation, and result processing.
|
|
144
|
+
*
|
|
145
|
+
* @param {object} emitter - The emitter object (already validated)
|
|
146
|
+
* @param {string} event - The event name to emit
|
|
147
|
+
* @param {...unknown} args - Arguments to pass to event listeners
|
|
148
|
+
* @returns {Promise<void>} Resolves when all listeners have completed
|
|
149
|
+
*/
|
|
150
|
+
static "__#private@#performAsyncEmit"(emitter: object, event: string, ...args: unknown[]): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Emits an event asynchronously and waits for all listeners to complete.
|
|
153
|
+
* Unlike the standard EventEmitter.emit() which is synchronous, this method
|
|
154
|
+
* properly handles async event listeners by waiting for all of them to
|
|
155
|
+
* resolve or reject using Promise.allSettled().
|
|
156
|
+
*
|
|
157
|
+
* Uses strict instanceof checking to ensure the emitter is a genuine EventEmitter.
|
|
158
|
+
*
|
|
159
|
+
* @param {EventEmitter} emitter - The EventEmitter instance to emit on
|
|
160
|
+
* @param {string} event - The event name to emit
|
|
161
|
+
* @param {...unknown} args - Arguments to pass to event listeners
|
|
162
|
+
* @returns {Promise<void>} Resolves when all listeners have completed
|
|
163
|
+
*/
|
|
164
|
+
static asyncEmit(emitter: EventEmitter, event: string, ...args: unknown[]): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Emits an event asynchronously and waits for all listeners to complete.
|
|
167
|
+
* Like asyncEmit, but uses duck typing for more flexible emitter validation.
|
|
168
|
+
* Accepts any object that has the required EventEmitter-like methods.
|
|
169
|
+
*
|
|
170
|
+
* @param {object} emitter - Any object with EventEmitter-like interface
|
|
171
|
+
* @param {string} event - The event name to emit
|
|
172
|
+
* @param {...unknown} args - Arguments to pass to event listeners
|
|
173
|
+
* @returns {Promise<void>} Resolves when all listeners have completed
|
|
174
|
+
*/
|
|
175
|
+
static asyncEmitAnon(emitter: object, event: string, ...args: unknown[]): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Determine the Levenshtein distance between two string values
|
|
178
|
+
*
|
|
179
|
+
* @param {string} a The first value for comparison.
|
|
180
|
+
* @param {string} b The second value for comparison.
|
|
181
|
+
* @returns {number} The Levenshtein distance
|
|
182
|
+
*/
|
|
183
|
+
static levenshteinDistance(a: string, b: string): number;
|
|
184
|
+
/**
|
|
185
|
+
* Determine the closest match between a string and allowed values
|
|
186
|
+
* from the Levenshtein distance.
|
|
187
|
+
*
|
|
188
|
+
* @param {string} input The input string to resolve
|
|
189
|
+
* @param {Array<string>} allowedValues The values which are permitted
|
|
190
|
+
* @param {number} [threshold] Max edit distance for a "close match"
|
|
191
|
+
* @returns {string} Suggested, probable match.
|
|
192
|
+
*/
|
|
193
|
+
static findClosestMatch(input: string, allowedValues: Array<string>, threshold?: number): string;
|
|
194
|
+
static regexify(input: any, trim?: boolean, flags?: any[]): RegExp;
|
|
195
|
+
}
|
|
196
|
+
import { EventEmitter } from "node:events";
|
|
197
|
+
//# sourceMappingURL=Util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../lib/Util.js"],"names":[],"mappings":"AAOA;;;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,CAAC,CAQ9C;IAED;;;;;;;OAOG;IACH,4BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAalB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,mCAHW,MAAM,GACJ,KAAK,CAAC,MAAM,CAAC,CAazB;IAED;;;;;;OAMG;IACH,0BAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAInC;IAED;;;;;;OAMG;IACH,2BAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAIlC;IAED;;;;;OAKG;IACH,2BAHW,KAAK,CAAC,MAAM,CAAC,GACX,OAAO,CAInB;IAED;;;;;OAKG;IACH,kCAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;OAKG;IACH,iCAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,gCAJW,MAAM,YACN,KAAK,CAAC,MAAM,CAAC,QAKvB;IAED;;;;;OAKG;IACH,mCAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;OAKG;IACH,+BAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,sBAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;;;;;OAQG;IACH,+CALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAmBzB;IAED;;;;;;;;;;;;OAYG;IACH,0BALW,YAAY,SACZ,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAqBzB;IAED;;;;;;;;;OASG;IACH,8BALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAyBzB;IAED;;;;;;OAMG;IACH,8BAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAsBlB;IAED;;;;;;;;OAQG;IACH,+BALW,MAAM,iBACN,KAAK,CAAC,MAAM,CAAC,cACb,MAAM,GACJ,MAAM,CAwBlB;IAED,mEAiBC;CACF;6BAjZ0B,aAAa"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
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":["../../lib/Valid.js"],"names":[],"mappings":"AAaA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,mBAJW,OAAO,QACP,MAAM,YACN,MAAM,QAQhB;IAED;;;;;;;;OAQG;IACH,yBANW,OAAO,WACP,MAAM,QAEN,MAAM,QAmBhB;IAED,+CAAmE;IAEnE;;;;;;OAMG;IACH,0CAHW,KAAK,CAAC,MAAM,CAAC,QAYvB;CACF"}
|