@ix-xs/node-comfort 1.1.31 → 1.2.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.
@@ -0,0 +1,293 @@
1
+ /**
2
+ * Capitalizes the first character of a string and lowercases the rest.
3
+ *
4
+ * @example
5
+ * nodeComfort.str.capitalize("hELLO"); // "Hello"
6
+ *
7
+ * @param {string} str - Input string.
8
+ * @returns {string} The capitalized string.
9
+ */
10
+ export function capitalize(str: string): string;
11
+ /**
12
+ * Uppercases the first character of each word (Title Case), leaving the rest untouched.
13
+ *
14
+ * @example
15
+ * nodeComfort.str.titleCase("the quick brown fox"); // "The Quick Brown Fox"
16
+ *
17
+ * @param {string} str - Input string.
18
+ * @returns {string} The title-cased string.
19
+ */
20
+ export function titleCase(str: string): string;
21
+ /**
22
+ * Converts a string to `camelCase`.
23
+ *
24
+ * @example
25
+ * nodeComfort.str.camelCase("hello world"); // "helloWorld"
26
+ * nodeComfort.str.camelCase("foo-bar_baz"); // "fooBarBaz"
27
+ *
28
+ * @param {string} str - Input string.
29
+ * @returns {string} The camelCased string.
30
+ */
31
+ export function camelCase(str: string): string;
32
+ /**
33
+ * Converts a string to `PascalCase`.
34
+ *
35
+ * @example
36
+ * nodeComfort.str.pascalCase("hello world"); // "HelloWorld"
37
+ *
38
+ * @param {string} str - Input string.
39
+ * @returns {string} The PascalCased string.
40
+ */
41
+ export function pascalCase(str: string): string;
42
+ /**
43
+ * Converts a string to `snake_case`.
44
+ *
45
+ * @example
46
+ * nodeComfort.str.snakeCase("helloWorld"); // "hello_world"
47
+ *
48
+ * @param {string} str - Input string.
49
+ * @returns {string} The snake_cased string.
50
+ */
51
+ export function snakeCase(str: string): string;
52
+ /**
53
+ * Converts a string to `kebab-case`.
54
+ *
55
+ * @example
56
+ * nodeComfort.str.kebabCase("helloWorld"); // "hello-world"
57
+ *
58
+ * @param {string} str - Input string.
59
+ * @returns {string} The kebab-cased string.
60
+ */
61
+ export function kebabCase(str: string): string;
62
+ /**
63
+ * Converts a string to `CONSTANT_CASE`.
64
+ *
65
+ * @example
66
+ * nodeComfort.str.constantCase("helloWorld"); // "HELLO_WORLD"
67
+ *
68
+ * @param {string} str - Input string.
69
+ * @returns {string} The CONSTANT_CASED string.
70
+ */
71
+ export function constantCase(str: string): string;
72
+ /**
73
+ * Converts a string into a URL-friendly slug.
74
+ *
75
+ * Accents/diacritics are stripped, non-alphanumeric runs become the separator.
76
+ *
77
+ * @example
78
+ * nodeComfort.str.slugify("Héllo, World!"); // "hello-world"
79
+ * nodeComfort.str.slugify("A B C", { separator: "_" }); // "a_b_c"
80
+ *
81
+ * @param {string} str - Input string.
82
+ * @param {{ separator?: string, lower?: boolean }} [options] - Slug options.
83
+ * @returns {string} The slug.
84
+ */
85
+ export function slugify(str: string, options?: {
86
+ separator?: string;
87
+ lower?: boolean;
88
+ }): string;
89
+ /**
90
+ * Truncates a string to a maximum length, appending an ellipsis if cut.
91
+ *
92
+ * @example
93
+ * nodeComfort.str.truncate("Hello world", 8); // "Hello…"
94
+ * nodeComfort.str.truncate("Hello world", 8, { omission: "..." }); // "Hello..."
95
+ *
96
+ * @param {string} str - Input string.
97
+ * @param {number} length - Maximum length of the result (including the omission).
98
+ * @param {{ omission?: string, words?: boolean }} [options] - Truncation options.
99
+ * @returns {string} The truncated string.
100
+ */
101
+ export function truncate(str: string, length: number, options?: {
102
+ omission?: string;
103
+ words?: boolean;
104
+ }): string;
105
+ /**
106
+ * Pads a string on the left (start) to a target length.
107
+ *
108
+ * @param {string} str - Input string.
109
+ * @param {number} length - Target total length.
110
+ * @param {string} [char=" "] - Padding character(s).
111
+ * @returns {string} The padded string.
112
+ */
113
+ export function padStart(str: string, length: number, char?: string): string;
114
+ /**
115
+ * Pads a string on the right (end) to a target length.
116
+ *
117
+ * @param {string} str - Input string.
118
+ * @param {number} length - Target total length.
119
+ * @param {string} [char=" "] - Padding character(s).
120
+ * @returns {string} The padded string.
121
+ */
122
+ export function padEnd(str: string, length: number, char?: string): string;
123
+ /**
124
+ * Centers a string within a target length by padding both sides.
125
+ *
126
+ * @example
127
+ * nodeComfort.str.center("hi", 6); // " hi "
128
+ * nodeComfort.str.center("hi", 6, "*"); // "**hi**"
129
+ *
130
+ * @param {string} str - Input string.
131
+ * @param {number} length - Target total length.
132
+ * @param {string} [char=" "] - Padding character.
133
+ * @returns {string} The centered string.
134
+ */
135
+ export function center(str: string, length: number, char?: string): string;
136
+ /**
137
+ * Reverses a string (Unicode code-point aware, so emojis stay intact).
138
+ *
139
+ * @example
140
+ * nodeComfort.str.reverse("abc"); // "cba"
141
+ *
142
+ * @param {string} str - Input string.
143
+ * @returns {string} The reversed string.
144
+ */
145
+ export function reverse(str: string): string;
146
+ /**
147
+ * Collapses all runs of whitespace into single spaces and trims the ends.
148
+ *
149
+ * @example
150
+ * nodeComfort.str.squish(" hello world \n"); // "hello world"
151
+ *
152
+ * @param {string} str - Input string.
153
+ * @returns {string} The normalized string.
154
+ */
155
+ export function squish(str: string): string;
156
+ /**
157
+ * Removes all HTML tags from a string.
158
+ *
159
+ * @example
160
+ * nodeComfort.str.stripTags("<b>Hi</b> there"); // "Hi there"
161
+ *
162
+ * @param {string} str - Input string.
163
+ * @returns {string} The string with tags removed.
164
+ */
165
+ export function stripTags(str: string): string;
166
+ /**
167
+ * Escapes HTML-sensitive characters (`& < > " '`).
168
+ *
169
+ * @example
170
+ * nodeComfort.str.escapeHTML('<a href="x">'); // "&lt;a href=&quot;x&quot;&gt;"
171
+ *
172
+ * @param {string} str - Input string.
173
+ * @returns {string} The escaped string.
174
+ */
175
+ export function escapeHTML(str: string): string;
176
+ /**
177
+ * Reverses {@link escapeHTML}: turns HTML entities back into characters.
178
+ *
179
+ * @param {string} str - Input string.
180
+ * @returns {string} The unescaped string.
181
+ */
182
+ export function unescapeHTML(str: string): string;
183
+ /**
184
+ * Escapes a string for safe use inside a `RegExp`.
185
+ *
186
+ * @example
187
+ * new RegExp(nodeComfort.str.escapeRegExp("a.b")); // matches literal "a.b"
188
+ *
189
+ * @param {string} str - Input string.
190
+ * @returns {string} The escaped string.
191
+ */
192
+ export function escapeRegExp(str: string): string;
193
+ /**
194
+ * Counts the number of non-overlapping occurrences of a substring.
195
+ *
196
+ * @example
197
+ * nodeComfort.str.count("banana", "a"); // 3
198
+ *
199
+ * @param {string} str - Input string.
200
+ * @param {string} sub - Substring to count.
201
+ * @returns {number} Number of occurrences.
202
+ */
203
+ export function count(str: string, sub: string): number;
204
+ /**
205
+ * Ensures a string starts with a given prefix (adds it only if missing).
206
+ *
207
+ * @example
208
+ * nodeComfort.str.ensurePrefix("example.com", "https://"); // "https://example.com"
209
+ *
210
+ * @param {string} str - Input string.
211
+ * @param {string} prefix - Prefix to ensure.
212
+ * @returns {string} The string with the prefix guaranteed.
213
+ */
214
+ export function ensurePrefix(str: string, prefix: string): string;
215
+ /**
216
+ * Ensures a string ends with a given suffix (adds it only if missing).
217
+ *
218
+ * @example
219
+ * nodeComfort.str.ensureSuffix("path", "/"); // "path/"
220
+ *
221
+ * @param {string} str - Input string.
222
+ * @param {string} suffix - Suffix to ensure.
223
+ * @returns {string} The string with the suffix guaranteed.
224
+ */
225
+ export function ensureSuffix(str: string, suffix: string): string;
226
+ /**
227
+ * Removes a prefix from a string if present.
228
+ *
229
+ * @param {string} str - Input string.
230
+ * @param {string} prefix - Prefix to remove.
231
+ * @returns {string} The string without the prefix.
232
+ */
233
+ export function removePrefix(str: string, prefix: string): string;
234
+ /**
235
+ * Removes a suffix from a string if present.
236
+ *
237
+ * @param {string} str - Input string.
238
+ * @param {string} suffix - Suffix to remove.
239
+ * @returns {string} The string without the suffix.
240
+ */
241
+ export function removeSuffix(str: string, suffix: string): string;
242
+ /**
243
+ * Renders a template, replacing `{key}` placeholders with values from `data`.
244
+ *
245
+ * Missing keys are left as-is by default. Nested paths (`{user.name}`) are supported.
246
+ *
247
+ * @example
248
+ * nodeComfort.str.template("Hi {name}, you have {count} msgs", { name: "Jo", count: 3 });
249
+ * // "Hi Jo, you have 3 msgs"
250
+ *
251
+ * @param {string} str - Template string.
252
+ * @param {Record<string, any>} data - Replacement values.
253
+ * @param {{ open?: string, close?: string, fallback?: string }} [options] - Delimiters / fallback.
254
+ * @returns {string} The rendered string.
255
+ */
256
+ export function template(str: string, data: Record<string, any>, options?: {
257
+ open?: string;
258
+ close?: string;
259
+ fallback?: string;
260
+ }): string;
261
+ /**
262
+ * Splits a string into an array of "words" (camelCase / snake / kebab aware).
263
+ *
264
+ * @example
265
+ * nodeComfort.str.words("helloWorld-foo_bar"); // ["hello", "World", "foo", "bar"]
266
+ *
267
+ * @param {string} str - Input string.
268
+ * @returns {string[]} The words.
269
+ */
270
+ export function words(str: string): string[];
271
+ /**
272
+ * Returns the visible length of a string in code points (emoji-safe).
273
+ *
274
+ * @example
275
+ * "😀".length; // 2
276
+ * nodeComfort.str.length("😀"); // 1
277
+ *
278
+ * @param {string} str - Input string.
279
+ * @returns {number} The number of code points.
280
+ */
281
+ export function length(str: string): number;
282
+ /**
283
+ * Generates a random alphanumeric string of a given length.
284
+ *
285
+ * Note: uses `Math.random` and is **not** cryptographically secure.
286
+ * For tokens/IDs use `nodeComfort.id.token()` instead.
287
+ *
288
+ * @param {number} [length=16] - Desired length.
289
+ * @param {string} [charset] - Characters to pick from.
290
+ * @returns {string} The random string.
291
+ */
292
+ export function random(length?: number, charset?: string): string;
293
+ //# sourceMappingURL=Str.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Str.d.ts","sourceRoot":"","sources":["../../src/Str.js"],"names":[],"mappings":"AA2BE;;;;;;;;GAQG;AACH,gCAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;;;GAQG;AACH,+BAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;;;;GASG;AACH,+BAHW,MAAM,GACJ,MAAM,CAUlB;AAED;;;;;;;;GAQG;AACH,gCAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;;;GAQG;AACH,+BAHW,MAAM,GACJ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N,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;;GAMG;AACH,kCAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;;;;;;;;;GAaG;AACH,8BALW,MAAM,QACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YACnB;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD,MAAM,CAclB;AAED;;;;;;;;GAQG;AACH,2BAHW,MAAM,GACJ,MAAM,EAAE,CAIpB;AAED;;;;;;;;;GASG;AACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;;;;GASG;AACH,gCAJW,MAAM,YACN,MAAM,GACJ,MAAM,CAQlB"}
@@ -0,0 +1,205 @@
1
+ declare namespace _exports {
2
+ export { TimeModule };
3
+ }
4
+ declare namespace _exports {
5
+ /**
6
+ * Sets the global default locale used by `relative`, `formatDuration` and
7
+ * `format` (named tokens). Chainable.
8
+ *
9
+ * @example
10
+ * nodeComfort.time.setLocale("fr");
11
+ *
12
+ * @param {string} locale - A BCP-47 locale tag (e.g. `"fr"`, `"en-GB"`, `"ja"`).
13
+ * @returns {TimeModule} The time module (for chaining).
14
+ */
15
+ function setLocale(locale: string): TimeModule;
16
+ /**
17
+ * Sets the global default time zone used by `format` and `isSameDay`.
18
+ * Chainable. Pass `undefined` to fall back to the system local zone.
19
+ *
20
+ * @example
21
+ * nodeComfort.time.setTimezone("Europe/Paris");
22
+ *
23
+ * @param {string|undefined} timeZone - An IANA time-zone name (e.g. `"America/New_York"`).
24
+ * @returns {TimeModule} The time module (for chaining).
25
+ */
26
+ function setTimezone(timeZone: string | undefined): TimeModule;
27
+ /**
28
+ * Returns the current global `{ locale, timeZone }` defaults.
29
+ *
30
+ * @returns {{ locale: string, timeZone: string|undefined }} A copy of the config.
31
+ */
32
+ function getConfig(): {
33
+ locale: string;
34
+ timeZone: string | undefined;
35
+ };
36
+ /**
37
+ * Parses a human duration string into milliseconds.
38
+ *
39
+ * Accepts things like `"1h"`, `"30m"`, `"1h30m"`, `"2 days"`, `"500ms"`.
40
+ * A plain number is treated as milliseconds.
41
+ *
42
+ * @example
43
+ * nodeComfort.time.parseDuration("1h30m"); // 5400000
44
+ * nodeComfort.time.parseDuration("2 days"); // 172800000
45
+ *
46
+ * @param {string|number} input - Duration string or millisecond count.
47
+ * @returns {number|null} Milliseconds, or null if it can't be parsed.
48
+ */
49
+ function parseDuration(input: string | number): number | null;
50
+ /**
51
+ * Formats a millisecond duration into a human string.
52
+ *
53
+ * The compact form (default) is language-neutral (`"1h 30m"`). The `long`
54
+ * form is fully localized through `Intl` • pass `options.locale` or set a
55
+ * global locale with {@link module:Time.setLocale}.
56
+ *
57
+ * @example
58
+ * nodeComfort.time.formatDuration(5400000); // "1h 30m"
59
+ * nodeComfort.time.formatDuration(90000, { long: true }); // "1 minute 30 seconds"
60
+ * nodeComfort.time.formatDuration(90000, { long: true, locale: "fr" }); // "1 minute 30 secondes"
61
+ *
62
+ * @param {number} ms - Duration in milliseconds.
63
+ * @param {{ long?: boolean, units?: number, locale?: string }} [options] - Formatting options (`units` caps how many parts show).
64
+ * @returns {string} The formatted duration.
65
+ */
66
+ function formatDuration(ms: number, options?: {
67
+ long?: boolean;
68
+ units?: number;
69
+ locale?: string;
70
+ }): string;
71
+ /**
72
+ * Returns a human-friendly, localized relative time string.
73
+ *
74
+ * Built on `Intl.RelativeTimeFormat`, so it speaks every language. Set
75
+ * `options.locale` (or a global locale) to translate; `options.numeric`
76
+ * controls wording (`"always"` → "1 day ago", `"auto"` → "yesterday").
77
+ *
78
+ * @example
79
+ * nodeComfort.time.relative(Date.now() - 3600e3); // "1 hour ago"
80
+ * nodeComfort.time.relative(Date.now() - 3600e3, undefined, { locale: "fr" }); // "il y a 1 heure"
81
+ * nodeComfort.time.relative(Date.now() - 86400e3, undefined, { numeric: "auto" }); // "yesterday"
82
+ *
83
+ * @param {Date|number|string} date - Target date.
84
+ * @param {Date|number|string} [from] - Reference date (defaults to now).
85
+ * @param {{ locale?: string, numeric?: "always"|"auto" }} [options] - Formatting options.
86
+ * @returns {string} The relative time string.
87
+ */
88
+ function relative(date: Date | number | string, from?: Date | number | string, options?: {
89
+ locale?: string;
90
+ numeric?: "always" | "auto";
91
+ }): string;
92
+ /**
93
+ * Formats a date using a small token syntax, with optional locale & time zone.
94
+ *
95
+ * **Numeric tokens:** `YYYY` `YY` `MM` `M` `DD` `D` `HH` `H` (24h) `hh` `h`
96
+ * (12h) `mm` `m` `ss` `s` `SSS`.
97
+ * **Localized tokens:** `MMMM` (month name) `MMM` (short month) `dddd` (weekday)
98
+ * `ddd` (short weekday) `A` (AM/PM) `a` (am/pm).
99
+ *
100
+ * Wrap literal text in square brackets to keep it verbatim: `"[Today is] dddd"`.
101
+ *
102
+ * @example
103
+ * nodeComfort.time.format(new Date(), "YYYY-MM-DD HH:mm:ss");
104
+ * nodeComfort.time.format(Date.now(), "dddd D MMMM YYYY", { locale: "fr" });
105
+ * nodeComfort.time.format(Date.now(), "HH:mm", { timeZone: "Asia/Tokyo" });
106
+ *
107
+ * @param {Date|number|string} date - Date to format.
108
+ * @param {string} [pattern="YYYY-MM-DD HH:mm:ss"] - Format pattern.
109
+ * @param {{ locale?: string, timeZone?: string }} [options] - Locale / time-zone overrides.
110
+ * @returns {string} The formatted date.
111
+ */
112
+ function format(date: Date | number | string, pattern?: string, options?: {
113
+ locale?: string;
114
+ timeZone?: string;
115
+ }): string;
116
+ /**
117
+ * Adds a duration to a date and returns a new Date.
118
+ *
119
+ * The duration may be a millisecond number or a string like `"1h30m"`.
120
+ *
121
+ * @example
122
+ * nodeComfort.time.add(new Date(), "2h");
123
+ * nodeComfort.time.add(new Date(), -1, "days");
124
+ *
125
+ * @param {Date|number|string} date - Base date.
126
+ * @param {number|string} amount - Amount (ms/string) or a number paired with `unit`.
127
+ * @param {"ms"|"s"|"m"|"h"|"d"|"w"} [unit] - Unit when `amount` is a plain number.
128
+ * @returns {Date} The resulting date.
129
+ */
130
+ function add(date: Date | number | string, amount: number | string, unit?: "ms" | "s" | "m" | "h" | "d" | "w"): Date;
131
+ /**
132
+ * Subtracts a duration from a date and returns a new Date.
133
+ *
134
+ * @param {Date|number|string} date - Base date.
135
+ * @param {number|string} amount - Amount (ms/string) or a number paired with `unit`.
136
+ * @param {"ms"|"s"|"m"|"h"|"d"|"w"} [unit] - Unit when `amount` is a plain number.
137
+ * @returns {Date} The resulting date.
138
+ */
139
+ function subtract(date: Date | number | string, amount: number | string, unit?: "ms" | "s" | "m" | "h" | "d" | "w"): Date;
140
+ /**
141
+ * Returns the difference between two dates in the requested unit.
142
+ *
143
+ * @example
144
+ * nodeComfort.time.diff("2024-01-02", "2024-01-01", "d"); // 1
145
+ *
146
+ * @param {Date|number|string} a - First date.
147
+ * @param {Date|number|string} b - Second date.
148
+ * @param {"ms"|"s"|"m"|"h"|"d"|"w"} [unit="ms"] - Result unit.
149
+ * @returns {number} The signed difference (`a - b`) in the given unit.
150
+ */
151
+ function diff(a: Date | number | string, b: Date | number | string, unit?: "ms" | "s" | "m" | "h" | "d" | "w"): number;
152
+ /**
153
+ * Checks whether two dates fall on the same calendar day.
154
+ *
155
+ * Uses local time by default; pass `options.timeZone` (or set a global zone)
156
+ * to compare calendar days in a specific zone.
157
+ *
158
+ * @param {Date|number|string} a - First date.
159
+ * @param {Date|number|string} b - Second date.
160
+ * @param {{ timeZone?: string }} [options] - Time-zone override.
161
+ * @returns {boolean} True if both are the same day.
162
+ */
163
+ function isSameDay(a: Date | number | string, b: Date | number | string, options?: {
164
+ timeZone?: string;
165
+ }): boolean;
166
+ /**
167
+ * Returns a new Date at the start of the given unit (day/hour/etc).
168
+ *
169
+ * @example
170
+ * nodeComfort.time.startOf(new Date(), "day"); // midnight today
171
+ *
172
+ * @param {Date|number|string} date - Base date.
173
+ * @param {"year"|"month"|"day"|"hour"|"minute"|"second"} unit - Unit to reset to.
174
+ * @returns {Date} The start-of-unit date.
175
+ */
176
+ function startOf(date: Date | number | string, unit: "year" | "month" | "day" | "hour" | "minute" | "second"): Date;
177
+ /**
178
+ * Returns the current Unix timestamp in seconds.
179
+ *
180
+ * @returns {number} Seconds since the Unix epoch.
181
+ */
182
+ function unix(): number;
183
+ /**
184
+ * Returns a high-resolution stopwatch you can `.stop()` to get elapsed ms.
185
+ *
186
+ * @example
187
+ * const timer = nodeComfort.time.stopwatch();
188
+ * doWork();
189
+ * console.log(timer.stop()); // e.g. 12.34 (ms, sub-ms precise)
190
+ * console.log(timer.stop(true)); // "12.34ms"
191
+ *
192
+ * @returns {{ elapsed: () => number, stop: (format?: boolean) => number|string }} A stopwatch handle.
193
+ */
194
+ function stopwatch(): {
195
+ elapsed: () => number;
196
+ stop: (format?: boolean) => number | string;
197
+ };
198
+ }
199
+ export = _exports;
200
+ /**
201
+ * The time module itself • used as the return type of the chainable setters so
202
+ * `setLocale().setTimezone()...` stays fully typed without inlining the type.
203
+ */
204
+ type TimeModule = typeof import("./Time");
205
+ //# sourceMappingURL=Time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Time.d.ts","sourceRoot":"","sources":["../../src/Time.js"],"names":[],"mappings":";;;;IA2HE;;;;;;;;;OASG;IACH,2BAHW,MAAM,GACJ,UAAU,CAKtB;IAED;;;;;;;;;OASG;IACH,+BAHW,MAAM,GAAC,SAAS,GACd,UAAU,CAKtB;IAED;;;;OAIG;IACH,sBAFa;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAC,SAAS,CAAA;KAAE,CAI1D;IAED;;;;;;;;;;;;OAYG;IACH,8BAHW,MAAM,GAAC,MAAM,GACX,MAAM,GAAC,IAAI,CAkBvB;IAED;;;;;;;;;;;;;;;OAeG;IACH,4BAJW,MAAM,YACN;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE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,MAAM,GAAC,OAAO,GAAC,KAAK,GAAC,MAAM,GAAC,QAAQ,GAAC,QAAQ,GAC3C,IAAI,CAkBhB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IAED;;;;;;;;;;OAUG;IACH,sBAFa;QAAE,OAAO,EAAE,MAAM,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,MAAM,GAAC,MAAM,CAAA;KAAE,CAYhF;;;;;;;kBAxcU,cAAc,QAAQ,CAAC"}
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "nodenext",
5
- "allowJs": true,
6
- "declaration": true,
7
- "emitDeclarationOnly": true,
8
- "outDir": "types",
9
- "declarationMap": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "moduleResolution": "nodenext",
13
- "esModuleInterop": true,
14
- "resolveJsonModule": true
15
- },
16
- "include": ["**/*"],
17
- "exclude": ["node_modules", "types"]
18
- }