@decaf-ts/utils 0.2.6 → 0.2.8
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/LICENSE.md +0 -0
- package/README.md +0 -0
- package/bin/build-scripts.cjs +1885 -1423
- package/bin/tag-release.cjs +1876 -1420
- package/bin/tag-release.sh +0 -0
- package/bin/update-scripts.cjs +1881 -1425
- package/dist/assets/slogans.json +0 -0
- package/dist/utils.cjs +86 -689
- package/dist/utils.esm.cjs +78 -674
- package/lib/assets/slogans.json +0 -0
- package/lib/bin/build-scripts.d.ts +0 -0
- package/lib/bin/tag-release.d.ts +0 -0
- package/lib/bin/update-scripts.d.ts +0 -0
- package/lib/cli/command.cjs +6 -7
- package/lib/cli/command.d.ts +5 -5
- package/lib/cli/commands/build-scripts.cjs +9 -3
- package/lib/cli/commands/build-scripts.d.ts +1 -1
- package/lib/cli/commands/index.cjs +0 -0
- package/lib/cli/commands/index.d.ts +0 -0
- package/lib/cli/commands/tag-release.cjs +1 -1
- package/lib/cli/commands/tag-release.d.ts +1 -1
- package/lib/cli/commands/update-scripts.cjs +1 -1
- package/lib/cli/commands/update-scripts.d.ts +1 -1
- package/lib/cli/constants.cjs +0 -0
- package/lib/cli/constants.d.ts +0 -0
- package/lib/cli/index.cjs +0 -0
- package/lib/cli/index.d.ts +0 -0
- package/lib/cli/types.cjs +1 -1
- package/lib/cli/types.d.ts +1 -1
- package/lib/esm/assets/slogans.json +0 -0
- package/lib/esm/bin/build-scripts.d.ts +0 -0
- package/lib/esm/bin/build-scripts.js +0 -0
- package/lib/esm/bin/tag-release.d.ts +0 -0
- package/lib/esm/bin/tag-release.js +0 -0
- package/lib/esm/bin/update-scripts.d.ts +0 -0
- package/lib/esm/bin/update-scripts.js +0 -0
- package/lib/esm/cli/command.d.ts +5 -5
- package/lib/esm/cli/command.js +2 -3
- package/lib/esm/cli/commands/build-scripts.d.ts +1 -1
- package/lib/esm/cli/commands/build-scripts.js +9 -3
- package/lib/esm/cli/commands/index.d.ts +0 -0
- package/lib/esm/cli/commands/index.js +0 -0
- package/lib/esm/cli/commands/tag-release.d.ts +1 -1
- package/lib/esm/cli/commands/tag-release.js +1 -1
- package/lib/esm/cli/commands/update-scripts.d.ts +1 -1
- package/lib/esm/cli/commands/update-scripts.js +1 -1
- package/lib/esm/cli/constants.d.ts +0 -0
- package/lib/esm/cli/constants.js +0 -0
- package/lib/esm/cli/index.d.ts +0 -0
- package/lib/esm/cli/index.js +0 -0
- package/lib/esm/cli/types.d.ts +1 -1
- package/lib/esm/cli/types.js +1 -1
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +2 -2
- package/lib/esm/input/index.d.ts +0 -0
- package/lib/esm/input/index.js +0 -0
- package/lib/esm/input/input.d.ts +1 -2
- package/lib/esm/input/input.js +2 -2
- package/lib/esm/input/types.d.ts +83 -0
- package/lib/esm/input/types.js +1 -1
- package/lib/esm/output/common.d.ts +3 -3
- package/lib/esm/output/common.js +2 -2
- package/lib/esm/output/index.d.ts +1 -3
- package/lib/esm/output/index.js +2 -4
- package/lib/esm/utils/constants.d.ts +0 -77
- package/lib/esm/utils/constants.js +1 -114
- package/lib/esm/utils/environment.d.ts +1 -1
- package/lib/esm/utils/environment.js +2 -2
- package/lib/esm/utils/fs.d.ts +0 -0
- package/lib/esm/utils/fs.js +2 -2
- package/lib/esm/utils/http.d.ts +1 -1
- package/lib/esm/utils/http.js +2 -2
- package/lib/esm/utils/index.d.ts +0 -0
- package/lib/esm/utils/index.js +0 -0
- package/lib/esm/utils/md.d.ts +0 -0
- package/lib/esm/utils/md.js +0 -0
- package/lib/esm/utils/tests.d.ts +0 -0
- package/lib/esm/utils/tests.js +0 -0
- package/lib/esm/utils/text.d.ts +0 -0
- package/lib/esm/utils/text.js +0 -0
- package/lib/esm/utils/timeout.d.ts +0 -0
- package/lib/esm/utils/timeout.js +0 -0
- package/lib/esm/utils/types.d.ts +0 -0
- package/lib/esm/utils/types.js +0 -0
- package/lib/esm/utils/utils.d.ts +2 -2
- package/lib/esm/utils/utils.js +2 -2
- package/lib/esm/utils/web.d.ts +0 -0
- package/lib/esm/utils/web.js +0 -0
- package/lib/esm/writers/OutputWriter.d.ts +0 -0
- package/lib/esm/writers/OutputWriter.js +0 -0
- package/lib/esm/writers/RegexpOutputWriter.d.ts +0 -0
- package/lib/esm/writers/RegexpOutputWriter.js +0 -0
- package/lib/esm/writers/StandardOutputWriter.d.ts +2 -2
- package/lib/esm/writers/StandardOutputWriter.js +2 -2
- package/lib/esm/writers/index.d.ts +0 -0
- package/lib/esm/writers/index.js +0 -0
- package/lib/esm/writers/types.d.ts +0 -0
- package/lib/esm/writers/types.js +0 -0
- package/lib/index.cjs +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/input/index.cjs +0 -0
- package/lib/input/index.d.ts +0 -0
- package/lib/input/input.cjs +2 -2
- package/lib/input/input.d.ts +1 -2
- package/lib/input/types.cjs +1 -1
- package/lib/input/types.d.ts +83 -0
- package/lib/output/common.cjs +2 -2
- package/lib/output/common.d.ts +3 -3
- package/lib/output/index.cjs +1 -3
- package/lib/output/index.d.ts +1 -3
- package/lib/utils/constants.cjs +2 -115
- package/lib/utils/constants.d.ts +0 -77
- package/lib/utils/environment.cjs +3 -3
- package/lib/utils/environment.d.ts +1 -1
- package/lib/utils/fs.cjs +2 -2
- package/lib/utils/fs.d.ts +0 -0
- package/lib/utils/http.cjs +2 -2
- package/lib/utils/http.d.ts +1 -1
- package/lib/utils/index.cjs +0 -0
- package/lib/utils/index.d.ts +0 -0
- package/lib/utils/md.cjs +0 -0
- package/lib/utils/md.d.ts +0 -0
- package/lib/utils/tests.cjs +0 -0
- package/lib/utils/tests.d.ts +0 -0
- package/lib/utils/text.cjs +0 -0
- package/lib/utils/text.d.ts +0 -0
- package/lib/utils/timeout.cjs +0 -0
- package/lib/utils/timeout.d.ts +0 -0
- package/lib/utils/types.cjs +0 -0
- package/lib/utils/types.d.ts +0 -0
- package/lib/utils/utils.cjs +2 -2
- package/lib/utils/utils.d.ts +2 -2
- package/lib/utils/web.cjs +0 -0
- package/lib/utils/web.d.ts +0 -0
- package/lib/writers/OutputWriter.cjs +0 -0
- package/lib/writers/OutputWriter.d.ts +0 -0
- package/lib/writers/RegexpOutputWriter.cjs +0 -0
- package/lib/writers/RegexpOutputWriter.d.ts +0 -0
- package/lib/writers/StandardOutputWriter.cjs +2 -2
- package/lib/writers/StandardOutputWriter.d.ts +2 -2
- package/lib/writers/index.cjs +0 -0
- package/lib/writers/index.d.ts +0 -0
- package/lib/writers/types.cjs +0 -0
- package/lib/writers/types.d.ts +0 -0
- package/package.json +5 -2
- package/lib/esm/output/logging.d.ts +0 -177
- package/lib/esm/output/logging.js +0 -349
- package/lib/esm/output/types.d.ts +0 -203
- package/lib/esm/output/types.js +0 -2
- package/lib/esm/utils/accumulator.d.ts +0 -105
- package/lib/esm/utils/accumulator.js +0 -144
- package/lib/output/logging.cjs +0 -354
- package/lib/output/logging.d.ts +0 -177
- package/lib/output/types.cjs +0 -3
- package/lib/output/types.d.ts +0 -203
- package/lib/utils/accumulator.cjs +0 -148
- package/lib/utils/accumulator.d.ts +0 -105
package/lib/output/types.d.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { LogLevel } from "../utils/constants";
|
|
2
|
-
import { styles } from "styled-string-builder";
|
|
3
|
-
export type StringLike = string | {
|
|
4
|
-
toString: () => string;
|
|
5
|
-
};
|
|
6
|
-
export type LoggingContext = string | {
|
|
7
|
-
new (...args: any[]): any;
|
|
8
|
-
} | ((...args: any[]) => any);
|
|
9
|
-
/**
|
|
10
|
-
* @description Interface for a logger with verbosity levels.
|
|
11
|
-
* @summary Defines methods for logging at different verbosity levels.
|
|
12
|
-
* @interface VerbosityLogger
|
|
13
|
-
* @memberOf @decaf-ts/utils
|
|
14
|
-
*/
|
|
15
|
-
export interface VerbosityLogger {
|
|
16
|
-
/**
|
|
17
|
-
* @description Logs a `way too verbose` or a silly message.
|
|
18
|
-
* @param {StringLike} msg - The message to log.
|
|
19
|
-
*/
|
|
20
|
-
silly(msg: StringLike): void;
|
|
21
|
-
/**
|
|
22
|
-
* @description Logs a verbose message.
|
|
23
|
-
* @param {StringLike} msg - The message to log.
|
|
24
|
-
* @param {number} verbosity - The verbosity level of the message.
|
|
25
|
-
*/
|
|
26
|
-
verbose(msg: StringLike, verbosity?: number): void;
|
|
27
|
-
/**
|
|
28
|
-
* @description Logs an info message.
|
|
29
|
-
* @param {StringLike} msg - The message to log.
|
|
30
|
-
*/
|
|
31
|
-
info(msg: StringLike): void;
|
|
32
|
-
/**
|
|
33
|
-
* @description Logs an error message.
|
|
34
|
-
* @param {StringLike | Error} msg - The message to log.
|
|
35
|
-
*/
|
|
36
|
-
error(msg: StringLike | Error): void;
|
|
37
|
-
/**
|
|
38
|
-
* @description Logs a debug message.
|
|
39
|
-
* @param {string} msg - The message to log.
|
|
40
|
-
*/
|
|
41
|
-
debug(msg: StringLike): void;
|
|
42
|
-
for(method?: string | ((...args: any[]) => any), config?: Partial<LoggingConfig>): VerbosityLogger;
|
|
43
|
-
setConfig(config: Partial<LoggingConfig>): void;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* @description Configuration for logging.
|
|
47
|
-
* @summary Defines the log level and verbosity for logging.
|
|
48
|
-
* @typedef {Object} LoggingConfig
|
|
49
|
-
* @property {LogLevel} level - The logging level.
|
|
50
|
-
* @property {number} verbose - The verbosity level.
|
|
51
|
-
* @memberOf @decaf-ts/utils
|
|
52
|
-
*/
|
|
53
|
-
export type LoggingConfig = {
|
|
54
|
-
level: LogLevel;
|
|
55
|
-
logLevel?: boolean;
|
|
56
|
-
verbose: number;
|
|
57
|
-
separator: string;
|
|
58
|
-
style?: boolean;
|
|
59
|
-
timestamp?: boolean;
|
|
60
|
-
timestampFormat?: string;
|
|
61
|
-
context?: boolean;
|
|
62
|
-
theme?: Theme;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
/**
|
|
66
|
-
* @description Represents a theme option for console output styling.
|
|
67
|
-
* @summary Defines the structure for styling a specific element in the console output.
|
|
68
|
-
* It allows for customization of foreground color, background color, and additional styles.
|
|
69
|
-
* Colors can be specified as a single number, an RGB array, or left undefined for default.
|
|
70
|
-
*
|
|
71
|
-
* @interface ThemeOption
|
|
72
|
-
* @memberOf @decaf-ts/utils
|
|
73
|
-
*/
|
|
74
|
-
export interface ThemeOption {
|
|
75
|
-
fg?: number | [number] | [number, number, number];
|
|
76
|
-
bg?: number | [number] | [number, number, number];
|
|
77
|
-
style?: number[] | [keyof typeof styles];
|
|
78
|
-
}
|
|
79
|
-
export type ThemeOptionByLogLevel = Partial<Record<LogLevel, ThemeOption>>;
|
|
80
|
-
/**
|
|
81
|
-
/**
|
|
82
|
-
* @description Defines the color theme for console output.
|
|
83
|
-
* @summary This interface specifies the color scheme for various elements of console output,
|
|
84
|
-
* including styling for different log levels and components. It uses ThemeOption to
|
|
85
|
-
* define the styling for each element, allowing for customization of colors and styles
|
|
86
|
-
* for different parts of the log output.
|
|
87
|
-
*
|
|
88
|
-
* @interface Theme
|
|
89
|
-
* @memberOf @decaf-ts/utils
|
|
90
|
-
*/
|
|
91
|
-
export interface Theme {
|
|
92
|
-
/**
|
|
93
|
-
* @description Styling for class names in the output.
|
|
94
|
-
*/
|
|
95
|
-
class: ThemeOption | ThemeOptionByLogLevel;
|
|
96
|
-
/**
|
|
97
|
-
* @description Styling for timestamps in the output.
|
|
98
|
-
*/
|
|
99
|
-
timestamp: ThemeOption | ThemeOptionByLogLevel;
|
|
100
|
-
/**
|
|
101
|
-
* @description Styling for the main message text in the output.
|
|
102
|
-
*/
|
|
103
|
-
message: ThemeOption | ThemeOptionByLogLevel;
|
|
104
|
-
/**
|
|
105
|
-
* @description Styling for method names in the output.
|
|
106
|
-
*/
|
|
107
|
-
method: ThemeOption | ThemeOptionByLogLevel;
|
|
108
|
-
/**
|
|
109
|
-
* @description Styling for identifier elements in the output.
|
|
110
|
-
*/
|
|
111
|
-
id: ThemeOption | ThemeOptionByLogLevel;
|
|
112
|
-
/**
|
|
113
|
-
* @description Styling for identifier elements in the output.
|
|
114
|
-
*/
|
|
115
|
-
stack: ThemeOption;
|
|
116
|
-
/**
|
|
117
|
-
* @description Styling for different log levels in the output.
|
|
118
|
-
*/
|
|
119
|
-
logLevel: ThemeOptionByLogLevel;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @description Represents a color function in the Kleur library.
|
|
123
|
-
* @summary The Color interface defines a function that can be called with or without arguments
|
|
124
|
-
* to apply color styling to text or chain multiple color operations.
|
|
125
|
-
*
|
|
126
|
-
* @interface Color
|
|
127
|
-
* @memberOf module:@decaf-ts/utils
|
|
128
|
-
* */
|
|
129
|
-
export interface Color {
|
|
130
|
-
/**
|
|
131
|
-
* @description Applies the color to the given text.
|
|
132
|
-
* @param {string | number} x - The text or number to be colored.
|
|
133
|
-
* @return {string} The colored text.
|
|
134
|
-
*/
|
|
135
|
-
(x: string | number): string;
|
|
136
|
-
/**
|
|
137
|
-
* @description Allows chaining of multiple color operations.
|
|
138
|
-
* @return {Kleur} The Kleur instance for method chaining.
|
|
139
|
-
*/
|
|
140
|
-
(): Kleur;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* @description Represents the main Kleur interface with all available color and style methods.
|
|
144
|
-
* @summary The Kleur interface provides methods for applying various colors, background colors,
|
|
145
|
-
* and text styles to strings in terminal output.
|
|
146
|
-
*
|
|
147
|
-
* @interface Kleur
|
|
148
|
-
* @memberOf module:@decaf-ts/utils
|
|
149
|
-
*/
|
|
150
|
-
export interface Kleur {
|
|
151
|
-
/** @description Applies black color to the text. */
|
|
152
|
-
black: Color;
|
|
153
|
-
/** @description Applies red color to the text. */
|
|
154
|
-
red: Color;
|
|
155
|
-
/** @description Applies green color to the text. */
|
|
156
|
-
green: Color;
|
|
157
|
-
/** @description Applies yellow color to the text. */
|
|
158
|
-
yellow: Color;
|
|
159
|
-
/** @description Applies blue color to the text. */
|
|
160
|
-
blue: Color;
|
|
161
|
-
/** @description Applies magenta color to the text. */
|
|
162
|
-
magenta: Color;
|
|
163
|
-
/** @description Applies cyan color to the text. */
|
|
164
|
-
cyan: Color;
|
|
165
|
-
/** @description Applies white color to the text. */
|
|
166
|
-
white: Color;
|
|
167
|
-
/** @description Applies gray color to the text. */
|
|
168
|
-
gray: Color;
|
|
169
|
-
/** @description Alias for gray color. */
|
|
170
|
-
grey: Color;
|
|
171
|
-
/** @description Applies black background to the text. */
|
|
172
|
-
bgBlack: Color;
|
|
173
|
-
/** @description Applies red background to the text. */
|
|
174
|
-
bgRed: Color;
|
|
175
|
-
/** @description Applies green background to the text. */
|
|
176
|
-
bgGreen: Color;
|
|
177
|
-
/** @description Applies yellow background to the text. */
|
|
178
|
-
bgYellow: Color;
|
|
179
|
-
/** @description Applies blue background to the text. */
|
|
180
|
-
bgBlue: Color;
|
|
181
|
-
/** @description Applies magenta background to the text. */
|
|
182
|
-
bgMagenta: Color;
|
|
183
|
-
/** @description Applies cyan background to the text. */
|
|
184
|
-
bgCyan: Color;
|
|
185
|
-
/** @description Applies white background to the text. */
|
|
186
|
-
bgWhite: Color;
|
|
187
|
-
/** @description Resets all applied styles. */
|
|
188
|
-
reset: Color;
|
|
189
|
-
/** @description Applies bold style to the text. */
|
|
190
|
-
bold: Color;
|
|
191
|
-
/** @description Applies dim (decreased intensity) style to the text. */
|
|
192
|
-
dim: Color;
|
|
193
|
-
/** @description Applies italic style to the text. */
|
|
194
|
-
italic: Color;
|
|
195
|
-
/** @description Applies underline style to the text. */
|
|
196
|
-
underline: Color;
|
|
197
|
-
/** @description Inverts the foreground and background colors. */
|
|
198
|
-
inverse: Color;
|
|
199
|
-
/** @description Hides the text (same color as background). */
|
|
200
|
-
hidden: Color;
|
|
201
|
-
/** @description Applies strikethrough style to the text. */
|
|
202
|
-
strikethrough: Color;
|
|
203
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ObjectAccumulator = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @class ObjectAccumulator
|
|
6
|
-
* @template T - The type of the accumulated object, extends object
|
|
7
|
-
* @description A class that accumulates objects and provides type-safe access to their properties.
|
|
8
|
-
* It allows for dynamic addition of properties while maintaining type information.
|
|
9
|
-
* @summary Accumulates objects and maintains type information for accumulated properties
|
|
10
|
-
* @memberOf utils
|
|
11
|
-
*/
|
|
12
|
-
class ObjectAccumulator {
|
|
13
|
-
constructor() {
|
|
14
|
-
Object.defineProperty(this, "__size", {
|
|
15
|
-
value: 0,
|
|
16
|
-
writable: true,
|
|
17
|
-
configurable: false,
|
|
18
|
-
enumerable: false,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @protected
|
|
23
|
-
* @description Expands the accumulator with properties from a new object
|
|
24
|
-
* @summary Adds new properties to the accumulator
|
|
25
|
-
* @template V - The type of the object being expanded
|
|
26
|
-
* @param {V} value - The object to expand with
|
|
27
|
-
* @returns {void}
|
|
28
|
-
*/
|
|
29
|
-
expand(value) {
|
|
30
|
-
Object.entries(value).forEach(([k, v]) => {
|
|
31
|
-
Object.defineProperty(this, k, {
|
|
32
|
-
get: () => v,
|
|
33
|
-
set: (val) => {
|
|
34
|
-
v = val;
|
|
35
|
-
},
|
|
36
|
-
configurable: true,
|
|
37
|
-
enumerable: true,
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @description Accumulates a new object into the accumulator
|
|
43
|
-
* @summary Adds properties from a new object to the accumulator, maintaining type information
|
|
44
|
-
* @template V - The type of the object being accumulated
|
|
45
|
-
* @param {V} value - The object to accumulate
|
|
46
|
-
* @returns A new ObjectAccumulator instance with updated type information
|
|
47
|
-
* @mermaid
|
|
48
|
-
* sequenceDiagram
|
|
49
|
-
* participant A as Accumulator
|
|
50
|
-
* participant O as Object
|
|
51
|
-
* A->>O: Get entries
|
|
52
|
-
* loop For each entry
|
|
53
|
-
* A->>A: Define property
|
|
54
|
-
* end
|
|
55
|
-
* A->>A: Update size
|
|
56
|
-
* A->>A: Return updated accumulator
|
|
57
|
-
*/
|
|
58
|
-
accumulate(value) {
|
|
59
|
-
this.expand(value);
|
|
60
|
-
this.__size = this.__size + Object.keys(value).length;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @description Retrieves a value from the accumulator by its key
|
|
65
|
-
* @summary Gets a value from the accumulated object using a type-safe key
|
|
66
|
-
* @template K - The key type, must be a key of this
|
|
67
|
-
* @param {K} key - The key of the value to retrieve
|
|
68
|
-
* @returns {any | undefined} The value associated with the key, or undefined if not found
|
|
69
|
-
*/
|
|
70
|
-
get(key) {
|
|
71
|
-
return this[key];
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @description Checks if a key exists in the accumulator
|
|
75
|
-
* @summary Determines whether the accumulator contains a specific key
|
|
76
|
-
* @param {string} key - The key to check for existence
|
|
77
|
-
* @returns {boolean} True if the key exists, false otherwise
|
|
78
|
-
*/
|
|
79
|
-
has(key) {
|
|
80
|
-
return !!this[key];
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* @description Removes a key-value pair from the accumulator
|
|
84
|
-
* @summary Deletes a property from the accumulated object
|
|
85
|
-
* @param {string} key - The key of the property to remove
|
|
86
|
-
* @returns {} The accumulator instance with the specified property removed
|
|
87
|
-
*/
|
|
88
|
-
remove(key) {
|
|
89
|
-
if (!(key in this))
|
|
90
|
-
return this;
|
|
91
|
-
delete this[key];
|
|
92
|
-
this.__size--;
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @description Retrieves all keys from the accumulator
|
|
97
|
-
* @summary Gets an array of all accumulated property keys
|
|
98
|
-
* @returns {string[]} An array of keys as strings
|
|
99
|
-
*/
|
|
100
|
-
keys() {
|
|
101
|
-
return Object.keys(this);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* @description Retrieves all values from the accumulator
|
|
105
|
-
* @summary Gets an array of all accumulated property values
|
|
106
|
-
* @returns An array of values
|
|
107
|
-
*/
|
|
108
|
-
values() {
|
|
109
|
-
return Object.values(this);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* @description Gets the number of key-value pairs in the accumulator
|
|
113
|
-
* @summary Returns the count of accumulated properties
|
|
114
|
-
* @returns {number} The number of key-value pairs
|
|
115
|
-
*/
|
|
116
|
-
size() {
|
|
117
|
-
return this.__size;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* @description Clears all accumulated key-value pairs
|
|
121
|
-
* @summary Removes all properties from the accumulator and returns a new empty instance
|
|
122
|
-
* @returns {ObjectAccumulator<never>} A new empty ObjectAccumulator instance
|
|
123
|
-
*/
|
|
124
|
-
clear() {
|
|
125
|
-
return new ObjectAccumulator();
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* @description Executes a callback for each key-value pair in the accumulator
|
|
129
|
-
* @summary Iterates over all accumulated properties, calling a function for each
|
|
130
|
-
* @param {function(any, string, number): void} callback - The function to execute for each entry
|
|
131
|
-
* @returns {void}
|
|
132
|
-
*/
|
|
133
|
-
forEach(callback) {
|
|
134
|
-
Object.entries(this).forEach(([key, value], i) => callback(value, key, i));
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* @description Creates a new array with the results of calling a provided function on every element in the accumulator
|
|
138
|
-
* @summary Maps each accumulated property to a new value using a callback function
|
|
139
|
-
* @template R - The type of the mapped values
|
|
140
|
-
* @param {function(any, string,number): R} callback - Function that produces an element of the new array
|
|
141
|
-
* @returns {R[]} A new array with each element being the result of the callback function
|
|
142
|
-
*/
|
|
143
|
-
map(callback) {
|
|
144
|
-
return Object.entries(this).map(([key, value], i) => callback(value, key, i));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
exports.ObjectAccumulator = ObjectAccumulator;
|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|
|
1
|
-
/**
|
|
2
|
-
* @class ObjectAccumulator
|
|
3
|
-
* @template T - The type of the accumulated object, extends object
|
|
4
|
-
* @description A class that accumulates objects and provides type-safe access to their properties.
|
|
5
|
-
* It allows for dynamic addition of properties while maintaining type information.
|
|
6
|
-
* @summary Accumulates objects and maintains type information for accumulated properties
|
|
7
|
-
* @memberOf utils
|
|
8
|
-
*/
|
|
9
|
-
export declare class ObjectAccumulator<T extends object> {
|
|
10
|
-
/**
|
|
11
|
-
* @private
|
|
12
|
-
* @description The size of the accumulated object
|
|
13
|
-
* @type {number}
|
|
14
|
-
*/
|
|
15
|
-
private __size;
|
|
16
|
-
constructor();
|
|
17
|
-
/**
|
|
18
|
-
* @protected
|
|
19
|
-
* @description Expands the accumulator with properties from a new object
|
|
20
|
-
* @summary Adds new properties to the accumulator
|
|
21
|
-
* @template V - The type of the object being expanded
|
|
22
|
-
* @param {V} value - The object to expand with
|
|
23
|
-
* @returns {void}
|
|
24
|
-
*/
|
|
25
|
-
protected expand<V extends object>(value: V): void;
|
|
26
|
-
/**
|
|
27
|
-
* @description Accumulates a new object into the accumulator
|
|
28
|
-
* @summary Adds properties from a new object to the accumulator, maintaining type information
|
|
29
|
-
* @template V - The type of the object being accumulated
|
|
30
|
-
* @param {V} value - The object to accumulate
|
|
31
|
-
* @returns A new ObjectAccumulator instance with updated type information
|
|
32
|
-
* @mermaid
|
|
33
|
-
* sequenceDiagram
|
|
34
|
-
* participant A as Accumulator
|
|
35
|
-
* participant O as Object
|
|
36
|
-
* A->>O: Get entries
|
|
37
|
-
* loop For each entry
|
|
38
|
-
* A->>A: Define property
|
|
39
|
-
* end
|
|
40
|
-
* A->>A: Update size
|
|
41
|
-
* A->>A: Return updated accumulator
|
|
42
|
-
*/
|
|
43
|
-
accumulate<V extends object>(value: V): T & V & ObjectAccumulator<T & V>;
|
|
44
|
-
/**
|
|
45
|
-
* @description Retrieves a value from the accumulator by its key
|
|
46
|
-
* @summary Gets a value from the accumulated object using a type-safe key
|
|
47
|
-
* @template K - The key type, must be a key of this
|
|
48
|
-
* @param {K} key - The key of the value to retrieve
|
|
49
|
-
* @returns {any | undefined} The value associated with the key, or undefined if not found
|
|
50
|
-
*/
|
|
51
|
-
get<K extends keyof this>(key: K): this[K] | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* @description Checks if a key exists in the accumulator
|
|
54
|
-
* @summary Determines whether the accumulator contains a specific key
|
|
55
|
-
* @param {string} key - The key to check for existence
|
|
56
|
-
* @returns {boolean} True if the key exists, false otherwise
|
|
57
|
-
*/
|
|
58
|
-
has(key: string): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* @description Removes a key-value pair from the accumulator
|
|
61
|
-
* @summary Deletes a property from the accumulated object
|
|
62
|
-
* @param {string} key - The key of the property to remove
|
|
63
|
-
* @returns {} The accumulator instance with the specified property removed
|
|
64
|
-
*/
|
|
65
|
-
remove(key: keyof this | string): (Omit<this, typeof key> & ObjectAccumulator<Omit<this, typeof key>>) | this;
|
|
66
|
-
/**
|
|
67
|
-
* @description Retrieves all keys from the accumulator
|
|
68
|
-
* @summary Gets an array of all accumulated property keys
|
|
69
|
-
* @returns {string[]} An array of keys as strings
|
|
70
|
-
*/
|
|
71
|
-
keys(): string[];
|
|
72
|
-
/**
|
|
73
|
-
* @description Retrieves all values from the accumulator
|
|
74
|
-
* @summary Gets an array of all accumulated property values
|
|
75
|
-
* @returns An array of values
|
|
76
|
-
*/
|
|
77
|
-
values(): T[keyof T][];
|
|
78
|
-
/**
|
|
79
|
-
* @description Gets the number of key-value pairs in the accumulator
|
|
80
|
-
* @summary Returns the count of accumulated properties
|
|
81
|
-
* @returns {number} The number of key-value pairs
|
|
82
|
-
*/
|
|
83
|
-
size(): number;
|
|
84
|
-
/**
|
|
85
|
-
* @description Clears all accumulated key-value pairs
|
|
86
|
-
* @summary Removes all properties from the accumulator and returns a new empty instance
|
|
87
|
-
* @returns {ObjectAccumulator<never>} A new empty ObjectAccumulator instance
|
|
88
|
-
*/
|
|
89
|
-
clear(): ObjectAccumulator<never>;
|
|
90
|
-
/**
|
|
91
|
-
* @description Executes a callback for each key-value pair in the accumulator
|
|
92
|
-
* @summary Iterates over all accumulated properties, calling a function for each
|
|
93
|
-
* @param {function(any, string, number): void} callback - The function to execute for each entry
|
|
94
|
-
* @returns {void}
|
|
95
|
-
*/
|
|
96
|
-
forEach(callback: (value: this[keyof this], key: keyof this, i: number) => void): void;
|
|
97
|
-
/**
|
|
98
|
-
* @description Creates a new array with the results of calling a provided function on every element in the accumulator
|
|
99
|
-
* @summary Maps each accumulated property to a new value using a callback function
|
|
100
|
-
* @template R - The type of the mapped values
|
|
101
|
-
* @param {function(any, string,number): R} callback - Function that produces an element of the new array
|
|
102
|
-
* @returns {R[]} A new array with each element being the result of the callback function
|
|
103
|
-
*/
|
|
104
|
-
map<R>(callback: (value: this[keyof this], key: keyof this, i: number) => R): R[];
|
|
105
|
-
}
|