@ix-xs/node-comfort 1.1.31 → 2.0.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/CHANGELOG.md +190 -0
- package/LICENSE +21 -0
- package/README.md +210 -748
- package/index.js +84 -13
- package/package.json +201 -21
- package/src/Arr.js +901 -0
- package/src/Async.js +585 -0
- package/src/Cache.js +329 -0
- package/src/Checker.js +979 -188
- package/src/Cli.js +1034 -0
- package/src/Color.js +415 -0
- package/src/Crypto.js +707 -0
- package/src/Emitter.js +289 -0
- package/src/Env.js +555 -0
- package/src/FS.js +1483 -768
- package/src/Func.js +692 -0
- package/src/Http.js +538 -0
- package/src/Id.js +418 -0
- package/src/Logger.js +739 -307
- package/src/Num.js +849 -0
- package/src/Obj.js +904 -0
- package/src/SQLite.js +1308 -994
- package/src/Schema.js +1586 -0
- package/src/Str.js +999 -0
- package/src/Sys.js +511 -0
- package/src/Time.js +1323 -0
- package/src/Utils.js +321 -325
- package/src/errors.js +292 -0
- package/types/index.d.ts +693 -120
- package/types/src/Arr.d.ts +562 -0
- package/types/src/Arr.d.ts.map +1 -0
- package/types/src/Async.d.ts +321 -0
- package/types/src/Async.d.ts.map +1 -0
- package/types/src/Cache.d.ts +195 -0
- package/types/src/Cache.d.ts.map +1 -0
- package/types/src/Checker.d.ts +609 -81
- package/types/src/Checker.d.ts.map +1 -1
- package/types/src/Cli.d.ts +582 -0
- package/types/src/Cli.d.ts.map +1 -0
- package/types/src/Color.d.ts +294 -0
- package/types/src/Color.d.ts.map +1 -0
- package/types/src/Crypto.d.ts +534 -0
- package/types/src/Crypto.d.ts.map +1 -0
- package/types/src/Emitter.d.ts +170 -0
- package/types/src/Emitter.d.ts.map +1 -0
- package/types/src/Env.d.ts +382 -0
- package/types/src/Env.d.ts.map +1 -0
- package/types/src/FS.d.ts +709 -201
- package/types/src/FS.d.ts.map +1 -1
- package/types/src/Func.d.ts +455 -0
- package/types/src/Func.d.ts.map +1 -0
- package/types/src/Http.d.ts +374 -0
- package/types/src/Http.d.ts.map +1 -0
- package/types/src/Id.d.ts +200 -0
- package/types/src/Id.d.ts.map +1 -0
- package/types/src/Logger.d.ts +374 -24
- package/types/src/Logger.d.ts.map +1 -1
- package/types/src/Num.d.ts +578 -0
- package/types/src/Num.d.ts.map +1 -0
- package/types/src/Obj.d.ts +475 -0
- package/types/src/Obj.d.ts.map +1 -0
- package/types/src/SQLite.d.ts +647 -305
- package/types/src/SQLite.d.ts.map +1 -1
- package/types/src/Schema.d.ts +940 -0
- package/types/src/Schema.d.ts.map +1 -0
- package/types/src/Str.d.ts +696 -0
- package/types/src/Str.d.ts.map +1 -0
- package/types/src/Sys.d.ts +269 -0
- package/types/src/Sys.d.ts.map +1 -0
- package/types/src/Time.d.ts +664 -0
- package/types/src/Time.d.ts.map +1 -0
- package/types/src/Utils.d.ts +154 -102
- package/types/src/Utils.d.ts.map +1 -1
- package/types/src/errors.d.ts +292 -0
- package/types/src/errors.d.ts.map +1 -0
- package/tsconfig.json +0 -18
- package/types/index.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Emitter.d.ts","sourceRoot":"","sources":["../../src/Emitter.js"],"names":[],"mappings":";AAkBA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,sBAFyB,MAAM,SAAjB,QAAS;IAQrB;;;;;;;;;;;OAWG;IACH,GALqC,CAAC,SAAxB,MAAM,MAAM,GAAG,MAAO,SACzB,CAAC,YACD,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,GAC7B,MAAM,IAAI,CAOtB;IAED;;;;;;;OAOG;IACH,KALqC,CAAC,SAAxB,MAAM,MAAM,GAAG,MAAO,SACzB,CAAC,YACD,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,GAC7B,MAAM,IAAI,CAUtB;IAED;;;;;;;;;OASG;IACH,gBAHW,CA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,CAAC,SAAR,GAAG,EAAG;;;;;;;;;;;;wBAII,CAAC,KAAK,OAAO"}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
declare namespace _exports {
|
|
2
|
+
export { EnvLoadOptions, EnvParseOptions, EnvGetterOptions, EnvVarSpec, EnvVarValue, EnvConfig };
|
|
3
|
+
}
|
|
4
|
+
declare namespace _exports {
|
|
5
|
+
export { parse };
|
|
6
|
+
export { load };
|
|
7
|
+
export { get };
|
|
8
|
+
export { has };
|
|
9
|
+
export { required };
|
|
10
|
+
export { string };
|
|
11
|
+
export { number };
|
|
12
|
+
export { bool };
|
|
13
|
+
export { port };
|
|
14
|
+
export { url };
|
|
15
|
+
export { duration };
|
|
16
|
+
export { list };
|
|
17
|
+
export { json };
|
|
18
|
+
export { oneOf };
|
|
19
|
+
export { validate };
|
|
20
|
+
export { mode };
|
|
21
|
+
export { isProduction };
|
|
22
|
+
export { isDevelopment };
|
|
23
|
+
export { isTest };
|
|
24
|
+
}
|
|
25
|
+
export = _exports;
|
|
26
|
+
/**
|
|
27
|
+
* Options for `load()`.
|
|
28
|
+
*/
|
|
29
|
+
type EnvLoadOptions = {
|
|
30
|
+
/**
|
|
31
|
+
* Overwrite variables that are already set.
|
|
32
|
+
*/
|
|
33
|
+
override?: boolean | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Replace `${OTHER}` references. Defaults to `true`.
|
|
36
|
+
*/
|
|
37
|
+
expand?: boolean | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Throw if a file is missing.
|
|
40
|
+
*/
|
|
41
|
+
required?: boolean | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Where to put the variables. Defaults to `process.env`.
|
|
44
|
+
*/
|
|
45
|
+
target?: NodeJS.ProcessEnv | undefined;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Options for `parse()`.
|
|
49
|
+
*/
|
|
50
|
+
type EnvParseOptions = {
|
|
51
|
+
/**
|
|
52
|
+
* Replace `$VAR`, `${VAR}` and `${VAR:-default}`. Defaults to `true`.
|
|
53
|
+
*/
|
|
54
|
+
expand?: boolean | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Other variables usable in expansions. Defaults to `process.env`.
|
|
57
|
+
*/
|
|
58
|
+
env?: Record<string, string | undefined> | undefined;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Options shared by the typed getters.
|
|
62
|
+
*/
|
|
63
|
+
type EnvGetterOptions<T> = {
|
|
64
|
+
/**
|
|
65
|
+
* Used when the variable is missing or empty. Without it, the variable is required.
|
|
66
|
+
*/
|
|
67
|
+
default?: T | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Return `undefined` instead of throwing when it's missing.
|
|
70
|
+
*/
|
|
71
|
+
optional?: boolean | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Where to read from. Defaults to `process.env`.
|
|
74
|
+
*/
|
|
75
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* One variable in `validate()`. It's required unless it has a `default` or
|
|
79
|
+
* `optional: true`.
|
|
80
|
+
*/
|
|
81
|
+
type EnvVarSpec = ({
|
|
82
|
+
type: "string";
|
|
83
|
+
default?: string;
|
|
84
|
+
optional?: boolean;
|
|
85
|
+
pattern?: RegExp;
|
|
86
|
+
minLength?: number;
|
|
87
|
+
description?: string;
|
|
88
|
+
} | {
|
|
89
|
+
type: "number";
|
|
90
|
+
default?: number;
|
|
91
|
+
optional?: boolean;
|
|
92
|
+
min?: number;
|
|
93
|
+
max?: number;
|
|
94
|
+
integer?: boolean;
|
|
95
|
+
description?: string;
|
|
96
|
+
} | {
|
|
97
|
+
type: "boolean";
|
|
98
|
+
default?: boolean;
|
|
99
|
+
optional?: boolean;
|
|
100
|
+
description?: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: "port";
|
|
103
|
+
default?: number;
|
|
104
|
+
optional?: boolean;
|
|
105
|
+
description?: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: "url";
|
|
108
|
+
default?: string;
|
|
109
|
+
optional?: boolean;
|
|
110
|
+
protocols?: string[];
|
|
111
|
+
description?: string;
|
|
112
|
+
} | {
|
|
113
|
+
type: "email";
|
|
114
|
+
default?: string;
|
|
115
|
+
optional?: boolean;
|
|
116
|
+
description?: string;
|
|
117
|
+
} | {
|
|
118
|
+
type: "duration";
|
|
119
|
+
default?: number | string;
|
|
120
|
+
optional?: boolean;
|
|
121
|
+
description?: string;
|
|
122
|
+
} | {
|
|
123
|
+
type: "list";
|
|
124
|
+
default?: string[];
|
|
125
|
+
optional?: boolean;
|
|
126
|
+
separator?: string;
|
|
127
|
+
description?: string;
|
|
128
|
+
} | {
|
|
129
|
+
type: "json";
|
|
130
|
+
default?: unknown;
|
|
131
|
+
optional?: boolean;
|
|
132
|
+
description?: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "enum";
|
|
135
|
+
values: readonly string[];
|
|
136
|
+
default?: string;
|
|
137
|
+
optional?: boolean;
|
|
138
|
+
description?: string;
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* The type a variable gets once read.
|
|
142
|
+
*/
|
|
143
|
+
type EnvVarValue<S extends EnvVarSpec> = S["type"] extends "number" | "port" | "duration" ? number : S["type"] extends "boolean" ? boolean : S["type"] extends "list" ? string[] : S["type"] extends "json" ? any : S extends {
|
|
144
|
+
values: readonly (infer V)[];
|
|
145
|
+
} ? V : string;
|
|
146
|
+
/**
|
|
147
|
+
* What `validate()` returns.
|
|
148
|
+
*/
|
|
149
|
+
type EnvConfig<T extends Record<string, EnvVarSpec>> = { -readonly [K in keyof T]: T[K] extends {
|
|
150
|
+
optional: true;
|
|
151
|
+
} ? EnvVarValue<T[K]> | undefined : EnvVarValue<T[K]>; };
|
|
152
|
+
/**
|
|
153
|
+
* Parses the text of a `.env` file: quotes, multi-line values, `export`,
|
|
154
|
+
* comments, escapes, and `${VAR}` expansion (except in single quotes).
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* env.parse('PORT=3000\nURL="http://localhost:${PORT}"');
|
|
158
|
+
* // { PORT: "3000", URL: "http://localhost:3000" }
|
|
159
|
+
*
|
|
160
|
+
* @param {string} content
|
|
161
|
+
* @param {EnvParseOptions} [options]
|
|
162
|
+
* @returns {Record<string, string>}
|
|
163
|
+
*/
|
|
164
|
+
declare function parse(content: string, options?: EnvParseOptions): Record<string, string>;
|
|
165
|
+
/**
|
|
166
|
+
* Loads `.env` files into `process.env`. The first file to set a variable
|
|
167
|
+
* wins, and variables that are already set are kept, unless you pass
|
|
168
|
+
* `override`.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* env.load(); // ./.env
|
|
172
|
+
* env.load([".env.local", ".env"]); // local values win
|
|
173
|
+
* env.load(".env.test", { override: true });
|
|
174
|
+
*
|
|
175
|
+
* @param {string | string[]} [files=".env"] Relative to the working directory.
|
|
176
|
+
* @param {EnvLoadOptions} [options]
|
|
177
|
+
* @returns {Record<string, string>} Everything read from the files.
|
|
178
|
+
* @throws {Error} If `required` is set and a file is missing.
|
|
179
|
+
*/
|
|
180
|
+
declare function load(files?: string | string[], options?: EnvLoadOptions): Record<string, string>;
|
|
181
|
+
/**
|
|
182
|
+
* Reads a variable, with a fallback. Never throws.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* env.get("REGION", "eu-west-1");
|
|
186
|
+
*
|
|
187
|
+
* @param {string} name
|
|
188
|
+
* @param {string} [fallback]
|
|
189
|
+
* @returns {string | undefined}
|
|
190
|
+
*/
|
|
191
|
+
declare function get(name: string, fallback?: string): string | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* Is the variable set, even to an empty string?
|
|
194
|
+
*
|
|
195
|
+
* @param {string} name
|
|
196
|
+
* @returns {boolean}
|
|
197
|
+
*/
|
|
198
|
+
declare function has(name: string): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Reads a variable that must be set and not empty.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* const key = env.required("STRIPE_SECRET_KEY");
|
|
204
|
+
*
|
|
205
|
+
* @param {string} name
|
|
206
|
+
* @returns {string}
|
|
207
|
+
* @throws {ValidationError} If it's missing or empty.
|
|
208
|
+
*/
|
|
209
|
+
declare function required(name: string): string;
|
|
210
|
+
/**
|
|
211
|
+
* Reads a string. Required unless you give a default or `optional`.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* env.string("APP_NAME", { default: "my-app" });
|
|
215
|
+
*
|
|
216
|
+
* @param {string} name
|
|
217
|
+
* @param {EnvGetterOptions<string> & { pattern?: RegExp, minLength?: number }} [options]
|
|
218
|
+
* @returns {string}
|
|
219
|
+
* @throws {ValidationError}
|
|
220
|
+
*/
|
|
221
|
+
declare function string(name: string, options?: EnvGetterOptions<string> & {
|
|
222
|
+
pattern?: RegExp;
|
|
223
|
+
minLength?: number;
|
|
224
|
+
}): string;
|
|
225
|
+
/**
|
|
226
|
+
* Reads a number.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* env.number("WORKERS", { default: 4, min: 1, integer: true });
|
|
230
|
+
*
|
|
231
|
+
* @param {string} name
|
|
232
|
+
* @param {EnvGetterOptions<number> & { min?: number, max?: number, integer?: boolean }} [options]
|
|
233
|
+
* @returns {number}
|
|
234
|
+
* @throws {ValidationError}
|
|
235
|
+
*/
|
|
236
|
+
declare function number(name: string, options?: EnvGetterOptions<number> & {
|
|
237
|
+
min?: number;
|
|
238
|
+
max?: number;
|
|
239
|
+
integer?: boolean;
|
|
240
|
+
}): number;
|
|
241
|
+
/**
|
|
242
|
+
* Reads a boolean: `true`/`false`, `1`/`0`, `yes`/`no` or `on`/`off`.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* if (env.bool("FEATURE_BETA", { default: false })) enableBeta();
|
|
246
|
+
*
|
|
247
|
+
* @param {string} name
|
|
248
|
+
* @param {EnvGetterOptions<boolean>} [options]
|
|
249
|
+
* @returns {boolean}
|
|
250
|
+
* @throws {ValidationError}
|
|
251
|
+
*/
|
|
252
|
+
declare function bool(name: string, options?: EnvGetterOptions<boolean>): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Reads a port number.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* server.listen(env.port("PORT", { default: 3000 }));
|
|
258
|
+
*
|
|
259
|
+
* @param {string} name
|
|
260
|
+
* @param {EnvGetterOptions<number>} [options]
|
|
261
|
+
* @returns {number}
|
|
262
|
+
* @throws {ValidationError}
|
|
263
|
+
*/
|
|
264
|
+
declare function port(name: string, options?: EnvGetterOptions<number>): number;
|
|
265
|
+
/**
|
|
266
|
+
* Reads an absolute URL.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* env.url("DATABASE_URL", { protocols: ["postgres", "postgresql"] });
|
|
270
|
+
*
|
|
271
|
+
* @param {string} name
|
|
272
|
+
* @param {EnvGetterOptions<string> & { protocols?: string[] }} [options]
|
|
273
|
+
* @returns {string}
|
|
274
|
+
* @throws {ValidationError}
|
|
275
|
+
*/
|
|
276
|
+
declare function url(name: string, options?: EnvGetterOptions<string> & {
|
|
277
|
+
protocols?: string[];
|
|
278
|
+
}): string;
|
|
279
|
+
/**
|
|
280
|
+
* Reads a duration like `"30s"` or `"1h30m"` and returns milliseconds.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* env.duration("CACHE_TTL", { default: "10m" }); // 600000
|
|
284
|
+
*
|
|
285
|
+
* @param {string} name
|
|
286
|
+
* @param {EnvGetterOptions<number | string>} [options]
|
|
287
|
+
* @returns {number}
|
|
288
|
+
* @throws {ValidationError}
|
|
289
|
+
*/
|
|
290
|
+
declare function duration(name: string, options?: EnvGetterOptions<number | string>): number;
|
|
291
|
+
/**
|
|
292
|
+
* Reads a comma-separated list. Items are trimmed and empty ones dropped.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* // ALLOWED_ORIGINS="https://a.com, https://b.com"
|
|
296
|
+
* env.list("ALLOWED_ORIGINS", { default: [] }); // ["https://a.com", "https://b.com"]
|
|
297
|
+
*
|
|
298
|
+
* @param {string} name
|
|
299
|
+
* @param {EnvGetterOptions<string[]> & { separator?: string }} [options]
|
|
300
|
+
* @returns {string[]}
|
|
301
|
+
* @throws {ValidationError}
|
|
302
|
+
*/
|
|
303
|
+
declare function list(name: string, options?: EnvGetterOptions<string[]> & {
|
|
304
|
+
separator?: string;
|
|
305
|
+
}): string[];
|
|
306
|
+
/**
|
|
307
|
+
* Reads a JSON value.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* const flags = env.json("FEATURE_FLAGS", { default: {} });
|
|
311
|
+
*
|
|
312
|
+
* @template [T=any]
|
|
313
|
+
* @param {string} name
|
|
314
|
+
* @param {EnvGetterOptions<T>} [options]
|
|
315
|
+
* @returns {T}
|
|
316
|
+
* @throws {ValidationError}
|
|
317
|
+
*/
|
|
318
|
+
declare function json<T = any>(name: string, options?: EnvGetterOptions<T>): T;
|
|
319
|
+
/**
|
|
320
|
+
* Reads a variable that must be one of the given values. The result has
|
|
321
|
+
* their literal type.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* env.oneOf("LOG_LEVEL", ["debug", "info", "warn", "error"], { default: "info" });
|
|
325
|
+
*
|
|
326
|
+
* @template {string} V
|
|
327
|
+
* @param {string} name
|
|
328
|
+
* @param {readonly V[]} values
|
|
329
|
+
* @param {EnvGetterOptions<V>} [options]
|
|
330
|
+
* @returns {V}
|
|
331
|
+
* @throws {ValidationError}
|
|
332
|
+
*/
|
|
333
|
+
declare function oneOf<V extends string>(name: string, values: readonly V[], options?: EnvGetterOptions<V>): V;
|
|
334
|
+
/**
|
|
335
|
+
* Checks all your variables at once and returns a typed, frozen config. If
|
|
336
|
+
* anything is wrong, one `ValidationError` lists every problem, so a bad
|
|
337
|
+
* deployment fails at startup with the full picture.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* const config = env.validate({
|
|
341
|
+
* NODE_ENV: { type: "enum", values: ["development", "production", "test"], default: "development" },
|
|
342
|
+
* PORT: { type: "port", default: 3000 },
|
|
343
|
+
* DATABASE_URL: { type: "url", protocols: ["postgres"] },
|
|
344
|
+
* JWT_SECRET: { type: "string", minLength: 32 },
|
|
345
|
+
* SENTRY_DSN: { type: "url", optional: true },
|
|
346
|
+
* });
|
|
347
|
+
* // ValidationError: Validation failed with 2 issues:
|
|
348
|
+
* // • DATABASE_URL: is required but is not set
|
|
349
|
+
* // • JWT_SECRET: must contain at least 32 characters
|
|
350
|
+
*
|
|
351
|
+
* @template {Record<string, EnvVarSpec>} T
|
|
352
|
+
* @param {T} spec
|
|
353
|
+
* @param {{ env?: NodeJS.ProcessEnv }} [options]
|
|
354
|
+
* @returns {Readonly<EnvConfig<T>>}
|
|
355
|
+
* @throws {ValidationError}
|
|
356
|
+
*/
|
|
357
|
+
declare function validate<T extends Record<string, EnvVarSpec>>(spec: T, options?: {
|
|
358
|
+
env?: NodeJS.ProcessEnv;
|
|
359
|
+
}): Readonly<EnvConfig<T>>;
|
|
360
|
+
/**
|
|
361
|
+
* `NODE_ENV`, or `"development"` when it's not set.
|
|
362
|
+
*
|
|
363
|
+
* @returns {string}
|
|
364
|
+
*/
|
|
365
|
+
declare function mode(): string;
|
|
366
|
+
/**
|
|
367
|
+
* Is `NODE_ENV` set to `"production"`?
|
|
368
|
+
* @returns {boolean}
|
|
369
|
+
*/
|
|
370
|
+
declare function isProduction(): boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Is `NODE_ENV` `"development"`, or not set?
|
|
373
|
+
* @returns {boolean}
|
|
374
|
+
*/
|
|
375
|
+
declare function isDevelopment(): boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Are we running tests? True when `NODE_ENV` is `"test"` or a test runner
|
|
378
|
+
* like `node --test` or Jest is detected.
|
|
379
|
+
* @returns {boolean}
|
|
380
|
+
*/
|
|
381
|
+
declare function isTest(): boolean;
|
|
382
|
+
//# sourceMapping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