@mnaoumov/typescript-lib 0.0.0 → 1.0.1
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/@types/debug/package.json +4 -0
- package/LICENSE +21 -0
- package/README.md +15 -1
- package/dist/lib/cjs/@types/debug.d.cts +21 -0
- package/dist/lib/cjs/abort-controller.cjs +144 -0
- package/dist/lib/cjs/abort-controller.d.cts +136 -0
- package/dist/lib/cjs/aggregate-error.cjs +40 -0
- package/dist/lib/cjs/aggregate-error.d.cts +24 -0
- package/dist/lib/cjs/array-buffer.cjs +38 -0
- package/dist/lib/cjs/array-buffer.d.cts +16 -0
- package/dist/lib/cjs/array.cjs +76 -0
- package/dist/lib/cjs/array.d.cts +46 -0
- package/dist/lib/cjs/async-events.cjs +408 -0
- package/dist/lib/cjs/async-events.d.cts +456 -0
- package/dist/lib/cjs/async-operation-hook.cjs +55 -0
- package/dist/lib/cjs/async-operation-hook.d.cts +59 -0
- package/dist/lib/cjs/async.cjs +463 -0
- package/dist/lib/cjs/async.d.cts +415 -0
- package/dist/lib/cjs/beeper.cjs +68 -0
- package/dist/lib/cjs/beeper.d.cts +21 -0
- package/dist/lib/cjs/blob.cjs +102 -0
- package/dist/lib/cjs/blob.d.cts +60 -0
- package/dist/lib/cjs/bytes.cjs +56 -0
- package/dist/lib/cjs/bytes.d.cts +17 -0
- package/dist/lib/cjs/debug-controller.cjs +22 -0
- package/dist/lib/cjs/debug-controller.d.cts +87 -0
- package/dist/lib/cjs/debug.cjs +204 -0
- package/dist/lib/cjs/debug.d.cts +66 -0
- package/dist/lib/cjs/desktop-zip-extractor.cjs +157 -0
- package/dist/lib/cjs/desktop-zip-extractor.d.cts +96 -0
- package/dist/lib/cjs/disposable.cjs +364 -0
- package/dist/lib/cjs/disposable.d.cts +387 -0
- package/dist/lib/cjs/enum.cjs +42 -0
- package/dist/lib/cjs/enum.d.cts +24 -0
- package/dist/lib/cjs/error.cjs +239 -0
- package/dist/lib/cjs/error.d.cts +182 -0
- package/dist/lib/cjs/function.cjs +83 -0
- package/dist/lib/cjs/function.d.cts +128 -0
- package/dist/lib/cjs/html-element.cjs +283 -0
- package/dist/lib/cjs/html-element.d.cts +200 -0
- package/dist/lib/cjs/index.cjs +137 -0
- package/dist/lib/cjs/index.d.cts +33 -0
- package/dist/lib/cjs/jpeg-metadata.cjs +170 -0
- package/dist/lib/cjs/jpeg-metadata.d.cts +42 -0
- package/dist/lib/cjs/library-references.d.cts +2 -0
- package/dist/lib/cjs/library.cjs +100 -0
- package/dist/lib/cjs/library.d.cts +96 -0
- package/dist/lib/cjs/object-utils.cjs +559 -0
- package/dist/lib/cjs/object-utils.d.cts +298 -0
- package/dist/lib/cjs/path.cjs +171 -0
- package/dist/lib/cjs/path.d.cts +155 -0
- package/dist/lib/cjs/reg-exp.cjs +196 -0
- package/dist/lib/cjs/reg-exp.d.cts +87 -0
- package/dist/lib/cjs/string.cjs +268 -0
- package/dist/lib/cjs/string.d.cts +362 -0
- package/dist/lib/cjs/transformers/date-transformer.cjs +71 -0
- package/dist/lib/cjs/transformers/date-transformer.d.cts +39 -0
- package/dist/lib/cjs/transformers/group-transformer.cjs +115 -0
- package/dist/lib/cjs/transformers/group-transformer.d.cts +70 -0
- package/dist/lib/cjs/transformers/index.cjs +65 -0
- package/dist/lib/cjs/transformers/index.d.cts +9 -0
- package/dist/lib/cjs/transformers/map-transformer.cjs +71 -0
- package/dist/lib/cjs/transformers/map-transformer.d.cts +41 -0
- package/dist/lib/cjs/transformers/set-transformer.cjs +71 -0
- package/dist/lib/cjs/transformers/set-transformer.d.cts +39 -0
- package/dist/lib/cjs/transformers/skip-private-property-transformer.cjs +69 -0
- package/dist/lib/cjs/transformers/skip-private-property-transformer.d.cts +36 -0
- package/dist/lib/cjs/transformers/transformer.cjs +112 -0
- package/dist/lib/cjs/transformers/transformer.d.cts +70 -0
- package/dist/lib/cjs/transformers/two-way-map-transformer.cjs +72 -0
- package/dist/lib/cjs/transformers/two-way-map-transformer.d.cts +42 -0
- package/dist/lib/cjs/transformers/typed-transformer.cjs +36 -0
- package/dist/lib/cjs/transformers/typed-transformer.d.cts +39 -0
- package/dist/lib/cjs/two-way-map.cjs +150 -0
- package/dist/lib/cjs/two-way-map.d.cts +101 -0
- package/dist/lib/cjs/type-guards.cjs +70 -0
- package/dist/lib/cjs/type-guards.d.cts +84 -0
- package/dist/lib/cjs/type.cjs +63 -0
- package/dist/lib/cjs/type.d.cts +122 -0
- package/dist/lib/cjs/typescript-lib-state.cjs +68 -0
- package/dist/lib/cjs/typescript-lib-state.d.cts +56 -0
- package/dist/lib/cjs/url.cjs +78 -0
- package/dist/lib/cjs/url.d.cts +74 -0
- package/dist/lib/cjs/value-provider.cjs +42 -0
- package/dist/lib/cjs/value-provider.d.cts +29 -0
- package/dist/lib/cjs/value-wrapper.cjs +86 -0
- package/dist/lib/cjs/value-wrapper.d.cts +47 -0
- package/dist/lib/esm/@types/debug.d.mts +21 -0
- package/dist/lib/esm/abort-controller.d.mts +136 -0
- package/dist/lib/esm/abort-controller.mjs +115 -0
- package/dist/lib/esm/aggregate-error.d.mts +24 -0
- package/dist/lib/esm/aggregate-error.mjs +16 -0
- package/dist/lib/esm/array-buffer.d.mts +16 -0
- package/dist/lib/esm/array-buffer.mjs +14 -0
- package/dist/lib/esm/array.d.mts +46 -0
- package/dist/lib/esm/array.mjs +49 -0
- package/dist/lib/esm/async-events.d.mts +456 -0
- package/dist/lib/esm/async-events.mjs +383 -0
- package/dist/lib/esm/async-operation-hook.d.mts +59 -0
- package/dist/lib/esm/async-operation-hook.mjs +27 -0
- package/dist/lib/esm/async.d.mts +415 -0
- package/dist/lib/esm/async.mjs +435 -0
- package/dist/lib/esm/beeper.d.mts +21 -0
- package/dist/lib/esm/beeper.mjs +44 -0
- package/dist/lib/esm/blob.d.mts +60 -0
- package/dist/lib/esm/blob.mjs +77 -0
- package/dist/lib/esm/bytes.d.mts +17 -0
- package/dist/lib/esm/bytes.mjs +32 -0
- package/dist/lib/esm/debug-controller.d.mts +87 -0
- package/dist/lib/esm/debug-controller.mjs +6 -0
- package/dist/lib/esm/debug.d.mts +66 -0
- package/dist/lib/esm/debug.mjs +168 -0
- package/dist/lib/esm/desktop-zip-extractor.d.mts +96 -0
- package/dist/lib/esm/desktop-zip-extractor.mjs +136 -0
- package/dist/lib/esm/disposable.d.mts +387 -0
- package/dist/lib/esm/disposable.mjs +324 -0
- package/dist/lib/esm/enum.d.mts +24 -0
- package/dist/lib/esm/enum.mjs +17 -0
- package/dist/lib/esm/error.d.mts +182 -0
- package/dist/lib/esm/error.mjs +204 -0
- package/dist/lib/esm/function.d.mts +128 -0
- package/dist/lib/esm/function.mjs +52 -0
- package/dist/lib/esm/html-element.d.mts +200 -0
- package/dist/lib/esm/html-element.mjs +247 -0
- package/dist/lib/esm/index.d.mts +33 -0
- package/dist/lib/esm/index.mjs +72 -0
- package/dist/lib/esm/jpeg-metadata.d.mts +42 -0
- package/dist/lib/esm/jpeg-metadata.mjs +145 -0
- package/dist/lib/esm/library-references.d.mts +2 -0
- package/dist/lib/esm/library.d.mts +96 -0
- package/dist/lib/esm/library.mjs +74 -0
- package/dist/lib/esm/object-utils.d.mts +298 -0
- package/dist/lib/esm/object-utils.mjs +523 -0
- package/dist/lib/esm/path.d.mts +155 -0
- package/dist/lib/esm/path.mjs +122 -0
- package/dist/lib/esm/reg-exp.d.mts +87 -0
- package/dist/lib/esm/reg-exp.mjs +169 -0
- package/dist/lib/esm/string.d.mts +362 -0
- package/dist/lib/esm/string.mjs +230 -0
- package/dist/lib/esm/transformers/date-transformer.d.mts +39 -0
- package/dist/lib/esm/transformers/date-transformer.mjs +47 -0
- package/dist/lib/esm/transformers/group-transformer.d.mts +70 -0
- package/dist/lib/esm/transformers/group-transformer.mjs +94 -0
- package/dist/lib/esm/transformers/index.d.mts +9 -0
- package/dist/lib/esm/transformers/index.mjs +24 -0
- package/dist/lib/esm/transformers/map-transformer.d.mts +41 -0
- package/dist/lib/esm/transformers/map-transformer.mjs +47 -0
- package/dist/lib/esm/transformers/set-transformer.d.mts +39 -0
- package/dist/lib/esm/transformers/set-transformer.mjs +47 -0
- package/dist/lib/esm/transformers/skip-private-property-transformer.d.mts +36 -0
- package/dist/lib/esm/transformers/skip-private-property-transformer.mjs +45 -0
- package/dist/lib/esm/transformers/transformer.d.mts +70 -0
- package/dist/lib/esm/transformers/transformer.mjs +88 -0
- package/dist/lib/esm/transformers/two-way-map-transformer.d.mts +42 -0
- package/dist/lib/esm/transformers/two-way-map-transformer.mjs +48 -0
- package/dist/lib/esm/transformers/typed-transformer.d.mts +39 -0
- package/dist/lib/esm/transformers/typed-transformer.mjs +12 -0
- package/dist/lib/esm/two-way-map.d.mts +101 -0
- package/dist/lib/esm/two-way-map.mjs +126 -0
- package/dist/lib/esm/type-guards.d.mts +84 -0
- package/dist/lib/esm/type-guards.mjs +41 -0
- package/dist/lib/esm/type.d.mts +122 -0
- package/dist/lib/esm/type.mjs +39 -0
- package/dist/lib/esm/typescript-lib-state.d.mts +56 -0
- package/dist/lib/esm/typescript-lib-state.mjs +40 -0
- package/dist/lib/esm/url.d.mts +74 -0
- package/dist/lib/esm/url.mjs +50 -0
- package/dist/lib/esm/value-provider.d.mts +29 -0
- package/dist/lib/esm/value-provider.mjs +18 -0
- package/dist/lib/esm/value-wrapper.d.mts +47 -0
- package/dist/lib/esm/value-wrapper.mjs +62 -0
- package/package.json +153 -13
- package/transformers/date-transformer/package.json +6 -0
- package/transformers/group-transformer/package.json +6 -0
- package/transformers/index/package.json +6 -0
- package/transformers/map-transformer/package.json +6 -0
- package/transformers/package.json +6 -0
- package/transformers/set-transformer/package.json +6 -0
- package/transformers/skip-private-property-transformer/package.json +6 -0
- package/transformers/transformer/package.json +6 -0
- package/transformers/two-way-map-transformer/package.json +6 -0
- package/transformers/typed-transformer/package.json +6 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/// <reference path="./library-references.d.cts" />
|
|
2
|
+
/// <reference lib="dom" />
|
|
3
|
+
/**
|
|
4
|
+
* @file
|
|
5
|
+
*
|
|
6
|
+
* Contains utility functions for string operations.
|
|
7
|
+
*/
|
|
8
|
+
import type { MaybeReturn } from './type.cjs';
|
|
9
|
+
import type { ValueProvider } from './value-provider.cjs';
|
|
10
|
+
/**
|
|
11
|
+
* An empty string constant.
|
|
12
|
+
*
|
|
13
|
+
* A shared sentinel for the `${EMPTY}` prefix that silences the `obsidianmd/ui/sentence-case` ESLint
|
|
14
|
+
* false positive on legitimate lower-case UI text (e.g. `cursor` colliding with the `Cursor` brand).
|
|
15
|
+
* `setName(`${EMPTY}...at cursor...`)` renders byte-identical `''` at runtime while the `{...}`
|
|
16
|
+
* placeholder makes the rule skip the string. Consumers import this instead of redefining a per-file
|
|
17
|
+
* `const EMPTY = ''`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const EMPTY = "";
|
|
20
|
+
/**
|
|
21
|
+
* A synchronous/asynchronous function that generates replacement strings, or a string to replace with.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam CapturedGroupArguments - The types of the captured group arguments.
|
|
24
|
+
*/
|
|
25
|
+
export type AsyncReplacer<CapturedGroupArguments extends string[]> = ValueProvider<StringReplacement, ReplaceArguments<CapturedGroupArguments>>;
|
|
26
|
+
/**
|
|
27
|
+
* Common arguments for the `replaceAll`/`replaceAllAsync` functions.
|
|
28
|
+
*
|
|
29
|
+
* @typeParam CapturedGroupArguments - The types of the captured group arguments.
|
|
30
|
+
*/
|
|
31
|
+
export interface ReplaceArguments<CapturedGroupArguments extends string[]> {
|
|
32
|
+
/**
|
|
33
|
+
* Captured group arguments.
|
|
34
|
+
*/
|
|
35
|
+
capturedGroupArguments: CapturedGroupArguments;
|
|
36
|
+
/**
|
|
37
|
+
* Groups of the match.
|
|
38
|
+
*/
|
|
39
|
+
groups: Record<string, string | undefined> | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Indices of the groups that were not found in the match.
|
|
42
|
+
*/
|
|
43
|
+
missingGroupIndices: number[];
|
|
44
|
+
/**
|
|
45
|
+
* An offset of the match.
|
|
46
|
+
*/
|
|
47
|
+
offset: number;
|
|
48
|
+
/**
|
|
49
|
+
* A source of the match.
|
|
50
|
+
*/
|
|
51
|
+
source: string;
|
|
52
|
+
/**
|
|
53
|
+
* A substring of the match.
|
|
54
|
+
*/
|
|
55
|
+
substring: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A synchronous function that generates replacement strings, or a string to replace with.
|
|
59
|
+
*
|
|
60
|
+
* @typeParam CapturedGroupArguments - The types of the captured group arguments.
|
|
61
|
+
*/
|
|
62
|
+
export type Replacer<CapturedGroupArguments extends string[]> = (($arguments: ReplaceArguments<CapturedGroupArguments>) => StringReplacement) | StringReplacement;
|
|
63
|
+
type StringReplacement = MaybeReturn<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Parameters for {@link ensureEndsWith}.
|
|
66
|
+
*/
|
|
67
|
+
export interface EnsureEndsWithParams {
|
|
68
|
+
/**
|
|
69
|
+
* The string to check.
|
|
70
|
+
*/
|
|
71
|
+
readonly $string: string;
|
|
72
|
+
/**
|
|
73
|
+
* The suffix to ensure.
|
|
74
|
+
*/
|
|
75
|
+
readonly suffix: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parameters for {@link ensureStartsWith}.
|
|
79
|
+
*/
|
|
80
|
+
export interface EnsureStartsWithParams {
|
|
81
|
+
/**
|
|
82
|
+
* The string to check.
|
|
83
|
+
*/
|
|
84
|
+
readonly $string: string;
|
|
85
|
+
/**
|
|
86
|
+
* The prefix to ensure.
|
|
87
|
+
*/
|
|
88
|
+
readonly prefix: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Parameters for {@link hasSingleOccurrence}.
|
|
92
|
+
*/
|
|
93
|
+
export interface HasSingleOccurrenceParams {
|
|
94
|
+
/**
|
|
95
|
+
* The string to check.
|
|
96
|
+
*/
|
|
97
|
+
readonly $string: string;
|
|
98
|
+
/**
|
|
99
|
+
* The search value to check for.
|
|
100
|
+
*/
|
|
101
|
+
readonly searchValue: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Parameters for {@link indent}.
|
|
105
|
+
*/
|
|
106
|
+
export interface IndentParams {
|
|
107
|
+
/**
|
|
108
|
+
* The prefix to add to each line.
|
|
109
|
+
*/
|
|
110
|
+
readonly prefix: string;
|
|
111
|
+
/**
|
|
112
|
+
* The string to indent.
|
|
113
|
+
*/
|
|
114
|
+
readonly text: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Parameters for {@link insertAt}.
|
|
118
|
+
*/
|
|
119
|
+
export interface InsertAtParams {
|
|
120
|
+
/**
|
|
121
|
+
* The string to insert the substring into.
|
|
122
|
+
*/
|
|
123
|
+
readonly $string: string;
|
|
124
|
+
/**
|
|
125
|
+
* The index to end the substring at.
|
|
126
|
+
*/
|
|
127
|
+
readonly endIndex?: number;
|
|
128
|
+
/**
|
|
129
|
+
* The index to insert the substring at.
|
|
130
|
+
*/
|
|
131
|
+
readonly startIndex: number;
|
|
132
|
+
/**
|
|
133
|
+
* The substring to insert.
|
|
134
|
+
*/
|
|
135
|
+
readonly substring: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Parameters for {@link replaceAllAsync}.
|
|
139
|
+
*
|
|
140
|
+
* @typeParam ReplaceGroupArguments - The types of the captured group arguments.
|
|
141
|
+
*/
|
|
142
|
+
export interface ReplaceAllAsyncParams<ReplaceGroupArguments extends string[]> {
|
|
143
|
+
/**
|
|
144
|
+
* The string in which to perform replacements.
|
|
145
|
+
*/
|
|
146
|
+
readonly $string: string;
|
|
147
|
+
/**
|
|
148
|
+
* The abort signal to control the execution of the function.
|
|
149
|
+
*/
|
|
150
|
+
readonly abortSignal?: AbortSignal;
|
|
151
|
+
/**
|
|
152
|
+
* A synchronous/asynchronous function that generates replacement strings, or a string to replace with.
|
|
153
|
+
*/
|
|
154
|
+
readonly replacer: AsyncReplacer<ReplaceGroupArguments>;
|
|
155
|
+
/**
|
|
156
|
+
* The string or regular expression to search for.
|
|
157
|
+
*/
|
|
158
|
+
readonly searchValue: RegExp | string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Parameters for {@link replaceAll}.
|
|
162
|
+
*
|
|
163
|
+
* @typeParam CapturedGroupArguments - The types of the captured group arguments.
|
|
164
|
+
*/
|
|
165
|
+
export interface ReplaceAllParams<CapturedGroupArguments extends string[]> {
|
|
166
|
+
/**
|
|
167
|
+
* The string in which to perform replacements.
|
|
168
|
+
*/
|
|
169
|
+
readonly $string: string;
|
|
170
|
+
/**
|
|
171
|
+
* A replacer function that generates replacement strings, or a string to replace with.
|
|
172
|
+
*/
|
|
173
|
+
readonly replacer: Replacer<CapturedGroupArguments>;
|
|
174
|
+
/**
|
|
175
|
+
* The string or regular expression to search for.
|
|
176
|
+
*/
|
|
177
|
+
readonly searchValue: RegExp | string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Parameters for {@link trimEnd}.
|
|
181
|
+
*/
|
|
182
|
+
export interface TrimEndParams {
|
|
183
|
+
/**
|
|
184
|
+
* The string to trim.
|
|
185
|
+
*/
|
|
186
|
+
readonly $string: string;
|
|
187
|
+
/**
|
|
188
|
+
* If `true`, throws an error if the string does not end with the suffix.
|
|
189
|
+
*
|
|
190
|
+
* @default `false`
|
|
191
|
+
*/
|
|
192
|
+
readonly shouldValidate?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* The suffix to remove from the end of the string.
|
|
195
|
+
*/
|
|
196
|
+
readonly suffix: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Parameters for {@link trimStart}.
|
|
200
|
+
*/
|
|
201
|
+
export interface TrimStartParams {
|
|
202
|
+
/**
|
|
203
|
+
* The string to trim.
|
|
204
|
+
*/
|
|
205
|
+
readonly $string: string;
|
|
206
|
+
/**
|
|
207
|
+
* The prefix to remove from the start of the string.
|
|
208
|
+
*/
|
|
209
|
+
readonly prefix: string;
|
|
210
|
+
/**
|
|
211
|
+
* If `true`, throws an error if the string does not start with the prefix.
|
|
212
|
+
*
|
|
213
|
+
* @default `false`
|
|
214
|
+
*/
|
|
215
|
+
readonly shouldValidate?: boolean;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Parameters for {@link unindent}.
|
|
219
|
+
*/
|
|
220
|
+
export interface UnindentParams {
|
|
221
|
+
/**
|
|
222
|
+
* The prefix to remove from each line.
|
|
223
|
+
*/
|
|
224
|
+
readonly prefix: string;
|
|
225
|
+
/**
|
|
226
|
+
* If `true`, throws an error if a line is not indented with the prefix.
|
|
227
|
+
*
|
|
228
|
+
* @default `false`
|
|
229
|
+
*/
|
|
230
|
+
readonly shouldThrowIfNotIndented?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* The string to unindent.
|
|
233
|
+
*/
|
|
234
|
+
readonly text: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Ensures that a string ends with the specified suffix, adding it if necessary.
|
|
238
|
+
*
|
|
239
|
+
* @param params - The parameters.
|
|
240
|
+
* @returns The string that ends with the suffix.
|
|
241
|
+
*/
|
|
242
|
+
export declare function ensureEndsWith(params: EnsureEndsWithParams): string;
|
|
243
|
+
/**
|
|
244
|
+
* Ensures that a string has `LF` line endings.
|
|
245
|
+
*
|
|
246
|
+
* It replaces `CRLF` line endings with `LF`.
|
|
247
|
+
*
|
|
248
|
+
* @param $string - The string.
|
|
249
|
+
* @returns The string with `LF` line endings.
|
|
250
|
+
*/
|
|
251
|
+
export declare function ensureLfEndings($string: string): string;
|
|
252
|
+
/**
|
|
253
|
+
* Ensures that a string starts with the specified prefix, adding it if necessary.
|
|
254
|
+
*
|
|
255
|
+
* @param params - The parameters.
|
|
256
|
+
* @returns The string that starts with the prefix.
|
|
257
|
+
*/
|
|
258
|
+
export declare function ensureStartsWith(params: EnsureStartsWithParams): string;
|
|
259
|
+
/**
|
|
260
|
+
* Escapes special characters in a string.
|
|
261
|
+
*
|
|
262
|
+
* @param $string - The string to escape.
|
|
263
|
+
* @returns The escaped string.
|
|
264
|
+
*/
|
|
265
|
+
export declare function escape($string: string): string;
|
|
266
|
+
/**
|
|
267
|
+
* Returns a function that maps LF-normalized offsets to original offsets.
|
|
268
|
+
*
|
|
269
|
+
* @param $string - The string to get the LF-normalized indices from.
|
|
270
|
+
* @returns A function that maps LF-normalized offsets to original offsets.
|
|
271
|
+
*/
|
|
272
|
+
export declare function getLfNormalizedOffsetToOriginalOffsetMapper($string: string): (lfOffset: number) => number;
|
|
273
|
+
/**
|
|
274
|
+
* Checks if a string has a single occurrence of a search value.
|
|
275
|
+
*
|
|
276
|
+
* @param params - The parameters.
|
|
277
|
+
* @returns `true` if the string has a single occurrence of the search value, `false` otherwise.
|
|
278
|
+
*/
|
|
279
|
+
export declare function hasSingleOccurrence(params: HasSingleOccurrenceParams): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Indents a string by adding a prefix to each line.
|
|
282
|
+
*
|
|
283
|
+
* @param params - The parameters.
|
|
284
|
+
* @returns The indented string.
|
|
285
|
+
*/
|
|
286
|
+
export declare function indent(params: IndentParams): string;
|
|
287
|
+
/**
|
|
288
|
+
* Inserts a substring at a specified position in a string.
|
|
289
|
+
*
|
|
290
|
+
* @param params - The parameters.
|
|
291
|
+
* @returns The modified string with the substring inserted.
|
|
292
|
+
*/
|
|
293
|
+
export declare function insertAt(params: InsertAtParams): string;
|
|
294
|
+
/**
|
|
295
|
+
* Converts a string into a valid JavaScript variable name by replacing invalid characters with underscores.
|
|
296
|
+
*
|
|
297
|
+
* @param $string - The string to convert.
|
|
298
|
+
* @returns The valid variable name.
|
|
299
|
+
*/
|
|
300
|
+
export declare function makeValidVariableName($string: string): string;
|
|
301
|
+
/**
|
|
302
|
+
* Normalizes a string by converting it to the NFC form and replacing non-breaking spaces with regular spaces.
|
|
303
|
+
*
|
|
304
|
+
* @param $string - The string to normalize.
|
|
305
|
+
* @returns The normalized string.
|
|
306
|
+
*/
|
|
307
|
+
export declare function normalizeString($string: string): string;
|
|
308
|
+
/**
|
|
309
|
+
* Replaces occurrences of strings in a given string based on a replacements map.
|
|
310
|
+
*
|
|
311
|
+
* @param $string - The string to perform replacements on.
|
|
312
|
+
* @param replacementsMap - An object mapping strings to their replacement values.
|
|
313
|
+
* @returns The modified string with replacements applied.
|
|
314
|
+
*/
|
|
315
|
+
export declare function replace($string: string, replacementsMap: Record<string, string>): string;
|
|
316
|
+
/**
|
|
317
|
+
* Replaces all occurrences of a search string or pattern with the results of an replacer function.
|
|
318
|
+
*
|
|
319
|
+
* @typeParam CapturedGroupArguments - The types of the captured group arguments.
|
|
320
|
+
* @param params - The parameters.
|
|
321
|
+
* @returns The string with all replacements made.
|
|
322
|
+
*/
|
|
323
|
+
export declare function replaceAll<CapturedGroupArguments extends string[]>(params: ReplaceAllParams<CapturedGroupArguments>): string;
|
|
324
|
+
/**
|
|
325
|
+
* Asynchronously replaces all occurrences of a search string or pattern with the results of an asynchronous replacer function.
|
|
326
|
+
*
|
|
327
|
+
* @typeParam ReplaceGroupArguments - The types of the captured group arguments.
|
|
328
|
+
* @param params - The parameters.
|
|
329
|
+
* @returns A {@link Promise} that resolves to the string with all replacements made.
|
|
330
|
+
*/
|
|
331
|
+
export declare function replaceAllAsync<ReplaceGroupArguments extends string[]>(params: ReplaceAllAsyncParams<ReplaceGroupArguments>): Promise<string>;
|
|
332
|
+
/**
|
|
333
|
+
* Trims the specified suffix from the end of a string.
|
|
334
|
+
*
|
|
335
|
+
* @param params - The parameters.
|
|
336
|
+
* @returns The trimmed string.
|
|
337
|
+
* @throws If `shouldValidate` is `true` and the string does not end with the suffix.
|
|
338
|
+
*/
|
|
339
|
+
export declare function trimEnd(params: TrimEndParams): string;
|
|
340
|
+
/**
|
|
341
|
+
* Trims the specified prefix from the start of a string.
|
|
342
|
+
*
|
|
343
|
+
* @param params - The parameters.
|
|
344
|
+
* @returns The trimmed string.
|
|
345
|
+
* @throws If `shouldValidate` is `true` and the string does not start with the prefix.
|
|
346
|
+
*/
|
|
347
|
+
export declare function trimStart(params: TrimStartParams): string;
|
|
348
|
+
/**
|
|
349
|
+
* Unescapes a string by replacing escape sequences with their corresponding characters.
|
|
350
|
+
*
|
|
351
|
+
* @param $string - The string to unescape.
|
|
352
|
+
* @returns The unescaped string.
|
|
353
|
+
*/
|
|
354
|
+
export declare function unescape($string: string): string;
|
|
355
|
+
/**
|
|
356
|
+
* Unindents a string by removing a prefix from each line.
|
|
357
|
+
*
|
|
358
|
+
* @param params - The parameters.
|
|
359
|
+
* @returns The unindented string.
|
|
360
|
+
*/
|
|
361
|
+
export declare function unindent(params: UnindentParams): string;
|
|
362
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
3
|
+
if you want to view the source, please visit the github repository of this plugin
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var date_transformer_exports = {};
|
|
25
|
+
__export(date_transformer_exports, {
|
|
26
|
+
DateTransformer: () => DateTransformer
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(date_transformer_exports);
|
|
29
|
+
var import_typed_transformer = require('./typed-transformer.cjs');
|
|
30
|
+
class DateTransformer extends import_typed_transformer.TypedTransformer {
|
|
31
|
+
/**
|
|
32
|
+
* An id of the transformer.
|
|
33
|
+
*
|
|
34
|
+
* @returns `date`.
|
|
35
|
+
*/
|
|
36
|
+
get id() {
|
|
37
|
+
return "date";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Determines if the value is a Date.
|
|
41
|
+
*
|
|
42
|
+
* @param value - The value to check.
|
|
43
|
+
* @returns A boolean indicating if the value is a Date.
|
|
44
|
+
*/
|
|
45
|
+
canTransform(value) {
|
|
46
|
+
return value instanceof Date;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Restores the value from a string.
|
|
50
|
+
*
|
|
51
|
+
* @param transformedValue - The transformed value.
|
|
52
|
+
* @returns The restored value.
|
|
53
|
+
*/
|
|
54
|
+
restoreValue(transformedValue) {
|
|
55
|
+
return new Date(transformedValue);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Transforms the value to a string.
|
|
59
|
+
*
|
|
60
|
+
* @param value - The value to transform.
|
|
61
|
+
* @returns The transformed value.
|
|
62
|
+
*/
|
|
63
|
+
transformValue(value) {
|
|
64
|
+
return value.toISOString();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
DateTransformer
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vc3JjL3RyYW5zZm9ybWVycy9kYXRlLXRyYW5zZm9ybWVyLnRzIl0sCiAgInNvdXJjZXNDb250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QUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsRUFRZ0IsZUFBZSxPQUFxQjtBQUNsRCxXQUFPLE1BQU0sWUFBWTtBQUFBLEVBQzNCO0FBQ0Y7IiwKICAibmFtZXMiOiBbXQp9Cg==
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference path="../library-references.d.cts" />
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
*
|
|
5
|
+
* A transformer that can transform Date to an ISO string and back.
|
|
6
|
+
*/
|
|
7
|
+
import { TypedTransformer } from './typed-transformer.cjs';
|
|
8
|
+
/**
|
|
9
|
+
* A transformer that can transform Date to an ISO string and back.
|
|
10
|
+
*/
|
|
11
|
+
export declare class DateTransformer extends TypedTransformer<Date, string> {
|
|
12
|
+
/**
|
|
13
|
+
* An id of the transformer.
|
|
14
|
+
*
|
|
15
|
+
* @returns `date`.
|
|
16
|
+
*/
|
|
17
|
+
get id(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Determines if the value is a Date.
|
|
20
|
+
*
|
|
21
|
+
* @param value - The value to check.
|
|
22
|
+
* @returns A boolean indicating if the value is a Date.
|
|
23
|
+
*/
|
|
24
|
+
canTransform(value: unknown): value is Date;
|
|
25
|
+
/**
|
|
26
|
+
* Restores the value from a string.
|
|
27
|
+
*
|
|
28
|
+
* @param transformedValue - The transformed value.
|
|
29
|
+
* @returns The restored value.
|
|
30
|
+
*/
|
|
31
|
+
restoreValue(transformedValue: string): Date;
|
|
32
|
+
/**
|
|
33
|
+
* Transforms the value to a string.
|
|
34
|
+
*
|
|
35
|
+
* @param value - The value to transform.
|
|
36
|
+
* @returns The transformed value.
|
|
37
|
+
*/
|
|
38
|
+
transformValue(value: Date): string;
|
|
39
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
3
|
+
if you want to view the source, please visit the github repository of this plugin
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var group_transformer_exports = {};
|
|
25
|
+
__export(group_transformer_exports, {
|
|
26
|
+
GroupTransformer: () => GroupTransformer
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(group_transformer_exports);
|
|
29
|
+
var import_type_guards = require('../type-guards.cjs');
|
|
30
|
+
var import_transformer = require('./transformer.cjs');
|
|
31
|
+
class GroupTransformer extends import_transformer.Transformer {
|
|
32
|
+
/**
|
|
33
|
+
* Transformers to combine.
|
|
34
|
+
*
|
|
35
|
+
* @param transformers - The transformers to combine.
|
|
36
|
+
*/
|
|
37
|
+
constructor(transformers) {
|
|
38
|
+
super();
|
|
39
|
+
this.transformers = transformers;
|
|
40
|
+
}
|
|
41
|
+
transformers;
|
|
42
|
+
/**
|
|
43
|
+
* An id of the transformer.
|
|
44
|
+
*
|
|
45
|
+
* @returns `group`.
|
|
46
|
+
*/
|
|
47
|
+
get id() {
|
|
48
|
+
return "group";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Determines if the value can be transformed by any of the transformers.
|
|
52
|
+
*
|
|
53
|
+
* @param value - The value to check.
|
|
54
|
+
* @param key - The key of the value to check.
|
|
55
|
+
* @returns A boolean indicating if the value can be transformed.
|
|
56
|
+
*/
|
|
57
|
+
canTransform(value, key) {
|
|
58
|
+
return this.getFirstTransformerThatCanTransform(value, key) !== null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the transformer with the given id.
|
|
62
|
+
*
|
|
63
|
+
* @param transformerId - The id of the transformer to get.
|
|
64
|
+
* @returns The transformer with the given id.
|
|
65
|
+
*/
|
|
66
|
+
getTransformer(transformerId) {
|
|
67
|
+
return (0, import_type_guards.ensureNonNullable)(this.transformers.find((t) => t.id === transformerId), `No transformer with id ${transformerId} found`);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Transforms the value using the first transformer that can transform it.
|
|
71
|
+
*
|
|
72
|
+
* @param value - The value to transform.
|
|
73
|
+
* @param key - The key of the value to transform.
|
|
74
|
+
* @returns The transformed value.
|
|
75
|
+
*/
|
|
76
|
+
transformValue(value, key) {
|
|
77
|
+
const transformer = this.getFirstTransformerThatCanTransform(value, key);
|
|
78
|
+
(0, import_type_guards.assertNonNullable)(transformer, "No transformer can transform the value");
|
|
79
|
+
return transformer.transformValue(value, key);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets the id of the transformer that can transform the given value.
|
|
83
|
+
*
|
|
84
|
+
* @param value - The value to get the transformer id for.
|
|
85
|
+
* @param key - The key of the value to get the transformer id for.
|
|
86
|
+
* @returns The id of the transformer that can transform the given value.
|
|
87
|
+
*/
|
|
88
|
+
getTransformerId(value, key) {
|
|
89
|
+
const transformer = this.getFirstTransformerThatCanTransform(value, key);
|
|
90
|
+
return transformer === null ? null : transformer.id;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* This transformer does not support restoring values.
|
|
94
|
+
*
|
|
95
|
+
* @throws
|
|
96
|
+
*/
|
|
97
|
+
restoreValue() {
|
|
98
|
+
throw new Error("GroupTransformer does not support restoring values");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Gets the first transformer that can transform the given value.
|
|
102
|
+
*
|
|
103
|
+
* @param value - The value to get the first transformer for.
|
|
104
|
+
* @param key - The key of the value to get the first transformer for.
|
|
105
|
+
* @returns The first transformer that can transform the given value.
|
|
106
|
+
*/
|
|
107
|
+
getFirstTransformerThatCanTransform(value, key) {
|
|
108
|
+
return this.transformers.find((t) => t.canTransform(value, key)) ?? null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
GroupTransformer
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vc3JjL3RyYW5zZm9ybWVycy9ncm91cC10cmFuc2Zvcm1lci50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLyoqXG4gKiBAZmlsZVxuICpcbiAqIEEgdHJhbnNmb3JtZXIgdGhhdCBjb21iaW5lcyBtdWx0aXBsZSB0cmFuc2Zvcm1lcnMuXG4gKi9cblxuaW1wb3J0IHtcbiAgYXNzZXJ0Tm9uTnVsbGFibGUsXG4gIGVuc3VyZU5vbk51bGxhYmxlXG59IGZyb20gJy4uL3R5cGUtZ3VhcmRzLnRzJztcbmltcG9ydCB7IFRyYW5zZm9ybWVyIH0gZnJvbSAnLi90cmFuc2Zvcm1lci50cyc7XG5cbi8qKlxuICogQSB0cmFuc2Zvcm1lciB0aGF0IGNvbWJpbmVzIG11bHRpcGxlIHRyYW5zZm9ybWVycy5cbiAqL1xuZXhwb3J0IGNsYXNzIEdyb3VwVHJhbnNmb3JtZXIgZXh0ZW5kcyBUcmFuc2Zvcm1lciB7XG4gIC8qKlx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UFLO0FBQUEsRUFDdEU7QUFDRjsiLAogICJuYW1lcyI6IFtdCn0K
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference path="../library-references.d.cts" />
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
*
|
|
5
|
+
* A transformer that combines multiple transformers.
|
|
6
|
+
*/
|
|
7
|
+
import { Transformer } from './transformer.cjs';
|
|
8
|
+
/**
|
|
9
|
+
* A transformer that combines multiple transformers.
|
|
10
|
+
*/
|
|
11
|
+
export declare class GroupTransformer extends Transformer {
|
|
12
|
+
protected readonly transformers: Transformer[];
|
|
13
|
+
/**
|
|
14
|
+
* An id of the transformer.
|
|
15
|
+
*
|
|
16
|
+
* @returns `group`.
|
|
17
|
+
*/
|
|
18
|
+
get id(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Transformers to combine.
|
|
21
|
+
*
|
|
22
|
+
* @param transformers - The transformers to combine.
|
|
23
|
+
*/
|
|
24
|
+
constructor(transformers: Transformer[]);
|
|
25
|
+
/**
|
|
26
|
+
* Determines if the value can be transformed by any of the transformers.
|
|
27
|
+
*
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @param key - The key of the value to check.
|
|
30
|
+
* @returns A boolean indicating if the value can be transformed.
|
|
31
|
+
*/
|
|
32
|
+
canTransform(value: unknown, key: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the transformer with the given id.
|
|
35
|
+
*
|
|
36
|
+
* @param transformerId - The id of the transformer to get.
|
|
37
|
+
* @returns The transformer with the given id.
|
|
38
|
+
*/
|
|
39
|
+
getTransformer(transformerId: string): Transformer;
|
|
40
|
+
/**
|
|
41
|
+
* Transforms the value using the first transformer that can transform it.
|
|
42
|
+
*
|
|
43
|
+
* @param value - The value to transform.
|
|
44
|
+
* @param key - The key of the value to transform.
|
|
45
|
+
* @returns The transformed value.
|
|
46
|
+
*/
|
|
47
|
+
transformValue(value: unknown, key: string): unknown;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the id of the transformer that can transform the given value.
|
|
50
|
+
*
|
|
51
|
+
* @param value - The value to get the transformer id for.
|
|
52
|
+
* @param key - The key of the value to get the transformer id for.
|
|
53
|
+
* @returns The id of the transformer that can transform the given value.
|
|
54
|
+
*/
|
|
55
|
+
protected getTransformerId(value: unknown, key: string): null | string;
|
|
56
|
+
/**
|
|
57
|
+
* This transformer does not support restoring values.
|
|
58
|
+
*
|
|
59
|
+
* @throws
|
|
60
|
+
*/
|
|
61
|
+
protected restoreValue(): never;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the first transformer that can transform the given value.
|
|
64
|
+
*
|
|
65
|
+
* @param value - The value to get the first transformer for.
|
|
66
|
+
* @param key - The key of the value to get the first transformer for.
|
|
67
|
+
* @returns The first transformer that can transform the given value.
|
|
68
|
+
*/
|
|
69
|
+
private getFirstTransformerThatCanTransform;
|
|
70
|
+
}
|