yavascript 0.0.7 → 0.0.9

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/yavascript.d.ts CHANGED
@@ -3,6 +3,109 @@
3
3
  // YavaScript APIs
4
4
  // ---------------
5
5
  // ===============
6
+ /**
7
+ * Prints help and usage text about the provided value, if any is available.
8
+ */
9
+ declare var help: {
10
+ /**
11
+ * Prints help and usage text about the provided value, if any is available.
12
+ */
13
+ (value?: any): void;
14
+
15
+ /**
16
+ * Set the help text for the provided value to the provided string.
17
+ *
18
+ * If the value is later passed into the `help` function, the provided text
19
+ * will be printed.
20
+ */
21
+ setHelpText: {
22
+ /**
23
+ * Set the help text for the provided value to the provided string.
24
+ *
25
+ * If the value is later passed into the `help` function, the provided text
26
+ * will be printed.
27
+ */
28
+ (value: object, text: string): void;
29
+
30
+ /**
31
+ * Lazily sets the help text for the provided value using the provided
32
+ * string-returning function.
33
+ *
34
+ * The first time help text is requested for the value, the string-returning
35
+ * function will be called, and its result will be registered as the help
36
+ * text for the value. Afterwards, the function will not be called again;
37
+ * instead, it will re-use the text returned from the first time the
38
+ * function was called.
39
+ */
40
+ lazy(value: object, getText: () => string): void;
41
+ };
42
+ };
43
+
44
+ /** Info about the currently-running yavascript binary */
45
+ declare const yavascript: {
46
+ /**
47
+ * The version of the currently-running yavascript binary.
48
+ *
49
+ * Will be something formatted like one of these:
50
+ * - "v0.0.7"
51
+ * - "v0.1.3-alpha"
52
+ * - "git-286a3a336849"
53
+ * - "git-286a3a336849-dirty"
54
+ *
55
+ * Or, more formally: either a "V" version string or a "GIT" version string:
56
+ * - "V" version strings start with the character 'v', followed by a semver
57
+ * version string, optionally followed by the character '-' and any
58
+ * arbitrary content afterwards.
59
+ * - "GIT" version strings start with the prefix "git-", followed by the
60
+ * first 12 digits of a git commit SHA, optionally followed by the
61
+ * character '-' and any arbitrary content afterwards.
62
+ */
63
+ version: string;
64
+
65
+ /** The processor architecture we're running on. */
66
+ arch: "x86_64" | "arm64";
67
+
68
+ /**
69
+ * The version of the ecma262 standard supported by the currently-running yavascript binary.
70
+ *
71
+ * Will always be in the format "ES" + a year. Is never lower than ES2020.
72
+ */
73
+ ecmaVersion: string;
74
+
75
+ /** The compilers yavascript uses internally to load files. */
76
+ compilers: {
77
+ js(
78
+ code: string,
79
+ options?: { filename?: string; expression?: boolean }
80
+ ): string;
81
+
82
+ tsx(
83
+ code: string,
84
+ options?: { filename?: string; expression?: boolean }
85
+ ): string;
86
+
87
+ ts(
88
+ code: string,
89
+ options?: { filename?: string; expression?: boolean }
90
+ ): string;
91
+
92
+ jsx(
93
+ code: string,
94
+ options?: { filename?: string; expression?: boolean }
95
+ ): string;
96
+
97
+ coffee(
98
+ code: string,
99
+ options?: { filename?: string; expression?: boolean }
100
+ ): string;
101
+
102
+ autodetect(
103
+ code: string,
104
+ options?: { filename?: string; expression?: boolean }
105
+ ): string;
106
+ };
107
+ };
108
+
6
109
  /**
7
110
  * An object representing the process's environment variables. You can read
8
111
  * from it to read environment variables, write into it to set environment
@@ -34,106 +137,67 @@ declare const env: { [key: string]: string | undefined };
34
137
  * Flags where you specify them multiple times, like `-vvv`, are not supported.
35
138
  * Write something like `-v 3` instead.
36
139
  *
37
- * @param hints - An object whose keys are flag names (in camelCase) and whose values indicate what type to treat that flag as. Valid property values are `String`, `Boolean`, `Number`, and `parseScriptArgs.Path`. `parseScriptArgs.Path` will resolve relative paths into absolute paths for you. If no hints object is specified, `parseScriptArgs` will do its best to guess, based on the command-line args.
140
+ * @param hints - An object whose keys are flag names (in camelCase) and whose values indicate what type to treat that flag as. Valid property values are `String`, `Boolean`, `Number`, and `Path`. `Path` will resolve relative paths into absolute paths for you. If no hints object is specified, `parseScriptArgs` will do its best to guess, based on the command-line args.
38
141
  * @param argv - An array containing the command line flags you want to parse. If unspecified, `scriptArgs.slice(2)` will be used (we slice 2 in order to skip the yavascript binary and script name). If you pass in an array here, it should only contain command-line flags, not the binary being called.
39
142
  *
40
143
  * @returns An object with two properties: `flags` and `args`. `flags` is an object whose keys are camelCase flag names and whose values are strings, booleans, or numbers corresponding to the input command-line args. `args` is an Array of positional arguments, as found on the command-line.
41
144
  */
42
- declare const parseScriptArgs: {
145
+ declare function parseScriptArgs(
146
+ hints?: {
147
+ [key: string]: typeof String | typeof Boolean | typeof Number | typeof Path;
148
+ },
149
+ args?: Array<string>
150
+ ): {
151
+ flags: { [key: string]: any };
152
+ args: Array<string>;
153
+ };
154
+
155
+ /**
156
+ * Read the contents of a file from disk.
157
+ */
158
+ declare const readFile: {
43
159
  /**
44
- * Parse command line --flags into an object of flags and an array of
45
- * positional arguments. This function is opinionated; if it doesn't meet your
46
- * needs, you can parse the `scriptArgs` global manually.
47
- *
48
- * Flags `--like-this`, `--like_this`, or `--LIKE_THIS` get converted into
49
- * property names `likeThis` on the returned flags object.
50
- *
51
- * Flags like this: `-v` get converted into into property names like this: `v`
52
- * on the returned flags object.
53
- *
54
- * Anything that appears after `--` is considered a positional argument instead
55
- * of a flag. `--` is not present in the returned positional arguments Array.
56
- *
57
- * Single-character flags must have a single leading dash, and multi-character
58
- * flags must have two leading dashes.
59
- *
60
- * Flags with equals signs in them (eg. `--something=42`) are not supported.
61
- * Write `--something 42` instead.
62
- *
63
- * Flags where you specify them multiple times, like `-vvv`, are not supported.
64
- * Write something like `-v 3` instead.
65
- *
66
- * @param hints - An object whose keys are flag names (in camelCase) and whose values indicate what type to treat that flag as. Valid property values are `String`, `Boolean`, `Number`, and `parseScriptArgs.Path`. `parseScriptArgs.Path` will resolve relative paths into absolute paths for you. If no hints object is specified, `parseScriptArgs` will do its best to guess, based on the command-line args.
67
- * @param args - An array containing the command line flags you want to parse. If unspecified, `scriptArgs.slice(2)` will be used (we slice 2 in order to skip the yavascript binary and script name). If you pass in an array here, it should only contain command-line flags, not the binary being called.
68
- *
69
- * @returns An object with two properties: `flags` and `args`. `flags` is an object whose keys are camelCase flag names and whose values are strings, booleans, or numbers corresponding to the input command-line args. `args` is an Array of positional arguments, as found on the command-line.
160
+ * Read the contents of a file from disk, as a UTF-8 string.
70
161
  */
71
- (
72
- hints?: {
73
- [key: string]:
74
- | typeof String
75
- | typeof Boolean
76
- | typeof Number
77
- | typeof parseScriptArgs["Path"];
78
- },
79
- args?: Array<string>
80
- ): {
81
- flags: { [key: string]: any };
82
- args: Array<string>;
83
- };
162
+ (path: string | Path): string;
84
163
 
85
164
  /**
86
- * A hint value for {@link parseScriptArgs}. Behaves similar to the hint value
87
- * `String`, except that it also resolves relative paths into absolute paths,
88
- * using the following rules:
89
- *
90
- * - paths `./like/this` or `../like/this` get resolved relative to `pwd()`.
91
- * - paths `like/this` or `this` get resolved relative to `pwd()` as if they had a leading `./`.
165
+ * Read the contents of a file from disk, as a UTF-8 string.
92
166
  */
93
- readonly Path: unique symbol;
94
- };
167
+ (path: string | Path, options: {}): string;
95
168
 
96
- /**
97
- * Read the contents of a file from disk, as a UTF-8 string.
98
- */
99
- declare function readFile(path: string): string;
169
+ /**
170
+ * Read the contents of a file from disk, as a UTF-8 string.
171
+ */
172
+ (path: string | Path, options: { binary: false }): string;
173
+
174
+ /**
175
+ * Read the contents of a file from disk, as an ArrayBuffer.
176
+ */
177
+ (path: string | Path, options: { binary: true }): ArrayBuffer;
178
+ };
100
179
 
101
180
  /**
102
181
  * Write the contents of a string or ArrayBuffer to a file.
103
182
  *
104
183
  * Strings are written using the UTF-8 encoding.
105
184
  */
106
- declare function writeFile(path: string, data: string | ArrayBuffer): void;
107
-
108
- /**
109
- * Function which returns true if the path points to a directory, or if the
110
- * path points to a symlink which points to a directory. Otherwise, it returns
111
- * false.
112
- */
113
- interface IsDir {
114
- /**
115
- * Returns true if the path points to a directory, or if the path points to
116
- * a symlink which points to a directory. Otherwise, returns false.
117
- */
118
- (path: string): boolean;
119
-
120
- /**
121
- * Maximum number of symlinks to follow before erroring. Defaults to 100.
122
- */
123
- symlinkLimit: number;
124
- }
185
+ declare function writeFile(
186
+ path: string | Path,
187
+ data: string | ArrayBuffer
188
+ ): void;
125
189
 
126
190
  /**
127
191
  * Function which returns true if the path points to a directory, or if the
128
192
  * path points to a symlink which points to a directory. Otherwise, it returns
129
193
  * false.
130
194
  */
131
- declare const isDir: IsDir;
195
+ declare function isDir(path: string | Path): boolean;
132
196
 
133
197
  /**
134
198
  * Returns true if the path points to a symlink.
135
199
  */
136
- declare function isLink(path: string): boolean;
200
+ declare function isLink(path: string | Path): boolean;
137
201
 
138
202
  /**
139
203
  * Delete the file or directory at the specified path.
@@ -142,22 +206,22 @@ declare function isLink(path: string): boolean;
142
206
  *
143
207
  * Provides the same functionality as the command `rm -rf`.
144
208
  */
145
- declare function remove(path: string): void;
209
+ declare function remove(path: string | Path): void;
146
210
 
147
211
  /**
148
212
  * Returns true if a file or directory exists at the specified path.
149
213
  *
150
214
  * Provides the same functionality as the command `test -e`.
151
215
  */
152
- declare function exists(path: string): boolean;
216
+ declare function exists(path: string | Path): boolean;
153
217
 
154
218
  /**
155
- * Create directories for each of the provided path components,
219
+ * Creates directories for each of the provided path components,
156
220
  * if they don't already exist.
157
221
  *
158
222
  * Provides the same functionality as the command `mkdir -p`.
159
223
  */
160
- declare function ensureDir(path: string): string;
224
+ declare function ensureDir(path: string | Path): string;
161
225
 
162
226
  /**
163
227
  * Options for {@link copy}.
@@ -185,12 +249,23 @@ declare type CopyOptions = {
185
249
  };
186
250
 
187
251
  /**
188
- * Copy a file or folder from one location to another.
252
+ * Copies a file or folder from one location to another.
189
253
  * Folders are copied recursively.
190
254
  *
191
255
  * Provides the same functionality as the command `cp -R`.
192
256
  */
193
- declare function copy(from: string, to: string, options?: CopyOptions): void;
257
+ declare function copy(
258
+ from: string | Path,
259
+ to: string | Path,
260
+ options?: CopyOptions
261
+ ): void;
262
+
263
+ /**
264
+ * Rename the file or directory at the specified path.
265
+ *
266
+ * Provides the same functionality as the command `mv`.
267
+ */
268
+ declare function rename(from: string | Path, to: string | Path): void;
194
269
 
195
270
  /** An object that represents a filesystem path. */
196
271
  declare class Path {
@@ -238,10 +313,22 @@ declare class Path {
238
313
  ): string;
239
314
 
240
315
  /**
241
- * Return whether the provided path string is absolute; that is, whether it
316
+ * Return whether the provided path is absolute; that is, whether it
242
317
  * starts with either `/` or a drive letter (ie `C:`).
243
318
  */
244
- static isAbsolute(path: string): boolean;
319
+ static isAbsolute(path: string | Path): boolean;
320
+
321
+ /** A tagged template literal function that creates a `Path` object. */
322
+ static tag(
323
+ strings: TemplateStringsArray,
324
+ ...values: ReadonlyArray<string | Path | Array<string | Path>>
325
+ ): Path;
326
+
327
+ /**
328
+ * Returns a tagged template literal that creates a `Path` object. `dir` is
329
+ * used as a prefix for every `Path` object created.
330
+ */
331
+ static tagUsingBase(dir: string | Path): typeof Path.tag;
245
332
 
246
333
  /**
247
334
  * An array of the path segments that make up this path.
@@ -293,38 +380,65 @@ declare class Path {
293
380
  */
294
381
  isAbsolute(): boolean;
295
382
 
383
+ /**
384
+ * Make a second Path object containing the same information as this one.
385
+ */
386
+ clone(): this;
387
+
388
+ /**
389
+ * Express this path relative to `dir`.
390
+ *
391
+ * @param dir - The directory to create a new path relative to.
392
+ * @param options - Options that affect the resulting path.
393
+ */
394
+ relativeTo(
395
+ dir: Path | string,
396
+ options?: {
397
+ /**
398
+ * Defaults to false. When true, a leading `./` will be omitted from the
399
+ * path, if present. Note that a leading `../` will never be omitted.
400
+ */
401
+ noLeadingDot?: boolean;
402
+ }
403
+ ): Path;
404
+
296
405
  /**
297
406
  * Turn this path into a string by joining its segments using its separator.
298
407
  */
299
408
  toString(): string;
409
+
410
+ /**
411
+ * Alias for `toString`; causes Path objects to be serialized as strings.
412
+ */
413
+ toJSON(): string;
300
414
  }
301
415
 
302
416
  /**
303
417
  * The absolute path to the current file (whether script or module).
304
418
  *
305
- * Behaves the same as in Node.js, except that it's present within ES modules.
419
+ * Behaves the same as in Node.js, except that it's also present within ES modules.
306
420
  */
307
- declare const __filename: string;
421
+ declare var __filename: string;
308
422
 
309
423
  /**
310
424
  * The absolute path to the directory the current file is inside of.
311
425
  *
312
- * Behaves the same as in Node.js, except that it's present within ES modules.
426
+ * Behaves the same as in Node.js, except that it's also present within ES modules.
313
427
  */
314
- declare const __dirname: string;
428
+ declare var __dirname: string;
315
429
 
316
430
  /**
317
431
  * Return the last component of a path string.
318
432
  *
319
433
  * Provides the same functionality as the unix binary of the same name.
320
434
  */
321
- declare function basename(path: string): string;
435
+ declare function basename(path: string | Path): string;
322
436
 
323
437
  /**
324
438
  * Read the contents of one of more files from disk as one UTF-8 string,
325
439
  * print that string to stdout, then return it.
326
440
  */
327
- declare function cat(...paths: Array<string>): string;
441
+ declare function cat(...paths: Array<string | Path>): string;
328
442
 
329
443
  /**
330
444
  * Change the process's current working directory to the specified path. If no
@@ -332,7 +446,7 @@ declare function cat(...paths: Array<string>): string;
332
446
  *
333
447
  * Provides the same functionality as the shell builtin of the same name.
334
448
  */
335
- declare function cd(path?: string): void;
449
+ declare function cd(path?: string | Path): void;
336
450
 
337
451
  /** A string representing who a permission applies to. */
338
452
  declare type ChmodPermissionsWho =
@@ -375,7 +489,7 @@ declare function chmod(
375
489
  | number
376
490
  | string
377
491
  | Record<ChmodPermissionsWho, ChmodPermissionsWhat>,
378
- path: string
492
+ path: string | Path
379
493
  ): void;
380
494
 
381
495
  /**
@@ -383,7 +497,7 @@ declare function chmod(
383
497
  *
384
498
  * Provides the same functionality as the unix binary of the same name.
385
499
  */
386
- declare function dirname(path: string): string;
500
+ declare function dirname(path: string | Path): string;
387
501
 
388
502
  /**
389
503
  * Print one or more values to stdout.
@@ -398,42 +512,46 @@ declare const echo: typeof console.log;
398
512
  * Pass `{ full: true }` to get compound extensions, eg `.d.ts` or `.test.js` instead of just `.ts`/`.js`.
399
513
  */
400
514
  declare function extname(
401
- pathOrFilename: string,
515
+ pathOrFilename: string | Path,
402
516
  options?: { full?: boolean }
403
517
  ): string;
404
518
 
405
519
  /**
406
- * Return the contents of a directory, as absolute paths. `.` and `..` are
520
+ * Returns the contents of a directory, as absolute paths. `.` and `..` are
407
521
  * omitted.
408
522
  *
409
523
  * Use the `relativePaths` option to get relative paths instead (relative to
410
524
  * the parent directory).
411
525
  */
412
526
  declare function ls(
413
- dir?: string,
527
+ dir?: string | Path,
414
528
  options?: { relativePaths?: boolean }
415
529
  ): Array<string>;
416
530
 
417
531
  /**
418
532
  * Print data to stdout using C-style format specifiers.
533
+ *
534
+ * The same formats as the standard C library printf are supported. Integer
535
+ * format types (e.g. `%d`) truncate the Numbers or BigInts to 32 bits. Use the l
536
+ * modifier (e.g. `%ld`) to truncate to 64 bits.
419
537
  */
420
538
  declare function printf(format: string, ...args: Array<any>): void;
421
539
 
422
540
  /**
423
- * Return the process's current working directory.
541
+ * Returns the process's current working directory.
424
542
  *
425
543
  * Provides the same functionality as the shell builtin of the same name.
426
544
  */
427
545
  declare function pwd(): string;
428
546
 
429
547
  /**
430
- * Read a symlink.
548
+ * Reads a symlink.
431
549
  *
432
550
  * Returns the target of the symlink, which may be absolute or relative.
433
551
  *
434
552
  * Provides the same functionality as the unix binary of the same name.
435
553
  */
436
- declare function readlink(path: string): string;
554
+ declare function readlink(path: string | Path): string;
437
555
 
438
556
  /**
439
557
  * Get the absolute path given a relative path. Symlinks are also resolved.
@@ -442,7 +560,7 @@ declare function readlink(path: string): string;
442
560
  *
443
561
  * Provides the same functionality as the unix binary of the same name.
444
562
  */
445
- declare function realpath(path: string): string;
563
+ declare function realpath(path: string | Path): string;
446
564
 
447
565
  /**
448
566
  * If the file at `path` exists, update its creation/modification timestamps.
@@ -451,11 +569,11 @@ declare function realpath(path: string): string;
451
569
  *
452
570
  * @param path The target path for the file.
453
571
  */
454
- declare function touch(path: string): void;
572
+ declare function touch(path: string | Path): void;
455
573
 
456
574
  declare type BaseExecOptions = {
457
575
  /** Sets the current working directory for the child process. */
458
- cwd?: string;
576
+ cwd?: string | Path;
459
577
 
460
578
  /** Sets environment variables within the process. */
461
579
  env?: { [key: string | number]: string | number | boolean };
@@ -470,12 +588,26 @@ declare type BaseExecOptions = {
470
588
  * ```
471
589
  */
472
590
  trace?: (...args: Array<any>) => void;
591
+
592
+ /**
593
+ * Whether an Error should be thrown when the process exits with a nonzero
594
+ * status code.
595
+ *
596
+ * Defaults to true.
597
+ */
598
+ failOnNonZeroStatus?: boolean;
599
+
600
+ /**
601
+ * If true, stdout and stderr will be collected into strings and returned
602
+ * instead of being printed to the screen.
603
+ *
604
+ * Defaults to false.
605
+ */
606
+ captureOutput?: boolean;
473
607
  };
474
608
 
475
609
  declare interface Exec {
476
- (args: Array<string> | string): void;
477
-
478
- (args: Array<string> | string, options: Record<string, never>): void;
610
+ (args: Array<string> | string, options?: BaseExecOptions): void;
479
611
 
480
612
  (
481
613
  args: Array<string> | string,
@@ -519,6 +651,19 @@ declare interface Exec {
519
651
  | { status: number; signal: undefined }
520
652
  | { status: undefined; signal: number };
521
653
 
654
+ (
655
+ args: Array<string> | string,
656
+ options: BaseExecOptions & {
657
+ /**
658
+ * Whether an Error should be thrown when the process exits with a nonzero
659
+ * status code.
660
+ *
661
+ * Defaults to true.
662
+ */
663
+ failOnNonZeroStatus: true;
664
+ }
665
+ ): void;
666
+
522
667
  (
523
668
  args: Array<string> | string,
524
669
  options: BaseExecOptions & {
@@ -567,6 +712,19 @@ declare interface Exec {
567
712
  }
568
713
  ): { stdout: string; stderr: string };
569
714
 
715
+ (
716
+ args: Array<string> | string,
717
+ options: BaseExecOptions & {
718
+ /**
719
+ * If true, stdout and stderr will be collected into strings and returned
720
+ * instead of being printed to the screen.
721
+ *
722
+ * Defaults to false.
723
+ */
724
+ captureOutput: false;
725
+ }
726
+ ): void;
727
+
570
728
  (
571
729
  args: Array<string> | string,
572
730
  options: BaseExecOptions & {
@@ -584,7 +742,7 @@ declare interface Exec {
584
742
  | { stdout: string; stderr: string; status: undefined; signal: number };
585
743
  }
586
744
 
587
- /** Run a child process using the provided arguments. The first value in the arguments array is the program to run. */
745
+ /** Runs a child process using the provided arguments. The first value in the arguments array is the program to run. */
588
746
  declare const exec: Exec;
589
747
 
590
748
  /** Alias for `exec(args, { captureOutput: true })` */
@@ -593,6 +751,100 @@ declare function $(args: Array<string> | string): {
593
751
  stderr: string;
594
752
  };
595
753
 
754
+ /** A class which represents a child process. The process may or may not be running. */
755
+ declare interface ChildProcess {
756
+ /**
757
+ * The argv for the process. The first entry in this array is the program to
758
+ * run.
759
+ */
760
+ args: Array<string>;
761
+
762
+ /** The current working directory for the process. */
763
+ cwd: string;
764
+
765
+ /** The environment variables for the process. */
766
+ env: { [key: string]: string };
767
+
768
+ /**
769
+ * The standard I/O streams for the process. Generally these are the same as
770
+ * `std.in`, `std.out`, and `std.err`, but they can be customized to write
771
+ * output elsewhere.
772
+ */
773
+ stdio: {
774
+ /** Where the process reads stdin from */
775
+ in: FILE;
776
+ /** Where the process writes stdout to */
777
+ out: FILE;
778
+ /** Where the process writes stderr to */
779
+ err: FILE;
780
+ };
781
+
782
+ /**
783
+ * Optional trace function which, if present, will be called at various times
784
+ * to provide information about the lifecycle of the process.
785
+ */
786
+ trace?: (...args: Array<any>) => void;
787
+
788
+ pid: number | null;
789
+
790
+ /** Spawns the process and returns its pid (process id). */
791
+ start(): number;
792
+
793
+ /** Blocks the calling thread until the process exits or is killed. */
794
+ waitUntilComplete():
795
+ | { status: number; signal: undefined }
796
+ | { status: undefined; signal: number };
797
+ }
798
+
799
+ /**
800
+ * Options to be passed to the ChildProcess constructor. Their purposes and
801
+ * types match the same-named properties found on the resulting ChildProcess.
802
+ */
803
+ declare type ChildProcessOptions = {
804
+ /** The current working directory for the process. */
805
+ cwd?: string;
806
+
807
+ /** The environment variables for the process. */
808
+ env?: { [key: string]: string };
809
+
810
+ /**
811
+ * The standard I/O streams for the process. Generally these are the same as
812
+ * `std.in`, `std.out`, and `std.err`, but they can be customized to write
813
+ * output elsewhere.
814
+ */
815
+ stdio?: {
816
+ /** Where the process reads stdin from */
817
+ in?: FILE;
818
+ /** Where the process writes stdout to */
819
+ out?: FILE;
820
+ /** Where the process writes stderr to */
821
+ err?: FILE;
822
+ };
823
+
824
+ /**
825
+ * Optional trace function which, if present, will be called at various times
826
+ * to provide information about the lifecycle of the process.
827
+ */
828
+ trace?: (...args: Array<any>) => void;
829
+ };
830
+
831
+ declare interface ChildProcessConstructor {
832
+ /**
833
+ * Construct a new ChildProcess.
834
+ *
835
+ * @param args - The argv for the process. The first entry in this array is the program to run.
836
+ * @param options - Options for the process (cwd, env, stdio, etc)
837
+ */
838
+ new (
839
+ args: string | Array<string>,
840
+ options?: ChildProcessOptions
841
+ ): ChildProcess;
842
+
843
+ readonly prototype: ChildProcess;
844
+ }
845
+
846
+ declare var ChildProcess: ChildProcessConstructor;
847
+
596
848
  /**
597
849
  * Options for {@link glob}.
598
850
  */
@@ -620,7 +872,7 @@ declare type GlobOptions = {
620
872
  /**
621
873
  * Directory to interpret glob patterns relative to. Defaults to `pwd()`.
622
874
  */
623
- dir?: string;
875
+ dir?: string | Path;
624
876
  };
625
877
 
626
878
  /**
@@ -632,7 +884,17 @@ declare type GlobOptions = {
632
884
  declare function glob(
633
885
  patterns: string | Array<string>,
634
886
  options?: GlobOptions
635
- ): Array<string>;
887
+ ): Array<Path>;
888
+
889
+ /**
890
+ * Clear the contents and scrollback buffer of the tty by printing special characters into stdout.
891
+ */
892
+ declare function clear(): void;
893
+
894
+ interface Console {
895
+ /** Same as {@link clear}(). */
896
+ clear: typeof clear;
897
+ }
636
898
 
637
899
  /**
638
900
  * Remove ANSI control characters from a string.
@@ -644,11 +906,6 @@ declare function stripAnsi(input: string): string;
644
906
  */
645
907
  declare function quote(input: string): string;
646
908
 
647
- /**
648
- * Clear the contents and scrollback buffer of the tty by printing special characters into stdout.
649
- */
650
- declare function clear(): void;
651
-
652
909
  // Colors
653
910
 
654
911
  /** Wrap a string with the ANSI control characters that will make it print as black text. */
@@ -775,45 +1032,49 @@ declare const grepString: {
775
1032
  /** Read the content at `path`, split it on newline, and then return lines matching `pattern`. */
776
1033
  declare const grepFile: {
777
1034
  /** Read the content at `path`, split it on newline, and then return lines matching `pattern`. */
778
- (path: string, pattern: string | RegExp): Array<string>;
1035
+ (path: string | Path, pattern: string | RegExp): Array<string>;
779
1036
 
780
1037
  /** Read the content at `path`, split it on newline, and then return lines matching `pattern`. */
781
1038
  (
782
- path: string,
1039
+ path: string | Path,
783
1040
  pattern: string | RegExp,
784
1041
  options: { inverse: false }
785
1042
  ): Array<string>;
786
1043
 
787
1044
  /** Read the content at `path`, split it on newline, and then return lines NOT matching `pattern`. */
788
1045
  (
789
- path: string,
1046
+ path: string | Path,
790
1047
  pattern: string | RegExp,
791
1048
  options: { inverse: true }
792
1049
  ): Array<string>;
793
1050
 
794
1051
  /** Read the content at `path`, split it on newline, and then return lines matching `pattern`. */
795
1052
  (
796
- path: string,
1053
+ path: string | Path,
797
1054
  pattern: string | RegExp,
798
1055
  options: { details: false }
799
1056
  ): Array<string>;
800
1057
 
801
1058
  /** Read the content at `path`, split it on newline, and then return lines matching `pattern`. */
802
1059
  (
803
- path: string,
1060
+ path: string | Path,
804
1061
  pattern: string | RegExp,
805
1062
  options: { inverse: false; details: false }
806
1063
  ): Array<string>;
807
1064
 
808
1065
  /** Read the content at `path`, split it on newline, and then return lines NOT matching `pattern`. */
809
1066
  (
810
- path: string,
1067
+ path: string | Path,
811
1068
  pattern: string | RegExp,
812
1069
  options: { inverse: true; details: false }
813
1070
  ): Array<string>;
814
1071
 
815
1072
  /** Read the content at `path`, split it on newline, and then return info about lines matching `pattern`. */
816
- (path: string, pattern: string | RegExp, options: { details: true }): Array<{
1073
+ (
1074
+ path: string | Path,
1075
+ pattern: string | RegExp,
1076
+ options: { details: true }
1077
+ ): Array<{
817
1078
  lineNumber: number;
818
1079
  lineContent: string;
819
1080
  matches: RegExpMatchArray;
@@ -821,14 +1082,14 @@ declare const grepFile: {
821
1082
 
822
1083
  /** Read the content at `path`, split it on newline, and then return info about lines matching `pattern`. */
823
1084
  (
824
- path: string,
1085
+ path: string | Path,
825
1086
  pattern: string | RegExp,
826
1087
  options: { inverse: false; details: true }
827
1088
  ): Array<string>;
828
1089
 
829
1090
  /** Read the content at `path`, split it on newline, and then return info about lines NOT matching `pattern`. */
830
1091
  (
831
- path: string,
1092
+ path: string | Path,
832
1093
  pattern: string | RegExp,
833
1094
  options: { inverse: true; details: true }
834
1095
  ): Array<string>;
@@ -882,17 +1143,100 @@ interface String {
882
1143
  };
883
1144
  }
884
1145
 
885
- declare type TypedArray =
886
- | Int8Array
887
- | Uint8Array
888
- | Uint8ClampedArray
889
- | Int16Array
890
- | Uint16Array
891
- | Int32Array
892
- | Uint32Array
893
- | Float32Array
894
- | Float64Array;
895
- declare type TypedArrayConstructor =
1146
+ declare type TypeValidator<T> = (value: any) => value is T;
1147
+
1148
+ declare type CoerceToTypeValidator<V extends CoerceableToTypeValidator> =
1149
+ V extends StringConstructor
1150
+ ? TypeValidator<string>
1151
+ : V extends NumberConstructor
1152
+ ? TypeValidator<number>
1153
+ : V extends BooleanConstructor
1154
+ ? TypeValidator<boolean>
1155
+ : V extends BigIntConstructor
1156
+ ? TypeValidator<BigInt>
1157
+ : V extends SymbolConstructor
1158
+ ? TypeValidator<Symbol>
1159
+ : V extends RegExpConstructor
1160
+ ? TypeValidator<RegExp>
1161
+ : V extends ArrayConstructor
1162
+ ? TypeValidator<Array<unknown>>
1163
+ : V extends SetConstructor
1164
+ ? TypeValidator<Set<unknown>>
1165
+ : V extends MapConstructor
1166
+ ? TypeValidator<Map<unknown, unknown>>
1167
+ : V extends ObjectConstructor
1168
+ ? TypeValidator<{
1169
+ [key: string | number | symbol]: unknown;
1170
+ }>
1171
+ : V extends DateConstructor
1172
+ ? TypeValidator<Date>
1173
+ : V extends FunctionConstructor
1174
+ ? TypeValidator<Function>
1175
+ : V extends ArrayBufferConstructor
1176
+ ? TypeValidator<ArrayBuffer>
1177
+ : V extends SharedArrayBufferConstructor
1178
+ ? TypeValidator<SharedArrayBuffer>
1179
+ : V extends DataViewConstructor
1180
+ ? TypeValidator<DataView>
1181
+ : V extends Int8ArrayConstructor
1182
+ ? TypeValidator<Int8Array>
1183
+ : V extends Uint8ArrayConstructor
1184
+ ? TypeValidator<Uint8Array>
1185
+ : V extends Uint8ClampedArrayConstructor
1186
+ ? TypeValidator<Uint8ClampedArray>
1187
+ : V extends Int16ArrayConstructor
1188
+ ? TypeValidator<Int16Array>
1189
+ : V extends Uint16ArrayConstructor
1190
+ ? TypeValidator<Uint16Array>
1191
+ : V extends Int32ArrayConstructor
1192
+ ? TypeValidator<Int32Array>
1193
+ : V extends Uint32ArrayConstructor
1194
+ ? TypeValidator<Uint32Array>
1195
+ : V extends Float32ArrayConstructor
1196
+ ? TypeValidator<Float32Array>
1197
+ : V extends Float64ArrayConstructor
1198
+ ? TypeValidator<Float64Array>
1199
+ : V extends RegExp
1200
+ ? TypeValidator<string>
1201
+ : V extends {}
1202
+ ? TypeValidator<{
1203
+ [key in keyof V]: CoerceToTypeValidator<V[key]>;
1204
+ }>
1205
+ : V extends []
1206
+ ? TypeValidator<[]>
1207
+ : V extends [any]
1208
+ ? TypeValidator<Array<CoerceToTypeValidator<V[0]>>>
1209
+ : V extends Array<any>
1210
+ ? TypeValidator<Array<unknown>>
1211
+ : V extends {
1212
+ new (...args: any): any;
1213
+ }
1214
+ ? TypeValidator<InstanceType<V>>
1215
+ : TypeValidator<V>;
1216
+
1217
+ declare type CoerceableToTypeValidator =
1218
+ | boolean
1219
+ | number
1220
+ | string
1221
+ | bigint
1222
+ | undefined
1223
+ | null
1224
+ | RegExp
1225
+ | StringConstructor
1226
+ | NumberConstructor
1227
+ | BooleanConstructor
1228
+ | BigIntConstructor
1229
+ | SymbolConstructor
1230
+ | RegExpConstructor
1231
+ | ArrayConstructor
1232
+ | SetConstructor
1233
+ | MapConstructor
1234
+ | ObjectConstructor
1235
+ | DateConstructor
1236
+ | FunctionConstructor
1237
+ | ArrayBufferConstructor
1238
+ | SharedArrayBufferConstructor
1239
+ | DataViewConstructor
896
1240
  | Int8ArrayConstructor
897
1241
  | Uint8ArrayConstructor
898
1242
  | Uint8ClampedArrayConstructor
@@ -901,89 +1245,1257 @@ declare type TypedArrayConstructor =
901
1245
  | Int32ArrayConstructor
902
1246
  | Uint32ArrayConstructor
903
1247
  | Float32ArrayConstructor
904
- | Float64ArrayConstructor;
1248
+ | Float64ArrayConstructor
1249
+ | {}
1250
+ | []
1251
+ | [any]
1252
+ | Array<any>
1253
+ | {
1254
+ new (...args: any): any;
1255
+ };
905
1256
 
906
- declare const is: {
907
- string(value: any): value is string;
908
- String(value: any): value is string;
909
- number(value: any): value is number;
910
- Number(value: any): value is number;
911
- boolean(value: any): value is boolean;
912
- Boolean(value: any): value is boolean;
913
- bigint(value: any): value is bigint;
914
- BigInt(value: any): value is bigint;
915
- symbol(value: any): value is symbol;
916
- Symbol(value: any): value is symbol;
917
- null(value: any): value is null;
918
- undefined(value: any): value is undefined;
919
- void(value: any): value is null | undefined;
920
- object(value: any): value is {
921
- [key: string]: unknown;
922
- [key: number]: unknown;
923
- [key: symbol]: unknown;
924
- };
925
- Object(value: any): value is {
926
- [key: string]: unknown;
927
- [key: number]: unknown;
928
- [key: symbol]: unknown;
929
- };
930
- Array(value: any): value is unknown[];
931
- function(value: any): value is Function & {
932
- [key: string]: unknown;
933
- [key: number]: unknown;
934
- [key: symbol]: unknown;
935
- };
936
- Function(value: any): value is Function & {
937
- [key: string]: unknown;
938
- [key: number]: unknown;
939
- [key: symbol]: unknown;
940
- };
941
- tagged(value: any, tag: string): boolean;
942
- instanceOf<T>(value: any, klass: new (...args: any) => T): value is T;
943
- Error(value: any): value is Error;
944
- Infinity(value: any): value is number;
945
- NegativeInfinity(value: any): value is number;
946
- NaN(value: any): value is number;
947
- Date(value: any): value is Date;
948
- RegExp(value: any): value is RegExp;
949
- Map(value: any): value is Map<unknown, unknown>;
950
- Set(value: any): value is Set<unknown>;
951
- WeakMap(value: any): value is Map<unknown, unknown>;
952
- WeakSet(value: any): value is Set<unknown>;
953
- ArrayBuffer(value: any): value is ArrayBuffer;
954
- SharedArrayBuffer(value: any): value is SharedArrayBuffer;
955
- DataView(value: any): value is DataView;
956
- TypedArray(value: any): value is TypedArray;
957
- Int8Array(value: any): value is Int8Array;
958
- Uint8Array(value: any): value is Uint8Array;
959
- Uint8ClampedArray(value: any): value is Uint8ClampedArray;
960
- Int16Array(value: any): value is Int16Array;
961
- Uint16Array(value: any): value is Uint16Array;
962
- Int32Array(value: any): value is Int32Array;
963
- Uint32Array(value: any): value is Uint32Array;
964
- Float32Array(value: any): value is Float32Array;
965
- Float64Array(value: any): value is Float64Array;
966
- Promise(value: any): value is Promise<unknown>;
967
- Generator(value: any): value is Generator<unknown, any, unknown>;
968
- GeneratorFunction(value: any): value is GeneratorFunction;
969
- AsyncFunction(value: any): value is ((...args: any) => Promise<unknown>) & {
970
- [key: string]: unknown;
971
- [key: number]: unknown;
972
- [key: symbol]: unknown;
1257
+ declare type UnwrapTypeFromCoerceableOrValidator<
1258
+ V extends CoerceableToTypeValidator | TypeValidator<any> | unknown
1259
+ > = V extends TypeValidator<infer T>
1260
+ ? T
1261
+ : V extends CoerceableToTypeValidator
1262
+ ? CoerceToTypeValidator<V> extends TypeValidator<infer T>
1263
+ ? T
1264
+ : never
1265
+ : unknown;
1266
+
1267
+ declare const types: {
1268
+ // basic types
1269
+ any: TypeValidator<any>;
1270
+ unknown: TypeValidator<unknown>;
1271
+ anyObject: TypeValidator<{
1272
+ [key: string | number | symbol]: any;
1273
+ }>;
1274
+ unknownObject: TypeValidator<{}>;
1275
+ object: TypeValidator<{}>;
1276
+ Object: TypeValidator<{}>;
1277
+ arrayOfAny: TypeValidator<Array<any>>;
1278
+ arrayOfUnknown: TypeValidator<Array<unknown>>;
1279
+ array: TypeValidator<Array<unknown>>;
1280
+ Array: TypeValidator<unknown[]>;
1281
+ anyArray: TypeValidator<Array<any>>;
1282
+ boolean: TypeValidator<boolean>;
1283
+ Boolean: TypeValidator<boolean>;
1284
+ string: TypeValidator<string>;
1285
+ String: TypeValidator<string>;
1286
+ null: TypeValidator<null>;
1287
+ undefined: TypeValidator<undefined>;
1288
+ nullish: TypeValidator<null | undefined>;
1289
+ void: TypeValidator<null | undefined>;
1290
+ numberIncludingNanAndInfinities: TypeValidator<number>;
1291
+ number: TypeValidator<number>;
1292
+ Number: TypeValidator<number>;
1293
+ NaN: TypeValidator<number>;
1294
+ Infinity: TypeValidator<number>;
1295
+ NegativeInfinity: TypeValidator<number>;
1296
+ integer: TypeValidator<number>;
1297
+ bigint: TypeValidator<bigint>;
1298
+ BigInt: TypeValidator<bigint>;
1299
+ never: TypeValidator<never>;
1300
+ anyFunction: TypeValidator<(...args: any) => any>;
1301
+ unknownFunction: TypeValidator<(...args: Array<unknown>) => unknown>;
1302
+ Function: TypeValidator<(...args: Array<unknown>) => unknown>;
1303
+ false: TypeValidator<false>;
1304
+ true: TypeValidator<true>;
1305
+ falsy: TypeValidator<false | null | undefined | "" | 0>;
1306
+ truthy: <T>(target: false | "" | 0 | T | null | undefined) => target is T;
1307
+ nonNullOrUndefined: <T>(target: T | null | undefined) => target is T;
1308
+ Error: TypeValidator<Error>;
1309
+ Symbol: TypeValidator<symbol>;
1310
+ symbol: TypeValidator<symbol>;
1311
+ RegExp: TypeValidator<RegExp>;
1312
+ Date: TypeValidator<Date>;
1313
+ anyMap: TypeValidator<Map<any, any>>;
1314
+ unknownMap: TypeValidator<Map<unknown, unknown>>;
1315
+ map: TypeValidator<Map<unknown, unknown>>;
1316
+ Map: TypeValidator<Map<unknown, unknown>>;
1317
+ anySet: TypeValidator<Set<any>>;
1318
+ unknownSet: TypeValidator<Set<unknown>>;
1319
+ set: TypeValidator<Set<unknown>>;
1320
+ Set: TypeValidator<Set<unknown>>;
1321
+ ArrayBuffer: TypeValidator<ArrayBuffer>;
1322
+ SharedArrayBuffer: TypeValidator<SharedArrayBuffer>;
1323
+ DataView: TypeValidator<DataView>;
1324
+ TypedArray: TypeValidator<
1325
+ | Int8Array
1326
+ | Uint8Array
1327
+ | Uint8ClampedArray
1328
+ | Int16Array
1329
+ | Uint16Array
1330
+ | Int32Array
1331
+ | Uint32Array
1332
+ | Float32Array
1333
+ | Float64Array
1334
+ >;
1335
+ Int8Array: TypeValidator<Int8Array>;
1336
+ Uint8Array: TypeValidator<Uint8Array>;
1337
+ Uint8ClampedArray: TypeValidator<Uint8ClampedArray>;
1338
+ Int16Array: TypeValidator<Int16Array>;
1339
+ Uint16Array: TypeValidator<Uint16Array>;
1340
+ Int32Array: TypeValidator<Int32Array>;
1341
+ Uint32Array: TypeValidator<Uint32Array>;
1342
+ Float32Array: TypeValidator<Float32Array>;
1343
+ Float64Array: TypeValidator<Float64Array>;
1344
+
1345
+ // type constructors
1346
+ exactString<T extends string>(str: T): TypeValidator<T>;
1347
+ exactNumber<T extends number>(num: T): TypeValidator<T>;
1348
+ exactBigInt<T extends bigint>(num: T): TypeValidator<T>;
1349
+ exactSymbol<T extends symbol>(sym: T): TypeValidator<T>;
1350
+ hasClassName<Name extends string>(
1351
+ name: Name
1352
+ ): TypeValidator<{
1353
+ constructor: Function & {
1354
+ name: Name;
1355
+ };
1356
+ }>;
1357
+ hasToStringTag(name: string): TypeValidator<any>;
1358
+ instanceOf<
1359
+ Klass extends Function & {
1360
+ prototype: any;
1361
+ }
1362
+ >(
1363
+ klass: Klass
1364
+ ): TypeValidator<Klass["prototype"]>;
1365
+ stringMatching(regexp: RegExp): TypeValidator<string>;
1366
+ symbolFor(key: string): TypeValidator<symbol>;
1367
+ arrayOf<T extends TypeValidator<any> | CoerceableToTypeValidator | unknown>(
1368
+ typeValidator: T
1369
+ ): TypeValidator<Array<UnwrapTypeFromCoerceableOrValidator<T>>>;
1370
+ intersection: {
1371
+ <
1372
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1373
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1374
+ >(
1375
+ first: First,
1376
+ second: Second
1377
+ ): TypeValidator<
1378
+ UnwrapTypeFromCoerceableOrValidator<First> &
1379
+ UnwrapTypeFromCoerceableOrValidator<Second>
1380
+ >;
1381
+ <
1382
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1383
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1384
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1385
+ >(
1386
+ first: First,
1387
+ second: Second,
1388
+ third: Third
1389
+ ): TypeValidator<
1390
+ UnwrapTypeFromCoerceableOrValidator<First> &
1391
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1392
+ UnwrapTypeFromCoerceableOrValidator<Third>
1393
+ >;
1394
+ <
1395
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1396
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1397
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1398
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1399
+ >(
1400
+ first: First,
1401
+ second: Second,
1402
+ third: Third,
1403
+ fourth: Fourth
1404
+ ): TypeValidator<
1405
+ UnwrapTypeFromCoerceableOrValidator<First> &
1406
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1407
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1408
+ UnwrapTypeFromCoerceableOrValidator<Fourth>
1409
+ >;
1410
+ <
1411
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1412
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1413
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1414
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1415
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1416
+ >(
1417
+ first: First,
1418
+ second: Second,
1419
+ third: Third,
1420
+ fourth: Fourth,
1421
+ fifth: Fifth
1422
+ ): TypeValidator<
1423
+ UnwrapTypeFromCoerceableOrValidator<First> &
1424
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1425
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1426
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1427
+ UnwrapTypeFromCoerceableOrValidator<Fifth>
1428
+ >;
1429
+ <
1430
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1431
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1432
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1433
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1434
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1435
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1436
+ >(
1437
+ first: First,
1438
+ second: Second,
1439
+ third: Third,
1440
+ fourth: Fourth,
1441
+ fifth: Fifth,
1442
+ sixth: Sixth
1443
+ ): TypeValidator<
1444
+ UnwrapTypeFromCoerceableOrValidator<First> &
1445
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1446
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1447
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1448
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1449
+ UnwrapTypeFromCoerceableOrValidator<Sixth>
1450
+ >;
1451
+ <
1452
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1453
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1454
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1455
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1456
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1457
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1458
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1459
+ >(
1460
+ first: First,
1461
+ second: Second,
1462
+ third: Third,
1463
+ fourth: Fourth,
1464
+ fifth: Fifth,
1465
+ sixth: Sixth,
1466
+ seventh: Seventh
1467
+ ): TypeValidator<
1468
+ UnwrapTypeFromCoerceableOrValidator<First> &
1469
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1470
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1471
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1472
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1473
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1474
+ UnwrapTypeFromCoerceableOrValidator<Seventh>
1475
+ >;
1476
+ <
1477
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1478
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1479
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1480
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1481
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1482
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1483
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1484
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1485
+ >(
1486
+ first: First,
1487
+ second: Second,
1488
+ third: Third,
1489
+ fourth: Fourth,
1490
+ fifth: Fifth,
1491
+ sixth: Sixth,
1492
+ seventh: Seventh,
1493
+ eighth: Eighth
1494
+ ): TypeValidator<
1495
+ UnwrapTypeFromCoerceableOrValidator<First> &
1496
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1497
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1498
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1499
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1500
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1501
+ UnwrapTypeFromCoerceableOrValidator<Seventh> &
1502
+ UnwrapTypeFromCoerceableOrValidator<Eighth>
1503
+ >;
1504
+ <
1505
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1506
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1507
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1508
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1509
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1510
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1511
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1512
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1513
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1514
+ >(
1515
+ first: First,
1516
+ second: Second,
1517
+ third: Third,
1518
+ fourth: Fourth,
1519
+ fifth: Fifth,
1520
+ sixth: Sixth,
1521
+ seventh: Seventh,
1522
+ eighth: Eighth,
1523
+ ninth: Ninth
1524
+ ): TypeValidator<
1525
+ UnwrapTypeFromCoerceableOrValidator<First> &
1526
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1527
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1528
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1529
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1530
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1531
+ UnwrapTypeFromCoerceableOrValidator<Seventh> &
1532
+ UnwrapTypeFromCoerceableOrValidator<Eighth> &
1533
+ UnwrapTypeFromCoerceableOrValidator<Ninth>
1534
+ >;
1535
+ <
1536
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1537
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1538
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1539
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1540
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1541
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1542
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1543
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1544
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1545
+ Tenth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1546
+ >(
1547
+ first: First,
1548
+ second: Second,
1549
+ third: Third,
1550
+ fourth: Fourth,
1551
+ fifth: Fifth,
1552
+ sixth: Sixth,
1553
+ seventh: Seventh,
1554
+ eighth: Eighth,
1555
+ ninth: Ninth,
1556
+ tenth: Tenth
1557
+ ): TypeValidator<
1558
+ UnwrapTypeFromCoerceableOrValidator<First> &
1559
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1560
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1561
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1562
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1563
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1564
+ UnwrapTypeFromCoerceableOrValidator<Seventh> &
1565
+ UnwrapTypeFromCoerceableOrValidator<Eighth> &
1566
+ UnwrapTypeFromCoerceableOrValidator<Ninth> &
1567
+ UnwrapTypeFromCoerceableOrValidator<Tenth>
1568
+ >;
973
1569
  };
974
- AsyncGenerator(value: any): value is AsyncGenerator<unknown, any, unknown>;
975
- AsyncGeneratorFunction(value: any): value is AsyncGeneratorFunction;
976
-
977
- FILE(value: any): value is FILE;
1570
+ and: {
1571
+ <
1572
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1573
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1574
+ >(
1575
+ first: First,
1576
+ second: Second
1577
+ ): TypeValidator<
1578
+ UnwrapTypeFromCoerceableOrValidator<First> &
1579
+ UnwrapTypeFromCoerceableOrValidator<Second>
1580
+ >;
1581
+ <
1582
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1583
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1584
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1585
+ >(
1586
+ first: First,
1587
+ second: Second,
1588
+ third: Third
1589
+ ): TypeValidator<
1590
+ UnwrapTypeFromCoerceableOrValidator<First> &
1591
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1592
+ UnwrapTypeFromCoerceableOrValidator<Third>
1593
+ >;
1594
+ <
1595
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1596
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1597
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1598
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1599
+ >(
1600
+ first: First,
1601
+ second: Second,
1602
+ third: Third,
1603
+ fourth: Fourth
1604
+ ): TypeValidator<
1605
+ UnwrapTypeFromCoerceableOrValidator<First> &
1606
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1607
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1608
+ UnwrapTypeFromCoerceableOrValidator<Fourth>
1609
+ >;
1610
+ <
1611
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1612
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1613
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1614
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1615
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1616
+ >(
1617
+ first: First,
1618
+ second: Second,
1619
+ third: Third,
1620
+ fourth: Fourth,
1621
+ fifth: Fifth
1622
+ ): TypeValidator<
1623
+ UnwrapTypeFromCoerceableOrValidator<First> &
1624
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1625
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1626
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1627
+ UnwrapTypeFromCoerceableOrValidator<Fifth>
1628
+ >;
1629
+ <
1630
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1631
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1632
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1633
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1634
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1635
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1636
+ >(
1637
+ first: First,
1638
+ second: Second,
1639
+ third: Third,
1640
+ fourth: Fourth,
1641
+ fifth: Fifth,
1642
+ sixth: Sixth
1643
+ ): TypeValidator<
1644
+ UnwrapTypeFromCoerceableOrValidator<First> &
1645
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1646
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1647
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1648
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1649
+ UnwrapTypeFromCoerceableOrValidator<Sixth>
1650
+ >;
1651
+ <
1652
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1653
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1654
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1655
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1656
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1657
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1658
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1659
+ >(
1660
+ first: First,
1661
+ second: Second,
1662
+ third: Third,
1663
+ fourth: Fourth,
1664
+ fifth: Fifth,
1665
+ sixth: Sixth,
1666
+ seventh: Seventh
1667
+ ): TypeValidator<
1668
+ UnwrapTypeFromCoerceableOrValidator<First> &
1669
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1670
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1671
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1672
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1673
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1674
+ UnwrapTypeFromCoerceableOrValidator<Seventh>
1675
+ >;
1676
+ <
1677
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1678
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1679
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1680
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1681
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1682
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1683
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1684
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1685
+ >(
1686
+ first: First,
1687
+ second: Second,
1688
+ third: Third,
1689
+ fourth: Fourth,
1690
+ fifth: Fifth,
1691
+ sixth: Sixth,
1692
+ seventh: Seventh,
1693
+ eighth: Eighth
1694
+ ): TypeValidator<
1695
+ UnwrapTypeFromCoerceableOrValidator<First> &
1696
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1697
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1698
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1699
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1700
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1701
+ UnwrapTypeFromCoerceableOrValidator<Seventh> &
1702
+ UnwrapTypeFromCoerceableOrValidator<Eighth>
1703
+ >;
1704
+ <
1705
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1706
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1707
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1708
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1709
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1710
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1711
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1712
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1713
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1714
+ >(
1715
+ first: First,
1716
+ second: Second,
1717
+ third: Third,
1718
+ fourth: Fourth,
1719
+ fifth: Fifth,
1720
+ sixth: Sixth,
1721
+ seventh: Seventh,
1722
+ eighth: Eighth,
1723
+ ninth: Ninth
1724
+ ): TypeValidator<
1725
+ UnwrapTypeFromCoerceableOrValidator<First> &
1726
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1727
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1728
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1729
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1730
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1731
+ UnwrapTypeFromCoerceableOrValidator<Seventh> &
1732
+ UnwrapTypeFromCoerceableOrValidator<Eighth> &
1733
+ UnwrapTypeFromCoerceableOrValidator<Ninth>
1734
+ >;
1735
+ <
1736
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1737
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1738
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1739
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1740
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1741
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1742
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1743
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1744
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1745
+ Tenth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1746
+ >(
1747
+ first: First,
1748
+ second: Second,
1749
+ third: Third,
1750
+ fourth: Fourth,
1751
+ fifth: Fifth,
1752
+ sixth: Sixth,
1753
+ seventh: Seventh,
1754
+ eighth: Eighth,
1755
+ ninth: Ninth,
1756
+ tenth: Tenth
1757
+ ): TypeValidator<
1758
+ UnwrapTypeFromCoerceableOrValidator<First> &
1759
+ UnwrapTypeFromCoerceableOrValidator<Second> &
1760
+ UnwrapTypeFromCoerceableOrValidator<Third> &
1761
+ UnwrapTypeFromCoerceableOrValidator<Fourth> &
1762
+ UnwrapTypeFromCoerceableOrValidator<Fifth> &
1763
+ UnwrapTypeFromCoerceableOrValidator<Sixth> &
1764
+ UnwrapTypeFromCoerceableOrValidator<Seventh> &
1765
+ UnwrapTypeFromCoerceableOrValidator<Eighth> &
1766
+ UnwrapTypeFromCoerceableOrValidator<Ninth> &
1767
+ UnwrapTypeFromCoerceableOrValidator<Tenth>
1768
+ >;
1769
+ };
1770
+ union: {
1771
+ <
1772
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1773
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1774
+ >(
1775
+ first: First,
1776
+ second: Second
1777
+ ): TypeValidator<
1778
+ | UnwrapTypeFromCoerceableOrValidator<First>
1779
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1780
+ >;
1781
+ <
1782
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1783
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1784
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1785
+ >(
1786
+ first: First,
1787
+ second: Second,
1788
+ third: Third
1789
+ ): TypeValidator<
1790
+ | UnwrapTypeFromCoerceableOrValidator<First>
1791
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1792
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1793
+ >;
1794
+ <
1795
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1796
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1797
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1798
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1799
+ >(
1800
+ first: First,
1801
+ second: Second,
1802
+ third: Third,
1803
+ fourth: Fourth
1804
+ ): TypeValidator<
1805
+ | UnwrapTypeFromCoerceableOrValidator<First>
1806
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1807
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1808
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
1809
+ >;
1810
+ <
1811
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1812
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1813
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1814
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1815
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1816
+ >(
1817
+ first: First,
1818
+ second: Second,
1819
+ third: Third,
1820
+ fourth: Fourth,
1821
+ fifth: Fifth
1822
+ ): TypeValidator<
1823
+ | UnwrapTypeFromCoerceableOrValidator<First>
1824
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1825
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1826
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
1827
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
1828
+ >;
1829
+ <
1830
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1831
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1832
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1833
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1834
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1835
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1836
+ >(
1837
+ first: First,
1838
+ second: Second,
1839
+ third: Third,
1840
+ fourth: Fourth,
1841
+ fifth: Fifth,
1842
+ sixth: Sixth
1843
+ ): TypeValidator<
1844
+ | UnwrapTypeFromCoerceableOrValidator<First>
1845
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1846
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1847
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
1848
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
1849
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
1850
+ >;
1851
+ <
1852
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1853
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1854
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1855
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1856
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1857
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1858
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1859
+ >(
1860
+ first: First,
1861
+ second: Second,
1862
+ third: Third,
1863
+ fourth: Fourth,
1864
+ fifth: Fifth,
1865
+ sixth: Sixth,
1866
+ seventh: Seventh
1867
+ ): TypeValidator<
1868
+ | UnwrapTypeFromCoerceableOrValidator<First>
1869
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1870
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1871
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
1872
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
1873
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
1874
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
1875
+ >;
1876
+ <
1877
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1878
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1879
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1880
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1881
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1882
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1883
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1884
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1885
+ >(
1886
+ first: First,
1887
+ second: Second,
1888
+ third: Third,
1889
+ fourth: Fourth,
1890
+ fifth: Fifth,
1891
+ sixth: Sixth,
1892
+ seventh: Seventh,
1893
+ eighth: Eighth
1894
+ ): TypeValidator<
1895
+ | UnwrapTypeFromCoerceableOrValidator<First>
1896
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1897
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1898
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
1899
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
1900
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
1901
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
1902
+ | UnwrapTypeFromCoerceableOrValidator<Eighth>
1903
+ >;
1904
+ <
1905
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1906
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1907
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1908
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1909
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1910
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1911
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1912
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1913
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1914
+ >(
1915
+ first: First,
1916
+ second: Second,
1917
+ third: Third,
1918
+ fourth: Fourth,
1919
+ fifth: Fifth,
1920
+ sixth: Sixth,
1921
+ seventh: Seventh,
1922
+ eighth: Eighth,
1923
+ ninth: Ninth
1924
+ ): TypeValidator<
1925
+ | UnwrapTypeFromCoerceableOrValidator<First>
1926
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1927
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1928
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
1929
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
1930
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
1931
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
1932
+ | UnwrapTypeFromCoerceableOrValidator<Eighth>
1933
+ | UnwrapTypeFromCoerceableOrValidator<Ninth>
1934
+ >;
1935
+ <
1936
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1937
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1938
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1939
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1940
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1941
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1942
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1943
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1944
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1945
+ Tenth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1946
+ >(
1947
+ first: First,
1948
+ second: Second,
1949
+ third: Third,
1950
+ fourth: Fourth,
1951
+ fifth: Fifth,
1952
+ sixth: Sixth,
1953
+ seventh: Seventh,
1954
+ eighth: Eighth,
1955
+ ninth: Ninth,
1956
+ tenth: Tenth
1957
+ ): TypeValidator<
1958
+ | UnwrapTypeFromCoerceableOrValidator<First>
1959
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1960
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1961
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
1962
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
1963
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
1964
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
1965
+ | UnwrapTypeFromCoerceableOrValidator<Eighth>
1966
+ | UnwrapTypeFromCoerceableOrValidator<Ninth>
1967
+ | UnwrapTypeFromCoerceableOrValidator<Tenth>
1968
+ >;
1969
+ };
1970
+ or: {
1971
+ <
1972
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1973
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1974
+ >(
1975
+ first: First,
1976
+ second: Second
1977
+ ): TypeValidator<
1978
+ | UnwrapTypeFromCoerceableOrValidator<First>
1979
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1980
+ >;
1981
+ <
1982
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1983
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1984
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1985
+ >(
1986
+ first: First,
1987
+ second: Second,
1988
+ third: Third
1989
+ ): TypeValidator<
1990
+ | UnwrapTypeFromCoerceableOrValidator<First>
1991
+ | UnwrapTypeFromCoerceableOrValidator<Second>
1992
+ | UnwrapTypeFromCoerceableOrValidator<Third>
1993
+ >;
1994
+ <
1995
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1996
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1997
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
1998
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
1999
+ >(
2000
+ first: First,
2001
+ second: Second,
2002
+ third: Third,
2003
+ fourth: Fourth
2004
+ ): TypeValidator<
2005
+ | UnwrapTypeFromCoerceableOrValidator<First>
2006
+ | UnwrapTypeFromCoerceableOrValidator<Second>
2007
+ | UnwrapTypeFromCoerceableOrValidator<Third>
2008
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
2009
+ >;
2010
+ <
2011
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2012
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2013
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2014
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2015
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2016
+ >(
2017
+ first: First,
2018
+ second: Second,
2019
+ third: Third,
2020
+ fourth: Fourth,
2021
+ fifth: Fifth
2022
+ ): TypeValidator<
2023
+ | UnwrapTypeFromCoerceableOrValidator<First>
2024
+ | UnwrapTypeFromCoerceableOrValidator<Second>
2025
+ | UnwrapTypeFromCoerceableOrValidator<Third>
2026
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
2027
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
2028
+ >;
2029
+ <
2030
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2031
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2032
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2033
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2034
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2035
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2036
+ >(
2037
+ first: First,
2038
+ second: Second,
2039
+ third: Third,
2040
+ fourth: Fourth,
2041
+ fifth: Fifth,
2042
+ sixth: Sixth
2043
+ ): TypeValidator<
2044
+ | UnwrapTypeFromCoerceableOrValidator<First>
2045
+ | UnwrapTypeFromCoerceableOrValidator<Second>
2046
+ | UnwrapTypeFromCoerceableOrValidator<Third>
2047
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
2048
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
2049
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
2050
+ >;
2051
+ <
2052
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2053
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2054
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2055
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2056
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2057
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2058
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2059
+ >(
2060
+ first: First,
2061
+ second: Second,
2062
+ third: Third,
2063
+ fourth: Fourth,
2064
+ fifth: Fifth,
2065
+ sixth: Sixth,
2066
+ seventh: Seventh
2067
+ ): TypeValidator<
2068
+ | UnwrapTypeFromCoerceableOrValidator<First>
2069
+ | UnwrapTypeFromCoerceableOrValidator<Second>
2070
+ | UnwrapTypeFromCoerceableOrValidator<Third>
2071
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
2072
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
2073
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
2074
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
2075
+ >;
2076
+ <
2077
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2078
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2079
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2080
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2081
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2082
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2083
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2084
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2085
+ >(
2086
+ first: First,
2087
+ second: Second,
2088
+ third: Third,
2089
+ fourth: Fourth,
2090
+ fifth: Fifth,
2091
+ sixth: Sixth,
2092
+ seventh: Seventh,
2093
+ eighth: Eighth
2094
+ ): TypeValidator<
2095
+ | UnwrapTypeFromCoerceableOrValidator<First>
2096
+ | UnwrapTypeFromCoerceableOrValidator<Second>
2097
+ | UnwrapTypeFromCoerceableOrValidator<Third>
2098
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
2099
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
2100
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
2101
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
2102
+ | UnwrapTypeFromCoerceableOrValidator<Eighth>
2103
+ >;
2104
+ <
2105
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2106
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2107
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2108
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2109
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2110
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2111
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2112
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2113
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2114
+ >(
2115
+ first: First,
2116
+ second: Second,
2117
+ third: Third,
2118
+ fourth: Fourth,
2119
+ fifth: Fifth,
2120
+ sixth: Sixth,
2121
+ seventh: Seventh,
2122
+ eighth: Eighth,
2123
+ ninth: Ninth
2124
+ ): TypeValidator<
2125
+ | UnwrapTypeFromCoerceableOrValidator<First>
2126
+ | UnwrapTypeFromCoerceableOrValidator<Second>
2127
+ | UnwrapTypeFromCoerceableOrValidator<Third>
2128
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
2129
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
2130
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
2131
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
2132
+ | UnwrapTypeFromCoerceableOrValidator<Eighth>
2133
+ | UnwrapTypeFromCoerceableOrValidator<Ninth>
2134
+ >;
2135
+ <
2136
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2137
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2138
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2139
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2140
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2141
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2142
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2143
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2144
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2145
+ Tenth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2146
+ >(
2147
+ first: First,
2148
+ second: Second,
2149
+ third: Third,
2150
+ fourth: Fourth,
2151
+ fifth: Fifth,
2152
+ sixth: Sixth,
2153
+ seventh: Seventh,
2154
+ eighth: Eighth,
2155
+ ninth: Ninth,
2156
+ tenth: Tenth
2157
+ ): TypeValidator<
2158
+ | UnwrapTypeFromCoerceableOrValidator<First>
2159
+ | UnwrapTypeFromCoerceableOrValidator<Second>
2160
+ | UnwrapTypeFromCoerceableOrValidator<Third>
2161
+ | UnwrapTypeFromCoerceableOrValidator<Fourth>
2162
+ | UnwrapTypeFromCoerceableOrValidator<Fifth>
2163
+ | UnwrapTypeFromCoerceableOrValidator<Sixth>
2164
+ | UnwrapTypeFromCoerceableOrValidator<Seventh>
2165
+ | UnwrapTypeFromCoerceableOrValidator<Eighth>
2166
+ | UnwrapTypeFromCoerceableOrValidator<Ninth>
2167
+ | UnwrapTypeFromCoerceableOrValidator<Tenth>
2168
+ >;
2169
+ };
2170
+ mapOf<
2171
+ K extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2172
+ V extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2173
+ >(
2174
+ keyType: K,
2175
+ valueType: V
2176
+ ): TypeValidator<
2177
+ Map<
2178
+ UnwrapTypeFromCoerceableOrValidator<K>,
2179
+ UnwrapTypeFromCoerceableOrValidator<V>
2180
+ >
2181
+ >;
2182
+ setOf<T extends TypeValidator<any> | CoerceableToTypeValidator | unknown>(
2183
+ itemType: T
2184
+ ): TypeValidator<Set<UnwrapTypeFromCoerceableOrValidator<T>>>;
2185
+ maybe<T extends TypeValidator<any> | CoerceableToTypeValidator | unknown>(
2186
+ itemType: T
2187
+ ): TypeValidator<UnwrapTypeFromCoerceableOrValidator<T> | undefined | null>;
2188
+ objectWithProperties<
2189
+ T extends {
2190
+ [key: string | number | symbol]:
2191
+ | TypeValidator<any>
2192
+ | CoerceableToTypeValidator
2193
+ | unknown;
2194
+ }
2195
+ >(
2196
+ properties: T
2197
+ ): TypeValidator<{
2198
+ [key in keyof T]: UnwrapTypeFromCoerceableOrValidator<T[key]>;
2199
+ }>;
2200
+ objectWithOnlyTheseProperties<
2201
+ T extends {
2202
+ [key: string | number | symbol]:
2203
+ | TypeValidator<any>
2204
+ | CoerceableToTypeValidator
2205
+ | unknown;
2206
+ }
2207
+ >(
2208
+ properties: T
2209
+ ): TypeValidator<{
2210
+ [key in keyof T]: UnwrapTypeFromCoerceableOrValidator<T[key]>;
2211
+ }>;
2212
+
2213
+ mappingObjectOf<
2214
+ Values extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2215
+ Keys extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2216
+ >(
2217
+ keyType: Keys,
2218
+ valueType: Values
2219
+ ): TypeValidator<
2220
+ Record<
2221
+ UnwrapTypeFromCoerceableOrValidator<Keys> extends string | number | symbol
2222
+ ? UnwrapTypeFromCoerceableOrValidator<Keys>
2223
+ : never,
2224
+ UnwrapTypeFromCoerceableOrValidator<Values>
2225
+ >
2226
+ >;
2227
+ record<
2228
+ Values extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2229
+ Keys extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2230
+ >(
2231
+ keyType: Keys,
2232
+ valueType: Values
2233
+ ): TypeValidator<
2234
+ Record<
2235
+ UnwrapTypeFromCoerceableOrValidator<Keys> extends string | number | symbol
2236
+ ? UnwrapTypeFromCoerceableOrValidator<Keys>
2237
+ : never,
2238
+ UnwrapTypeFromCoerceableOrValidator<Values>
2239
+ >
2240
+ >;
2241
+ partialObjectWithProperties<
2242
+ T extends {
2243
+ [key: string | number | symbol]:
2244
+ | TypeValidator<any>
2245
+ | CoerceableToTypeValidator
2246
+ | unknown;
2247
+ }
2248
+ >(
2249
+ properties: T
2250
+ ): TypeValidator<{
2251
+ [key in keyof T]:
2252
+ | UnwrapTypeFromCoerceableOrValidator<T[key]>
2253
+ | null
2254
+ | undefined;
2255
+ }>;
2256
+ tuple: {
2257
+ <
2258
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2259
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2260
+ >(
2261
+ first: First,
2262
+ second: Second
2263
+ ): TypeValidator<
2264
+ [
2265
+ UnwrapTypeFromCoerceableOrValidator<First>,
2266
+ UnwrapTypeFromCoerceableOrValidator<Second>
2267
+ ]
2268
+ >;
2269
+ <
2270
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2271
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2272
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2273
+ >(
2274
+ first: First,
2275
+ second: Second,
2276
+ third: Third
2277
+ ): TypeValidator<
2278
+ [
2279
+ UnwrapTypeFromCoerceableOrValidator<First>,
2280
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2281
+ UnwrapTypeFromCoerceableOrValidator<Third>
2282
+ ]
2283
+ >;
2284
+ <
2285
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2286
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2287
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2288
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2289
+ >(
2290
+ first: First,
2291
+ second: Second,
2292
+ third: Third,
2293
+ fourth: Fourth
2294
+ ): TypeValidator<
2295
+ [
2296
+ UnwrapTypeFromCoerceableOrValidator<First>,
2297
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2298
+ UnwrapTypeFromCoerceableOrValidator<Third>,
2299
+ UnwrapTypeFromCoerceableOrValidator<Fourth>
2300
+ ]
2301
+ >;
2302
+ <
2303
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2304
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2305
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2306
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2307
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2308
+ >(
2309
+ first: First,
2310
+ second: Second,
2311
+ third: Third,
2312
+ fourth: Fourth,
2313
+ fifth: Fifth
2314
+ ): TypeValidator<
2315
+ [
2316
+ UnwrapTypeFromCoerceableOrValidator<First>,
2317
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2318
+ UnwrapTypeFromCoerceableOrValidator<Third>,
2319
+ UnwrapTypeFromCoerceableOrValidator<Fourth>,
2320
+ UnwrapTypeFromCoerceableOrValidator<Fifth>
2321
+ ]
2322
+ >;
2323
+ <
2324
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2325
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2326
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2327
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2328
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2329
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2330
+ >(
2331
+ first: First,
2332
+ second: Second,
2333
+ third: Third,
2334
+ fourth: Fourth,
2335
+ fifth: Fifth,
2336
+ sixth: Sixth
2337
+ ): TypeValidator<
2338
+ [
2339
+ UnwrapTypeFromCoerceableOrValidator<First>,
2340
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2341
+ UnwrapTypeFromCoerceableOrValidator<Third>,
2342
+ UnwrapTypeFromCoerceableOrValidator<Fourth>,
2343
+ UnwrapTypeFromCoerceableOrValidator<Fifth>,
2344
+ UnwrapTypeFromCoerceableOrValidator<Sixth>
2345
+ ]
2346
+ >;
2347
+ <
2348
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2349
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2350
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2351
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2352
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2353
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2354
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2355
+ >(
2356
+ first: First,
2357
+ second: Second,
2358
+ third: Third,
2359
+ fourth: Fourth,
2360
+ fifth: Fifth,
2361
+ sixth: Sixth,
2362
+ seventh: Seventh
2363
+ ): TypeValidator<
2364
+ [
2365
+ UnwrapTypeFromCoerceableOrValidator<First>,
2366
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2367
+ UnwrapTypeFromCoerceableOrValidator<Third>,
2368
+ UnwrapTypeFromCoerceableOrValidator<Fourth>,
2369
+ UnwrapTypeFromCoerceableOrValidator<Fifth>,
2370
+ UnwrapTypeFromCoerceableOrValidator<Sixth>,
2371
+ UnwrapTypeFromCoerceableOrValidator<Seventh>
2372
+ ]
2373
+ >;
2374
+ <
2375
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2376
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2377
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2378
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2379
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2380
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2381
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2382
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2383
+ >(
2384
+ first: First,
2385
+ second: Second,
2386
+ third: Third,
2387
+ fourth: Fourth,
2388
+ fifth: Fifth,
2389
+ sixth: Sixth,
2390
+ seventh: Seventh,
2391
+ eighth: Eighth
2392
+ ): TypeValidator<
2393
+ [
2394
+ UnwrapTypeFromCoerceableOrValidator<First>,
2395
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2396
+ UnwrapTypeFromCoerceableOrValidator<Third>,
2397
+ UnwrapTypeFromCoerceableOrValidator<Fourth>,
2398
+ UnwrapTypeFromCoerceableOrValidator<Fifth>,
2399
+ UnwrapTypeFromCoerceableOrValidator<Sixth>,
2400
+ UnwrapTypeFromCoerceableOrValidator<Seventh>,
2401
+ UnwrapTypeFromCoerceableOrValidator<Eighth>
2402
+ ]
2403
+ >;
2404
+ <
2405
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2406
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2407
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2408
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2409
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2410
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2411
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2412
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2413
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2414
+ >(
2415
+ first: First,
2416
+ second: Second,
2417
+ third: Third,
2418
+ fourth: Fourth,
2419
+ fifth: Fifth,
2420
+ sixth: Sixth,
2421
+ seventh: Seventh,
2422
+ eighth: Eighth,
2423
+ ninth: Ninth
2424
+ ): TypeValidator<
2425
+ [
2426
+ UnwrapTypeFromCoerceableOrValidator<First>,
2427
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2428
+ UnwrapTypeFromCoerceableOrValidator<Third>,
2429
+ UnwrapTypeFromCoerceableOrValidator<Fourth>,
2430
+ UnwrapTypeFromCoerceableOrValidator<Fifth>,
2431
+ UnwrapTypeFromCoerceableOrValidator<Sixth>,
2432
+ UnwrapTypeFromCoerceableOrValidator<Seventh>,
2433
+ UnwrapTypeFromCoerceableOrValidator<Eighth>,
2434
+ UnwrapTypeFromCoerceableOrValidator<Ninth>
2435
+ ]
2436
+ >;
2437
+ <
2438
+ First extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2439
+ Second extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2440
+ Third extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2441
+ Fourth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2442
+ Fifth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2443
+ Sixth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2444
+ Seventh extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2445
+ Eighth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2446
+ Ninth extends TypeValidator<any> | CoerceableToTypeValidator | unknown,
2447
+ Tenth extends TypeValidator<any> | CoerceableToTypeValidator | unknown
2448
+ >(
2449
+ first: First,
2450
+ second: Second,
2451
+ third: Third,
2452
+ fourth: Fourth,
2453
+ fifth: Fifth,
2454
+ sixth: Sixth,
2455
+ seventh: Seventh,
2456
+ eighth: Eighth,
2457
+ ninth: Ninth,
2458
+ tenth: Tenth
2459
+ ): TypeValidator<
2460
+ [
2461
+ UnwrapTypeFromCoerceableOrValidator<First>,
2462
+ UnwrapTypeFromCoerceableOrValidator<Second>,
2463
+ UnwrapTypeFromCoerceableOrValidator<Third>,
2464
+ UnwrapTypeFromCoerceableOrValidator<Fourth>,
2465
+ UnwrapTypeFromCoerceableOrValidator<Fifth>,
2466
+ UnwrapTypeFromCoerceableOrValidator<Sixth>,
2467
+ UnwrapTypeFromCoerceableOrValidator<Seventh>,
2468
+ UnwrapTypeFromCoerceableOrValidator<Eighth>,
2469
+ UnwrapTypeFromCoerceableOrValidator<Ninth>,
2470
+ UnwrapTypeFromCoerceableOrValidator<Tenth>
2471
+ ]
2472
+ >;
2473
+ };
2474
+
2475
+ coerce: <V extends CoerceableToTypeValidator | TypeValidator<any> | unknown>(
2476
+ value: V
2477
+ ) => TypeValidator<UnwrapTypeFromCoerceableOrValidator<V>>;
978
2478
 
2479
+ FILE: TypeValidator<FILE>;
2480
+ Module: TypeValidator<{ [key: string]: unknown }>;
2481
+ Path: TypeValidator<Path>;
979
2482
  JSX: {
980
- /** Returns whether `value` is a JSX Element object as created via JSX syntax. */
981
- Element(value: any): value is JSX.Element;
982
- /** Returns whether `value` is a JSX fragment element as created via JSX syntax. */
983
- Fragment(value: any): value is JSX.Fragment;
2483
+ unknownElement: TypeValidator<
2484
+ JSX.Element<{ [key: string | symbol | number]: unknown }, unknown>
2485
+ >;
2486
+ anyElement: TypeValidator<JSX.Element<any, any>>;
2487
+ Element: TypeValidator<
2488
+ JSX.Element<{ [key: string | symbol | number]: unknown }, unknown>
2489
+ >;
2490
+ Fragment: TypeValidator<JSX.Fragment>;
984
2491
  };
985
2492
  };
986
2493
 
2494
+ declare const is: <T extends TypeValidator<any> | CoerceableToTypeValidator>(
2495
+ value: any,
2496
+ type: T
2497
+ ) => value is UnwrapTypeFromCoerceableOrValidator<T>;
2498
+
987
2499
  declare const assert: {
988
2500
  /**
989
2501
  * Throws an error if `value` is not truthy.
@@ -998,116 +2510,16 @@ declare const assert: {
998
2510
  ? never
999
2511
  : ValueType;
1000
2512
 
1001
- string(value: any, message?: string): asserts value is string;
1002
- String(value: any, message?: string): asserts value is string;
1003
- number(value: any, message?: string): asserts value is number;
1004
- Number(value: any, message?: string): asserts value is number;
1005
- boolean(value: any, message?: string): asserts value is boolean;
1006
- Boolean(value: any, message?: string): asserts value is boolean;
1007
- bigint(value: any, message?: string): asserts value is bigint;
1008
- BigInt(value: any, message?: string): asserts value is bigint;
1009
- symbol(value: any, message?: string): asserts value is symbol;
1010
- Symbol(value: any, message?: string): asserts value is symbol;
1011
- null(value: any, message?: string): asserts value is null;
1012
- undefined(value: any, message?: string): asserts value is undefined;
1013
- void(value: any, message?: string): asserts value is null | undefined;
1014
- object(
1015
- value: any,
1016
- message?: string
1017
- ): asserts value is {
1018
- [key: string]: unknown;
1019
- [key: number]: unknown;
1020
- [key: symbol]: unknown;
1021
- };
1022
- Object(
1023
- value: any,
1024
- message?: string
1025
- ): asserts value is {
1026
- [key: string]: unknown;
1027
- [key: number]: unknown;
1028
- [key: symbol]: unknown;
1029
- };
1030
- Array(value: any, message?: string): asserts value is unknown[];
1031
- function(
1032
- value: any,
1033
- message?: string
1034
- ): asserts value is Function & {
1035
- [key: string]: unknown;
1036
- [key: number]: unknown;
1037
- [key: symbol]: unknown;
1038
- };
1039
- Function(
1040
- value: any,
1041
- message?: string
1042
- ): asserts value is Function & {
1043
- [key: string]: unknown;
1044
- [key: number]: unknown;
1045
- [key: symbol]: unknown;
1046
- };
1047
- tagged(value: any, tag: string, message?: string): void;
1048
- instanceOf<T>(value: any, klass: new (...args: any) => T): asserts value is T;
1049
- Error(value: any, message?: string): asserts value is Error;
1050
- Infinity(value: any, message?: string): asserts value is number;
1051
- NegativeInfinity(value: any, message?: string): asserts value is number;
1052
- NaN(value: any, message?: string): asserts value is number;
1053
- Date(value: any, message?: string): asserts value is Date;
1054
- RegExp(value: any, message?: string): asserts value is RegExp;
1055
- Map(value: any, message?: string): asserts value is Map<unknown, unknown>;
1056
- Set(value: any, message?: string): asserts value is Set<unknown>;
1057
- WeakMap(value: any, message?: string): asserts value is Map<unknown, unknown>;
1058
- WeakSet(value: any, message?: string): asserts value is Set<unknown>;
1059
- ArrayBuffer(value: any, message?: string): asserts value is ArrayBuffer;
1060
- SharedArrayBuffer(
1061
- value: any,
1062
- message?: string
1063
- ): asserts value is SharedArrayBuffer;
1064
- DataView(value: any, message?: string): asserts value is DataView;
1065
- TypedArray(value: any, message?: string): asserts value is TypedArray;
1066
- Int8Array(value: any, message?: string): asserts value is Int8Array;
1067
- Uint8Array(value: any, message?: string): asserts value is Uint8Array;
1068
- Uint8ClampedArray(
1069
- value: any,
1070
- message?: string
1071
- ): asserts value is Uint8ClampedArray;
1072
- Int16Array(value: any, message?: string): asserts value is Int16Array;
1073
- Uint16Array(value: any, message?: string): asserts value is Uint16Array;
1074
- Int32Array(value: any, message?: string): asserts value is Int32Array;
1075
- Uint32Array(value: any, message?: string): asserts value is Uint32Array;
1076
- Float32Array(value: any, message?: string): asserts value is Float32Array;
1077
- Float64Array(value: any, message?: string): asserts value is Float64Array;
1078
- Promise(value: any, message?: string): asserts value is Promise<unknown>;
1079
- Generator(
1080
- value: any,
1081
- message?: string
1082
- ): asserts value is Generator<unknown, any, unknown>;
1083
- GeneratorFunction(
1084
- value: any,
1085
- message?: string
1086
- ): asserts value is GeneratorFunction;
1087
- AsyncFunction(
1088
- value: any,
1089
- message?: string
1090
- ): asserts value is ((...args: any) => Promise<unknown>) & {
1091
- [key: string]: unknown;
1092
- [key: number]: unknown;
1093
- [key: symbol]: unknown;
1094
- };
1095
- AsyncGenerator(
1096
- value: any
1097
- ): asserts value is AsyncGenerator<unknown, any, unknown>;
1098
- AsyncGeneratorFunction(
2513
+ /**
2514
+ * Throws an error if `value` is not of the type `type`.
2515
+ *
2516
+ * `type` should be either a {@link TypeValidator}, or a value which can be coerced into one via {@link types.coerce}.
2517
+ */
2518
+ type: <T extends TypeValidator<any> | CoerceableToTypeValidator>(
1099
2519
  value: any,
1100
- message?: string
1101
- ): asserts value is AsyncGeneratorFunction;
1102
-
1103
- FILE(value: any, message?: string): asserts value is FILE;
1104
-
1105
- JSX: {
1106
- /** Returns whether `value` is a JSX Element object as created via JSX syntax. */
1107
- Element(value: any, message?: string): asserts value is JSX.Element;
1108
- /** Returns whether `value` is a JSX fragment element as created via JSX syntax. */
1109
- Fragment(value: any, message?: string): asserts value is JSX.Fragment;
1110
- };
2520
+ type: T,
2521
+ optionalMessage?: string
2522
+ ) => asserts value is UnwrapTypeFromCoerceableOrValidator<T>;
1111
2523
  };
1112
2524
 
1113
2525
  /**
@@ -1117,7 +2529,7 @@ declare const assert: {
1117
2529
  * - Use `maxLength` to limit how much data to read.
1118
2530
  * - Use `until` to stop reading once a certain byte or character has been
1119
2531
  * read.
1120
- * - Use `path` or `fd` to open a file.
2532
+ * - Use `path` or `fd` to open a file (or pass a FILE or Path object).
1121
2533
  */
1122
2534
  declare type PipeSource =
1123
2535
  | { data: string; maxLength?: number; until?: string | byte }
@@ -1130,12 +2542,9 @@ declare type PipeSource =
1130
2542
  | DataView
1131
2543
  | { data: DataView; maxLength?: number; until?: string | byte }
1132
2544
  | FILE
1133
- | {
1134
- data: FILE;
1135
- maxLength?: number;
1136
- until?: string | byte;
1137
- }
1138
- | { path: string; maxLength?: number; until?: string | byte }
2545
+ | { data: FILE; maxLength?: number; until?: string | byte }
2546
+ | Path
2547
+ | { path: Path | string; maxLength?: number; until?: string | byte }
1139
2548
  | { fd: number; maxLength?: number; until?: string | byte };
1140
2549
 
1141
2550
  /**
@@ -1151,6 +2560,7 @@ declare type PipeDestination =
1151
2560
  | SharedArrayBuffer
1152
2561
  | DataView
1153
2562
  | TypedArray
2563
+ | Path
1154
2564
  | FILE
1155
2565
  | ArrayBufferConstructor
1156
2566
  | SharedArrayBufferConstructor
@@ -1189,39 +2599,133 @@ declare function pipe<Dest extends PipeDestination>(
1189
2599
  : never;
1190
2600
  };
1191
2601
 
2602
+ interface InteractivePrompt {
2603
+ prompt?: () => string;
2604
+ printInput?: (input: string) => void;
2605
+ historyFileName?: string;
2606
+ getCompletions?: (
2607
+ line: string,
2608
+ pos: number
2609
+ ) => {
2610
+ // TODO refactor these to have better key names
2611
+ tab: Array<string>;
2612
+ pos: number;
2613
+ ctx: { [key: string | number | symbol]: any };
2614
+ };
2615
+
2616
+ handleInput: (input: string) => void;
2617
+ start(): void;
2618
+ }
2619
+
2620
+ interface InteractivePromptConstructor {
2621
+ new (
2622
+ handleInput: (input: string) => void,
2623
+ options?: {
2624
+ prompt?: () => string;
2625
+ printInput?: (input: string) => void;
2626
+ historyFileName?: string;
2627
+ getCompletions?: (
2628
+ line: string,
2629
+ pos: number
2630
+ ) => {
2631
+ // TODO refactor these to have better key names
2632
+ tab: Array<string>;
2633
+ pos: number;
2634
+ ctx: { [key: string | number | symbol]: any };
2635
+ };
2636
+ }
2637
+ ): InteractivePrompt;
2638
+
2639
+ prototype: InteractivePrompt;
2640
+ }
2641
+
2642
+ /** wip experimental use at your own risk */
2643
+ declare var InteractivePrompt: InteractivePromptConstructor;
2644
+
1192
2645
  /**
1193
2646
  * Launch the Yavascript REPL (read-eval-print-loop).
1194
2647
  *
1195
2648
  * @param context Variables to make available as globals within the repl.
1196
2649
  * @param lang The langauge to use in the repl. Defaults to "javascript".
1197
2650
  */
1198
- declare function startRepl(
1199
- context?: { [key: string]: any },
1200
- lang?:
1201
- | "js"
1202
- | "javascript"
1203
- | "ts"
1204
- | "typescript"
1205
- | "jsx"
1206
- | "tsx"
1207
- | "coffee"
1208
- | "coffeescript"
1209
- ): void;
2651
+ declare const startRepl: {
2652
+ (
2653
+ context?: { [key: string]: any },
2654
+ lang?:
2655
+ | "js"
2656
+ | "javascript"
2657
+ | "ts"
2658
+ | "typescript"
2659
+ | "jsx"
2660
+ | "tsx"
2661
+ | "coffee"
2662
+ | "coffeescript"
2663
+ ): void;
1210
2664
 
1211
- /**
1212
- * Returns the absolute path to the root folder of the git/hg repo.
1213
- *
1214
- * This is done by running `git rev-parse --show-toplevel` and `hg root`.
1215
- *
1216
- * If `relativeTo` is provided, the git and hg commands will be executed in
1217
- * that folder instead of in `pwd()`.
1218
- */
1219
- declare function repoRoot(relativeTo?: string): string;
2665
+ /**
2666
+ * A special value; when expressions result in this value, the repl will
2667
+ * print nothing instead of printing this value.
2668
+ */
2669
+ NOTHING: symbol;
2670
+ };
1220
2671
 
1221
2672
  /**
1222
- * Returns whether the provided path is ignored by git.
2673
+ * An object that points to a git repository on disk and provides utility
2674
+ * methods for getting information from that repo.
1223
2675
  */
1224
- declare function isGitignored(path: string): boolean;
2676
+ declare class GitRepo {
2677
+ /**
2678
+ * Given a path to a file or folder on disk, finds the parent git repo
2679
+ * containing that path, and returns the absolute path to the repo root (the
2680
+ * folder that contains the '.git' folder).
2681
+ *
2682
+ * This is done by running `git rev-parse --show-toplevel`.
2683
+ */
2684
+ static findRoot(fromPath: string | Path): Path;
2685
+
2686
+ /**
2687
+ * Creates a new `Git` object for the given repo on disk.
2688
+ */
2689
+ constructor(repoDir: string | Path);
2690
+
2691
+ /**
2692
+ * The root folder of the git repo that this `Git` object represents (the
2693
+ * folder that contains the '.git' folder).
2694
+ */
2695
+ repoDir: Path;
2696
+
2697
+ /**
2698
+ * Returns the commit SHA the git repo is currently pointed at.
2699
+ *
2700
+ * This is done by running `git rev-parse HEAD`.
2701
+ */
2702
+ commitSHA(): string;
2703
+
2704
+ /**
2705
+ * If the commit SHA the git repo is currently pointed at is the tip of a
2706
+ * named branch, returns the branch name. Otherwise, returns `null`.
2707
+ *
2708
+ * This is done by running `git rev-parse --abbrev-ref HEAD`.
2709
+ */
2710
+ branchName(): string | null;
2711
+
2712
+ /**
2713
+ * Returns a boolean indicating whether there are uncommited changes in the
2714
+ * git repo. `true` means there are changes, `false` means there are no
2715
+ * changes (ie. the repo is clean).
2716
+ *
2717
+ * This is done by running `git status --quiet`.
2718
+ */
2719
+ isWorkingTreeDirty(): boolean;
2720
+
2721
+ /**
2722
+ * Returns whether the provided path is ignored by git.
2723
+ *
2724
+ * If `path` is an absolute path, it must be a child directory of this Git
2725
+ * object's `repoDir`, or else an error will be thrown.
2726
+ */
2727
+ isIgnored(path: string | Path): boolean;
2728
+ }
1225
2729
 
1226
2730
  /**
1227
2731
  * Configures the default value of `trace` in functions which receive `trace`
@@ -1256,10 +2760,10 @@ declare namespace JSX {
1256
2760
  * expression.
1257
2761
  *
1258
2762
  * Note that if you change this, you need to verify that the following
1259
- * expression always evaluates to `true` (by changing {@link is.JSX.Element}
1260
- * and {@link is.JSX.Fragment}):
2763
+ * expression always evaluates to `true` (by changing {@link types.JSX.Element}
2764
+ * and {@link types.JSX.Fragment}):
1261
2765
  * ```jsx
1262
- * is.JSX.Element(<a />) && is.JSX.Fragment(<></>)
2766
+ * types.JSX.Element(<a />) && types.JSX.Fragment(<></>)
1263
2767
  * ```
1264
2768
  *
1265
2769
  * Failure to uphold this guarantee indicates a bug.
@@ -1276,10 +2780,10 @@ declare namespace JSX {
1276
2780
  * expression.
1277
2781
  *
1278
2782
  * Note that if you change this, you need to verify that the following
1279
- * expression always evaluates to `true` (by changing {@link is.JSX.Element}
1280
- * and {@link is.JSX.Fragment}):
2783
+ * expression always evaluates to `true` (by changing {@link types.JSX.Element}
2784
+ * and {@link types.JSX.Fragment}):
1281
2785
  * ```jsx
1282
- * is.JSX.Element(<a />) && is.JSX.Fragment(<></>)
2786
+ * types.JSX.Element(<a />) && types.JSX.Fragment(<></>)
1283
2787
  * ```
1284
2788
  *
1285
2789
  * Failure to uphold this guarantee indicates a bug.
@@ -1408,18 +2912,899 @@ declare type byte =
1408
2912
  | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239
1409
2913
  | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255;
1410
2914
 
1411
- // Convenience aliases to provide parity with TypeScript types.
1412
- declare var number: NumberConstructor;
1413
- declare var string: StringConstructor;
1414
- declare var boolean: BooleanConstructor;
1415
- declare var bigint: BigIntConstructor;
1416
- declare var symbol: SymbolConstructor;
2915
+ // Convenience aliases to provide parity with TypeScript types.
2916
+ declare var number: NumberConstructor;
2917
+ declare var string: StringConstructor;
2918
+ declare var boolean: BooleanConstructor;
2919
+ declare var bigint: BigIntConstructor;
2920
+ declare var symbol: SymbolConstructor;
2921
+
2922
+ declare type TypedArray =
2923
+ | Int8Array
2924
+ | Uint8Array
2925
+ | Uint8ClampedArray
2926
+ | Int16Array
2927
+ | Uint16Array
2928
+ | Int32Array
2929
+ | Uint32Array
2930
+ | Float32Array
2931
+ | Float64Array;
2932
+ declare type TypedArrayConstructor =
2933
+ | Int8ArrayConstructor
2934
+ | Uint8ArrayConstructor
2935
+ | Uint8ClampedArrayConstructor
2936
+ | Int16ArrayConstructor
2937
+ | Uint16ArrayConstructor
2938
+ | Int32ArrayConstructor
2939
+ | Uint32ArrayConstructor
2940
+ | Float32ArrayConstructor
2941
+ | Float64ArrayConstructor;
2942
+
2943
+ // ==========================================
2944
+ // ------------------------------------------
2945
+ // QuickJS APIs, which YavaScript builds upon
2946
+ // ------------------------------------------
2947
+ // ==========================================
2948
+ interface ObjectConstructor {
2949
+ /**
2950
+ * Convert the specified value to a primitive value.
2951
+ *
2952
+ * The provided hint indicates a preferred return type, which may or may not
2953
+ * be respected by the engine.
2954
+ *
2955
+ * See the abstract operation "ToPrimitive" in the ECMAScript standard for
2956
+ * more info.
2957
+ */
2958
+ toPrimitive(
2959
+ input: any,
2960
+ hint: "string" | "number" | "default"
2961
+ ): string | number | bigint | boolean | undefined | symbol | null;
2962
+
2963
+ /**
2964
+ * Returns a boolean indicating whether the specified value is a primitive value.
2965
+ */
2966
+ isPrimitive(input: any): boolean;
2967
+ }
2968
+
2969
+ interface SymbolConstructor {
2970
+ /**
2971
+ * A method that changes the result of using the `typeof` operator on the
2972
+ * object. Called by the semantics of the typeof operator.
2973
+ *
2974
+ * Note that the following semantics will come into play when use of the
2975
+ * `typeof` operator causes the engine to call a `Symbol.typeofValue` method
2976
+ * on an object:
2977
+ *
2978
+ * - If the method returns any value other than one of the string values
2979
+ * which are normally the result of using the `typeof` operator, the engine
2980
+ * behaves as if no `Symbol.typeofValue` method was present on the object.
2981
+ * - If an error is thrown from this method, or an error is thrown while
2982
+ * accessing this property, the error will be silently ignored, and the
2983
+ * engine will behave as if no `Symbol.typeofValue` method was present on
2984
+ * the object.
2985
+ * - If this property is present on an object, but the value of that property
2986
+ * is not a function, the engine will not consider that value when
2987
+ * determining the result of the `typeof` operation (it'll ignore it).
2988
+ */
2989
+ readonly typeofValue: unique symbol;
2990
+
2991
+ /**
2992
+ * To override operators (+, -, ==, etc) for an object, set its
2993
+ * `Symbol.operatorSet` property to an `OperatorSet` object, which can be
2994
+ * created via `Operators.create`.
2995
+ */
2996
+ readonly operatorSet: unique symbol;
2997
+ }
2998
+
2999
+ /**
3000
+ * An object that, if placed on another object's `Symbol.operatorSet` property,
3001
+ * will overload its operators to behave as defined by the functions this
3002
+ * OperatorSet was constructed with.
3003
+ *
3004
+ * You can create an OperatorSet via `Operators(...)` or
3005
+ * `Operators.create(...)`.
3006
+ */
3007
+ declare type OperatorSet = {
3008
+ /**
3009
+ * This property is not here at runtime; we just use it to make this type
3010
+ * differ from an empty object.
3011
+ */
3012
+ __is__: "OperatorSet";
3013
+ };
3014
+
3015
+ interface OperatorFunctions<Left, Right> {
3016
+ "+": (left: Left, right: Right) => any;
3017
+ "-": (left: Left, right: Right) => any;
3018
+ "*": (left: Left, right: Right) => any;
3019
+ "/": (left: Left, right: Right) => any;
3020
+ "%": (left: Left, right: Right) => any;
3021
+ "**": (left: Left, right: Right) => any;
3022
+ "|": (left: Left, right: Right) => any;
3023
+ "&": (left: Left, right: Right) => any;
3024
+ "^": (left: Left, right: Right) => any;
3025
+ "<<": (left: Left, right: Right) => any;
3026
+ ">>": (left: Left, right: Right) => any;
3027
+ ">>>": (left: Left, right: Right) => any;
3028
+ "==": (left: Left, right: Right) => any;
3029
+ "<": (left: Left, right: Right) => any;
3030
+ pos: (left: Left, right: Right) => any;
3031
+ neg: (left: Left, right: Right) => any;
3032
+ "++": (left: Left, right: Right) => any;
3033
+ "--": (left: Left, right: Right) => any;
3034
+ "~": (left: Left, right: Right) => any;
3035
+ }
3036
+
3037
+ interface SelfOperators<T> extends Partial<OperatorFunctions<T, T>> {
3038
+ left?: undefined;
3039
+ right?: undefined;
3040
+ }
3041
+
3042
+ interface LeftOperators<T, Left> extends Partial<OperatorFunctions<Left, T>> {
3043
+ left: {};
3044
+ right?: undefined;
3045
+ }
3046
+
3047
+ interface RightOperators<T, Right>
3048
+ extends Partial<OperatorFunctions<T, Right>> {
3049
+ left?: undefined;
3050
+ right: {};
3051
+ }
3052
+
3053
+ interface OperatorsConstructor {
3054
+ /**
3055
+ * Creates a new OperatorSet object, which should be placed on an object's
3056
+ * Symbol.operatorSet property.
3057
+ */
3058
+ <T>(
3059
+ selfOperators?: SelfOperators<T>,
3060
+ ...otherOperators: Array<LeftOperators<T, any> | RightOperators<T, any>>
3061
+ ): OperatorSet;
3062
+
3063
+ /**
3064
+ * Creates a new OperatorSet object, which should be placed on an object's
3065
+ * Symbol.operatorSet property.
3066
+ */
3067
+ create: <T>(
3068
+ selfOperators?: SelfOperators<T>,
3069
+ ...otherOperators: Array<LeftOperators<T, any> | RightOperators<T, any>>
3070
+ ) => OperatorSet;
3071
+
3072
+ /**
3073
+ * In math mode, the BigInt division and power operators can be overloaded by
3074
+ * using this function.
3075
+ */
3076
+ updateBigIntOperators(
3077
+ ops: Pick<OperatorFunctions<BigInt, BigInt>, "/" | "**">
3078
+ ): void;
3079
+ }
3080
+
3081
+ declare var Operators: OperatorsConstructor;
3082
+
3083
+ interface Number {
3084
+ [Symbol.operatorSet]: OperatorSet;
3085
+ }
3086
+
3087
+ interface Boolean {
3088
+ [Symbol.operatorSet]: OperatorSet;
3089
+ }
3090
+
3091
+ interface String {
3092
+ [Symbol.operatorSet]: OperatorSet;
3093
+ }
3094
+
3095
+ interface BigInt {
3096
+ [Symbol.operatorSet]: OperatorSet;
3097
+ }
3098
+
3099
+ interface BigIntConstructor {
3100
+ /**
3101
+ * Return trunc(a/b).
3102
+ *
3103
+ * b = 0 raises a RangeError exception.
3104
+ */
3105
+ tdiv(a: bigint, b: bigint): bigint;
3106
+
3107
+ /**
3108
+ * Return \lfloor a/b \rfloor.
3109
+ *
3110
+ * b = 0 raises a RangeError exception.
3111
+ */
3112
+ fdiv(a: bigint, b: bigint): bigint;
3113
+
3114
+ /**
3115
+ * Return \lceil a/b \rceil.
3116
+ *
3117
+ * b = 0 raises a RangeError exception.
3118
+ */
3119
+ cdiv(a: bigint, b: bigint): bigint;
3120
+
3121
+ /**
3122
+ * Return sgn(b) \lfloor a/{|b|} \rfloor (Euclidian division).
3123
+ *
3124
+ * b = 0 raises a RangeError exception.
3125
+ */
3126
+ ediv(a: bigint, b: bigint): bigint;
3127
+
3128
+ /**
3129
+ * Perform trunc(a/b) and return an array of two elements. The first element
3130
+ * is the quotient, the second is the remainder.
3131
+ *
3132
+ * b = 0 raises a RangeError exception.
3133
+ */
3134
+ tdivrem(a: bigint, b: bigint): [bigint, bigint];
3135
+
3136
+ /**
3137
+ * Perform \lfloor a/b \rfloor and return an array of two elements. The first
3138
+ * element is the quotient, the second is the remainder.
3139
+ *
3140
+ * b = 0 raises a RangeError exception.
3141
+ */
3142
+ fdivrem(a: bigint, b: bigint): [bigint, bigint];
3143
+
3144
+ /**
3145
+ * Perform \lceil a/b \rceil and return an array of two elements. The first
3146
+ * element is the quotient, the second is the remainder.
3147
+ *
3148
+ * b = 0 raises a RangeError exception.
3149
+ */
3150
+ cdivrem(a: bigint, b: bigint): [bigint, bigint];
3151
+
3152
+ /**
3153
+ * Perform sgn(b) \lfloor a/{|b|} \rfloor (Euclidian division) and return an
3154
+ * array of two elements. The first element is the quotient, the second is
3155
+ * the remainder.
3156
+ *
3157
+ * b = 0 raises a RangeError exception.
3158
+ */
3159
+ edivrem(a: bigint, b: bigint): [bigint, bigint];
3160
+
3161
+ /**
3162
+ * Return \lfloor \sqrt(a) \rfloor.
3163
+ *
3164
+ * A RangeError exception is raised if a < 0.
3165
+ */
3166
+ sqrt(a: bigint): bigint;
3167
+
3168
+ /**
3169
+ * Return an array of two elements. The first element is
3170
+ * \lfloor \sqrt{a} \rfloor. The second element is
3171
+ * a-\lfloor \sqrt{a} \rfloor^2.
3172
+ *
3173
+ * A RangeError exception is raised if a < 0.
3174
+ */
3175
+ sqrtrem(a: bigint): [bigint, bigint];
3176
+
3177
+ /**
3178
+ * Return -1 if a \leq 0 otherwise return \lfloor \log2(a) \rfloor.
3179
+ */
3180
+ floorLog2(a: bigint): bigint;
3181
+
3182
+ /**
3183
+ * Return the number of trailing zeros in the two’s complement binary representation of a.
3184
+ *
3185
+ * Return -1 if a=0.
3186
+ */
3187
+ ctz(a: bigint): bigint;
3188
+ }
3189
+
3190
+ declare type BigFloatRoundingMode = number & {
3191
+ /**
3192
+ * This property is not here at runtime; we just use it to make this type
3193
+ * differ from a normal number
3194
+ */
3195
+ __is__: "BigFloatRoundingMode";
3196
+ };
3197
+
3198
+ interface BigFloatEnvConstructor {
3199
+ /**
3200
+ * Creates a new floating point environment. Its status flags are reset.
3201
+ *
3202
+ * - If unspecified, `precision` defaults to the precision from the global floating point environment.
3203
+ * - If unspecified, `roundingMode` defaults to RNDN.
3204
+ */
3205
+ new (precision?: number, roundingMode?: BigFloatRoundingMode): BigFloatEnv;
3206
+
3207
+ /**
3208
+ * The mantissa precision in bits of the global floating point environment.
3209
+ *
3210
+ * The initial value is 113.
3211
+ */
3212
+ get prec(): number;
3213
+
3214
+ /**
3215
+ * The exponent size in bits of the global floating point environment,
3216
+ * assuming an IEEE 754 representation.
3217
+ *
3218
+ * The initial value is 15.
3219
+ */
3220
+ get expBits(): number;
3221
+
3222
+ /**
3223
+ * Sets the mantissa precision of the global floating point environment to
3224
+ * `prec` and the exponent size to `expBits`, then calls the function `func`.
3225
+ * Then the precision and exponent size are reset to their previous values
3226
+ * and the return value of `func` is returned (or an exception is raised if
3227
+ * `func` raised an exception).
3228
+ *
3229
+ * If expBits is undefined, it is set to {@link BigFloatEnv.expBitsMax}.
3230
+ *
3231
+ * @param func The function to call within the modified environment
3232
+ * @param prec The mantissa precision (in bits) to use in the modified environment
3233
+ * @param expBits The exponent size (in bits) to use in the modified environment. Defaults to {@link BigFloatEnv.expBitsMax}.
3234
+ */
3235
+ setPrec<Ret>(func: () => Ret, prec: number, expBits?: number): Ret;
3236
+
3237
+ /**
3238
+ * Integer; the minimum allowed precision. Must be at least 2.
3239
+ */
3240
+ readonly precMin: number;
3241
+
3242
+ /**
3243
+ * Integer; the maximum allowed precision. Must be at least 113.
3244
+ */
3245
+ readonly precMax: number;
3246
+
3247
+ /**
3248
+ * Integer; the minimum allowed exponent size in bits. Must be at least 3.
3249
+ */
3250
+ readonly expBitsMin: number;
3251
+
3252
+ /**
3253
+ * Integer; the maximum allowed exponent size in bits. Must be at least 15.
3254
+ */
3255
+ readonly expBitsMax: number;
3256
+
3257
+ /**
3258
+ * Round to nearest, with ties to even rounding mode.
3259
+ */
3260
+ readonly RNDN: BigFloatRoundingMode;
3261
+
3262
+ /**
3263
+ * Round to zero rounding mode.
3264
+ */
3265
+ readonly RNDZ: BigFloatRoundingMode;
3266
+
3267
+ /**
3268
+ * Round to -Infinity rounding mode.
3269
+ */
3270
+ readonly RNDD: BigFloatRoundingMode;
3271
+
3272
+ /**
3273
+ * Round to +Infinity rounding mode.
3274
+ */
3275
+ readonly RNDU: BigFloatRoundingMode;
3276
+
3277
+ /**
3278
+ * Round to nearest, with ties away from zero rounding mode.
3279
+ */
3280
+ readonly RNDNA: BigFloatRoundingMode;
3281
+
3282
+ /**
3283
+ * Round away from zero rounding mode.
3284
+ */
3285
+ readonly RNDA: BigFloatRoundingMode;
3286
+
3287
+ /**
3288
+ * Faithful rounding mode. The result is non-deterministically rounded to
3289
+ * -Infinity or +Infinity.
3290
+ *
3291
+ * This rounding mode usually gives a faster and deterministic running time
3292
+ * for the floating point operations.
3293
+ */
3294
+ readonly RNDF: BigFloatRoundingMode;
3295
+
3296
+ prototype: BigFloatEnv;
3297
+ }
3298
+
3299
+ declare var BigFloatEnv: BigFloatEnvConstructor;
3300
+
3301
+ /**
3302
+ * A BigFloatEnv contains:
3303
+ *
3304
+ * - the mantissa precision in bits
3305
+ * - the exponent size in bits assuming an IEEE 754 representation;
3306
+ * - the subnormal flag (if true, subnormal floating point numbers can be generated by the floating point operations).
3307
+ * - the rounding mode
3308
+ * - the floating point status. The status flags can only be set by the floating point operations. They can be reset with BigFloatEnv.prototype.clearStatus() or with the various status flag setters.
3309
+ */
3310
+ interface BigFloatEnv {
3311
+ /**
3312
+ * The mantissa precision, in bits.
3313
+ *
3314
+ * If precision was not specified as an argument to the BigFloatEnv
3315
+ * constructor, defaults to the precision value of the global floating-point
3316
+ * environment ({@link BigFloatEnv.prec}).
3317
+ */
3318
+ get prec(): number;
3319
+ set prec(newValue: number);
3320
+
3321
+ /**
3322
+ * The exponent size in bits assuming an IEEE 754 representation.
3323
+ *
3324
+ * Defaults to the exponent size of the global floating-point environment
3325
+ * ({@link BigFloatEnv.expBits}).
3326
+ */
3327
+ get expBits(): number;
3328
+ set expBits(newValue: number);
3329
+
3330
+ /**
3331
+ * The rounding mode.
3332
+ *
3333
+ * If the rounding mode was not specified as an argument to the BigFloatEnv
3334
+ * constructor, defaults to {@link BigFloatEnv.RNDN}.
3335
+ */
3336
+ get rndMode(): BigFloatRoundingMode;
3337
+ set rndMode(newMode: BigFloatRoundingMode);
3338
+
3339
+ /** subnormal flag. It is false when expBits = expBitsMax. Defaults to false. */
3340
+ get subnormal(): boolean;
3341
+ set subnormal(newValue: boolean);
3342
+
3343
+ /** Status flag; cleared by `clearStatus`. */
3344
+ get invalidOperation(): boolean;
3345
+ set invalidOperation(newValue: boolean);
3346
+
3347
+ /** Status flag; cleared by `clearStatus`. */
3348
+ get divideByZero(): boolean;
3349
+ set divideByZero(newValue: boolean);
3350
+
3351
+ /** Status flag; cleared by `clearStatus`. */
3352
+ get overflow(): boolean;
3353
+ set overflow(newValue: boolean);
3354
+
3355
+ /** Status flag; cleared by `clearStatus`. */
3356
+ get underflow(): boolean;
3357
+ set underflow(newValue: boolean);
3358
+
3359
+ /** Status flag; cleared by `clearStatus`. */
3360
+ get inexact(): boolean;
3361
+ set inexact(newValue: boolean);
3362
+
3363
+ /**
3364
+ * Clear the status flags (invalidOperation, divideByZero, overflow,
3365
+ * underflow, and inexact).
3366
+ */
3367
+ clearStatus(): void;
3368
+ }
3369
+
3370
+ interface BigFloatConstructor {
3371
+ /**
3372
+ * If `value` is a numeric type, it is converted to BigFloat without rounding.
3373
+ *
3374
+ * If `value`` is a string, it is converted to BigFloat using the precision of the global floating point environment ({@link BigFloatEnv.prec}).
3375
+ */
3376
+ (value: number | string | BigInt | BigFloat): BigFloat;
3377
+
3378
+ prototype: BigFloat;
3379
+
3380
+ /**
3381
+ * The value of {@link Math.LN2} rounded to nearest, ties to even with the
3382
+ * current global precision.
3383
+ *
3384
+ * The constant values are cached for small precisions.
3385
+ */
3386
+ get LN2(): BigFloat;
3387
+
3388
+ /**
3389
+ * The value of {@link Math.PI} rounded to nearest, ties to even with
3390
+ * the current global precision.
3391
+ *
3392
+ * The constant values are cached for small precisions.
3393
+ */
3394
+ get PI(): BigFloat;
3395
+
3396
+ /**
3397
+ * The value of {@link Number.MIN_VALUE} as a BigFloat.
3398
+ */
3399
+ get MIN_VALUE(): BigFloat;
3400
+
3401
+ /**
3402
+ * The value of {@link Number.MAX_VALUE} as a BigFloat.
3403
+ */
3404
+ get MAX_VALUE(): BigFloat;
3405
+
3406
+ /**
3407
+ * The value of {@link Number.EPSILON} as a BigFloat.
3408
+ */
3409
+ get EPSILON(): BigFloat;
3410
+
3411
+ /**
3412
+ * Rounds the floating point number `a` according to the floating point
3413
+ * environment `e` or the global environment if `e` is undefined.
3414
+ */
3415
+ fpRound(a: BigFloat, e?: BigFloatEnv): BigFloat;
3416
+
3417
+ /**
3418
+ * Parses the string `a` as a floating point number in radix `radix`.
3419
+ *
3420
+ * The radix is 0 (default) or from 2 to 36. The radix 0 means radix 10
3421
+ * unless there is a hexadecimal or binary prefix.
3422
+ *
3423
+ * The result is rounded according to the floating point environment `e` or
3424
+ * the global environment if `e` is undefined.
3425
+ */
3426
+ parseFloat(a: string, radix?: number, e?: BigFloatEnv): BigFloat;
3427
+
3428
+ /**
3429
+ * Returns true if `a` is a finite bigfloat. Returns false otherwise.
3430
+ */
3431
+ isFinite(a: BigFloat): boolean;
3432
+
3433
+ /**
3434
+ * Returns true if a is a NaN bigfloat. Returns false otherwise.
3435
+ */
3436
+ isNaN(a: BigFloat): boolean;
3437
+
3438
+ /**
3439
+ * Adds `a` and `b` together and rounds the resulting floating point number
3440
+ * according to the floating point environment `e`, or the global environment
3441
+ * if e is undefined.
3442
+ *
3443
+ * If `e` is specified, the floating point status flags on `e` are updated.
3444
+ */
3445
+ add(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
3446
+
3447
+ /**
3448
+ * Subtracts `b` from `a` and rounds the resulting floating point number
3449
+ * according to the floating point environment `e`, or the global environment
3450
+ * if e is undefined.
3451
+ *
3452
+ * If `e` is specified, the floating point status flags on `e` are updated.
3453
+ */
3454
+ sub(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
3455
+
3456
+ /**
3457
+ * Multiplies `a` and `b` together and rounds the resulting floating point
3458
+ * number according to the floating point environment `e`, or the global
3459
+ * environment if e is undefined.
3460
+ *
3461
+ * If `e` is specified, the floating point status flags on `e` are updated.
3462
+ */
3463
+ mul(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
3464
+
3465
+ /**
3466
+ * Divides `a` by `b` and rounds the resulting floating point number
3467
+ * according to the floating point environment `e`, or the global environment
3468
+ * if e is undefined.
3469
+ *
3470
+ * If `e` is specified, the floating point status flags on `e` are updated.
3471
+ */
3472
+ div(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
3473
+
3474
+ /**
3475
+ * Rounds `x` down to the nearest integer.
3476
+ *
3477
+ * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
3478
+ */
3479
+ floor(x: BigFloat): BigFloat;
3480
+
3481
+ /**
3482
+ * Rounds `x` up to the nearest integer.
3483
+ *
3484
+ * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
3485
+ */
3486
+ ceil(x: BigFloat): BigFloat;
3487
+
3488
+ /**
3489
+ * Rounds `x` to the nearest integer.
3490
+ *
3491
+ * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
3492
+ */
3493
+ round(x: BigFloat): BigFloat;
3494
+
3495
+ /**
3496
+ * Truncates the fractional part of `x`, resulting in an integer.
3497
+ *
3498
+ * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
3499
+ */
3500
+ trunc(x: BigFloat): BigFloat;
3501
+
3502
+ /**
3503
+ * Returns the absolute value of `x`.
3504
+ *
3505
+ * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
3506
+ */
3507
+ abs(x: BigFloat): BigFloat;
3508
+
3509
+ /**
3510
+ * Floating point remainder. The quotient is truncated to zero.
3511
+ *
3512
+ * `e` is an optional floating point environment.
3513
+ */
3514
+ fmod(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
3515
+
3516
+ /**
3517
+ * Floating point remainder. The quotient is rounded to the nearest integer
3518
+ * with ties to even.
3519
+ *
3520
+ * `e` is an optional floating point environment.
3521
+ */
3522
+ remainder(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
3523
+
3524
+ /**
3525
+ * Square root. Returns a rounded floating point number.
3526
+ *
3527
+ * e is an optional floating point environment.
3528
+ */
3529
+ sqrt(x: BigFloat, e?: BigFloatEnv): BigFloat;
3530
+
3531
+ /**
3532
+ * Returns a rounded floating point number.
3533
+ *
3534
+ * `e` is an optional floating point environment.
3535
+ */
3536
+ sin(x: BigFloat, e?: BigFloatEnv): BigFloat;
3537
+
3538
+ /**
3539
+ * Returns a rounded floating point number.
3540
+ *
3541
+ * `e` is an optional floating point environment.
3542
+ */
3543
+ cos(x: BigFloat, e?: BigFloatEnv): BigFloat;
3544
+
3545
+ /**
3546
+ * Returns a rounded floating point number.
3547
+ *
3548
+ * `e` is an optional floating point environment.
3549
+ */
3550
+ tan(x: BigFloat, e?: BigFloatEnv): BigFloat;
3551
+
3552
+ /**
3553
+ * Returns a rounded floating point number.
3554
+ *
3555
+ * `e` is an optional floating point environment.
3556
+ */
3557
+ asin(x: BigFloat, e?: BigFloatEnv): BigFloat;
3558
+
3559
+ /**
3560
+ * Returns a rounded floating point number.
3561
+ *
3562
+ * `e` is an optional floating point environment.
3563
+ */
3564
+ acos(x: BigFloat, e?: BigFloatEnv): BigFloat;
3565
+
3566
+ /**
3567
+ * Returns a rounded floating point number.
3568
+ *
3569
+ * `e` is an optional floating point environment.
3570
+ */
3571
+ atan(x: BigFloat, e?: BigFloatEnv): BigFloat;
3572
+
3573
+ /**
3574
+ * Returns a rounded floating point number.
3575
+ *
3576
+ * `e` is an optional floating point environment.
3577
+ */
3578
+ atan2(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
3579
+
3580
+ /**
3581
+ * Returns a rounded floating point number.
3582
+ *
3583
+ * `e` is an optional floating point environment.
3584
+ */
3585
+ exp(x: BigFloat, e?: BigFloatEnv): BigFloat;
3586
+
3587
+ /**
3588
+ * Returns a rounded floating point number.
3589
+ *
3590
+ * `e` is an optional floating point environment.
3591
+ */
3592
+ log(x: BigFloat, e?: BigFloatEnv): BigFloat;
3593
+
3594
+ /**
3595
+ * Returns a rounded floating point number.
3596
+ *
3597
+ * `e` is an optional floating point environment.
3598
+ */
3599
+ pow(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
3600
+ }
3601
+
3602
+ declare var BigFloat: BigFloatConstructor;
3603
+
3604
+ /**
3605
+ * The BigFloat type represents floating point numbers in base 2 with the IEEE 754 semantics.
3606
+ *
3607
+ * A floating point number is represented as a sign, mantissa and exponent.
3608
+ *
3609
+ * The special values NaN, +/-Infinity, +0 and -0 are supported.
3610
+ *
3611
+ * The mantissa and exponent can have any bit length with an implementation specific minimum and maximum.
3612
+ */
3613
+ interface BigFloat {
3614
+ valueOf(): BigFloat;
3615
+
3616
+ /** radix must be between 2 and 36 */
3617
+ toString(radix?: number): string;
3618
+
3619
+ /**
3620
+ * Returns a string containing a number represented either in exponential or
3621
+ * fixed-point notation with a specified number of digits.
3622
+ *
3623
+ * @param precision Number of significant digits. There is no range limit on this number.
3624
+ * @param roundingMode The rounding mode to use when representing the value. Defaults to {@link BigFloatEnv.RNDNA}.
3625
+ * @param radix The base to use when representing the value. Must be an integer between 2 and 36. Defaults to 10.
3626
+ */
3627
+ toPrecision(
3628
+ precision: number,
3629
+ roundingMode?: BigFloatRoundingMode,
3630
+ radix?: number
3631
+ ): string;
3632
+
3633
+ /**
3634
+ * Returns a string representing a number in fixed-point notation.
3635
+ *
3636
+ * @param fractionDigits Number of digits after the decimal point. There is no range limit on this number.
3637
+ * @param roundingMode The rounding mode to use when representing the value. Defaults to {@link BigFloatEnv.RNDNA}.
3638
+ * @param radix The base to use when representing the value. Must be an integer between 2 and 36. Defaults to 10.
3639
+ */
3640
+ toFixed(
3641
+ fractionDigits: number,
3642
+ roundingMode?: BigFloatRoundingMode,
3643
+ radix?: number
3644
+ ): string;
3645
+
3646
+ /**
3647
+ * Returns a string containing a number represented in exponential notation.
3648
+ *
3649
+ * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
3650
+ * @param roundingMode The rounding mode to use when representing the value. Defaults to {@link BigFloatEnv.RNDNA}.
3651
+ * @param radix The base to use when representing the value. Must be an integer between 2 and 36. Defaults to 10.
3652
+ */
3653
+ toExponential(
3654
+ fractionDigits: number,
3655
+ roundingMode?: BigFloatRoundingMode,
3656
+ radix?: number
3657
+ ): string;
3658
+
3659
+ [Symbol.typeofValue]: () => "bigfloat";
3660
+ }
3661
+
3662
+ declare type BigDecimalRoundingMode =
3663
+ | "floor"
3664
+ | "ceiling"
3665
+ | "down"
3666
+ | "up"
3667
+ | "half-even"
3668
+ | "half-up";
3669
+
3670
+ declare type BigDecimalRoundingObject =
3671
+ | {
3672
+ /** must be >= 1 */
3673
+ maximumSignificantDigits: number;
3674
+ roundingMode: BigDecimalRoundingMode;
3675
+ }
3676
+ | {
3677
+ /** must be >= 0 */
3678
+ maximumFractionDigits: number;
3679
+ roundingMode: BigDecimalRoundingMode;
3680
+ };
3681
+
3682
+ interface BigDecimalConstructor {
3683
+ (): BigDecimal;
3684
+ (value: number | string | BigInt | BigFloat): BigDecimal;
3685
+
3686
+ /**
3687
+ * Adds together `a` and `b` and rounds the result according to the rounding
3688
+ * object `e`. If the rounding object is not present, the operation is
3689
+ * executed with infinite precision; in other words, no rounding occurs when
3690
+ * the rounding object is not present.
3691
+ */
3692
+ add(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
3693
+
3694
+ /**
3695
+ * Subtracts `b` from `a` and rounds the result according to the rounding
3696
+ * object `e`. If the rounding object is not present, the operation is
3697
+ * executed with infinite precision; in other words, no rounding occurs when
3698
+ * the rounding object is not present.
3699
+ */
3700
+ sub(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
3701
+
3702
+ /**
3703
+ * Multiplies together `a` and `b` and rounds the result according to the
3704
+ * rounding object `e`. If the rounding object is not present, the operation
3705
+ * is executed with infinite precision; in other words, no rounding occurs
3706
+ * when the rounding object is not present.
3707
+ */
3708
+ mul(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
3709
+
3710
+ /**
3711
+ * Divides `a` by `b` and rounds the result according to the rounding object
3712
+ * `e`.
3713
+ *
3714
+ * If the rounding object is not present, an attempt is made to perform the
3715
+ * operation with infinite precision. However, not all quotients can be
3716
+ * represented with infinite precision. If the quotient cannot be represented
3717
+ * with infinite precision, a RangeError is thrown.
3718
+ *
3719
+ * A RangeError is thrown when dividing by zero.
3720
+ */
3721
+ div(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
3722
+
3723
+ /**
3724
+ * Perform the modulo operation of `a` by `b` and round the result according
3725
+ * to the rounding object `e`. If the rounding object is not present, the
3726
+ * operation is executed with infinite precision; in other words, no rounding
3727
+ * occurs when the rounding object is not present.
3728
+ */
3729
+ mod(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
3730
+
3731
+ /**
3732
+ * Obtain the square root of `a`, rounding the result according to the
3733
+ * rounding object `e`.
3734
+ *
3735
+ * If `a` is less than zero, a RangeError will be thrown.
3736
+ *
3737
+ * Note that the rounding object is *required*.
3738
+ */
3739
+ sqrt(a: BigDecimal, e: BigDecimalRoundingObject): BigDecimal;
3740
+
3741
+ /**
3742
+ * Rounds `a` using the rounding object `e`.
3743
+ */
3744
+ round(a: BigDecimal, e: BigDecimalRoundingObject): BigDecimal;
3745
+
3746
+ prototype: BigDecimal;
3747
+ }
3748
+
3749
+ declare var BigDecimal: BigDecimalConstructor;
3750
+
3751
+ /**
3752
+ * The BigDecimal type represents floating point numbers in base 10.
3753
+ *
3754
+ * It is inspired from the proposal available at https://github.com/littledan/proposal-bigdecimal.
3755
+ *
3756
+ * The BigDecimal floating point numbers are always normalized and finite.
3757
+ * There is no concept of -0, Infinity or NaN. By default, all the computations
3758
+ * are done with infinite precision.
3759
+ */
3760
+ interface BigDecimal {
3761
+ /**
3762
+ * Returns the bigdecimal primitive value corresponding to this BigDecimal.
3763
+ */
3764
+ valueOf(): BigDecimal;
3765
+
3766
+ /**
3767
+ * Converts this BigDecimal to a string with infinite precision in base 10.
3768
+ */
3769
+ toString(): string;
3770
+
3771
+ /**
3772
+ * Returns a string containing a number represented either in exponential or
3773
+ * fixed-point notation with a specified number of digits.
3774
+ *
3775
+ * @param precision Number of significant digits. There is no range limit on this number.
3776
+ * @param roundingMode The rounding mode to use when representing the value. Defaults to "half-up".
3777
+ */
3778
+ toPrecision(precision: number, roundingMode?: BigDecimalRoundingMode): string;
3779
+
3780
+ /**
3781
+ * Returns a string representing a number in fixed-point notation.
3782
+ *
3783
+ * @param fractionDigits Number of digits after the decimal point. There is no range limit on this number.
3784
+ * @param roundingMode The rounding mode to use when representing the value. Defaults to "half-up".
3785
+ */
3786
+ toFixed(
3787
+ fractionDigits: number,
3788
+ roundingMode?: BigDecimalRoundingMode
3789
+ ): string;
3790
+
3791
+ /**
3792
+ * Returns a string containing a number represented in exponential notation.
3793
+ *
3794
+ * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
3795
+ * @param roundingMode The rounding mode to use when representing the value. Defaults to "half-up".
3796
+ */
3797
+ toExponential(
3798
+ fractionDigits: number,
3799
+ roundingMode?: BigDecimalRoundingMode
3800
+ ): string;
3801
+ }
3802
+
3803
+ // Note that BigFloat and BigDecimal have custom operator overloads defined in
3804
+ // QuickJS, but TypeScript does not support operator overloading. As such,
3805
+ // TypeScript will not understand or handle unary/binary operators for BigFloat
3806
+ // and BigDecimal properly.
1417
3807
 
1418
- // ==========================================
1419
- // ------------------------------------------
1420
- // QuickJS APIs, which YavaScript builds upon
1421
- // ------------------------------------------
1422
- // ==========================================
1423
3808
  // Definitions of the globals and modules added by quickjs-libc
1424
3809
 
1425
3810
  /**
@@ -1438,7 +3823,7 @@ declare var print: (...args: Array<any>) => void;
1438
3823
  /**
1439
3824
  * Object that provides functions for logging information.
1440
3825
  */
1441
- declare var console: {
3826
+ interface Console {
1442
3827
  /** Same as {@link print}(). */
1443
3828
  log: typeof print;
1444
3829
 
@@ -1450,7 +3835,9 @@ declare var console: {
1450
3835
 
1451
3836
  /** Same as {@link print}(). */
1452
3837
  info: typeof print;
1453
- };
3838
+ }
3839
+
3840
+ declare var console: Console;
1454
3841
 
1455
3842
  /** An object representing a file handle. */
1456
3843
  declare interface FILE {
@@ -1535,9 +3922,19 @@ declare interface FILE {
1535
3922
 
1536
3923
  /** Write one byte to the file. */
1537
3924
  putByte(value: number): void;
3925
+
3926
+ /**
3927
+ * Set the buffering mode and buffer size for the file stream (wrapper to the libc `setvbuf()`).
3928
+ *
3929
+ * Note that unlike the libc setvbuf, the "buffer" argument is not supported, and therefore is not present.
3930
+ *
3931
+ * @param mode The buffering mode to use. It can be one of the following values: `std._IOFBF` for full buffering, `std._IOLBF` for line buffering, or `std._IONBF` for no buffering.
3932
+ * @param size The size to resize the internal in-memory buffer for this file to.
3933
+ */
3934
+ setvbuf(mode: number, size: number): void;
1538
3935
  }
1539
3936
 
1540
- declare module "std" {
3937
+ declare module "quickjs:std" {
1541
3938
  /**
1542
3939
  * Exit the process with the provided status code.
1543
3940
  *
@@ -1551,11 +3948,12 @@ declare module "std" {
1551
3948
  * @param code - The code to evaluate.
1552
3949
  * @param options - An optional object containing the following optional properties:
1553
3950
  * @property backtraceBarrier - Boolean (default = false). If true, error backtraces do not list the stack frames below the evalScript.
3951
+ * @property filename - String (default = "<evalScript>"). The filename to associate with the code being executed.
1554
3952
  * @returns The result of the evaluation.
1555
3953
  */
1556
3954
  export function evalScript(
1557
3955
  code: string,
1558
- options?: { backtraceBarrier?: boolean }
3956
+ options?: { backtraceBarrier?: boolean; filename?: string }
1559
3957
  ): any;
1560
3958
 
1561
3959
  /**
@@ -1678,6 +4076,15 @@ declare module "std" {
1678
4076
  /** Constant for {@link FILE.seek}. Declares that the offset should be relative to the end of the file. See also libc `fseek()`. */
1679
4077
  export var SEEK_END: number;
1680
4078
 
4079
+ /** Constant for {@link FILE.setvbuf}. Declares that the buffer mode should be 'full buffering'. */
4080
+ export var _IOFBF: number;
4081
+
4082
+ /** Constant for {@link FILE.setvbuf}. Declares that the buffer mode should be 'line buffering'. */
4083
+ export var _IOLBF: number;
4084
+
4085
+ /** Constant for {@link FILE.setvbuf}. Declares that the buffer mode should be 'no buffering'. */
4086
+ export var _IONBF: number;
4087
+
1681
4088
  /** Manually invoke the cycle removal algorithm (garbage collector). The cycle removal algorithm is automatically started when needed, so this function is useful in case of specific memory constraints or for testing. */
1682
4089
  export function gc(): void;
1683
4090
 
@@ -1812,7 +4219,7 @@ declare module "std" {
1812
4219
  export function parseExtJSON(str: string): any;
1813
4220
  }
1814
4221
 
1815
- declare module "os" {
4222
+ declare module "quickjs:os" {
1816
4223
  /**
1817
4224
  * Open a file handle. Returns a number; the file descriptor.
1818
4225
  *
@@ -1843,8 +4250,19 @@ declare module "os" {
1843
4250
  /** POSIX open flag, used in {@link open}. */
1844
4251
  export var O_TRUNC: number;
1845
4252
 
1846
- /** Windows-specific open flag: open the file in text mode. The default is binary mode. Used in {@link open}. */
1847
- export var O_TEXT: number;
4253
+ /**
4254
+ * Windows-specific open flag: open the file in binary mode (which is the default). Used in {@link open}.
4255
+ *
4256
+ * NOTE: this property is only present on windows
4257
+ */
4258
+ export var O_BINARY: number | undefined;
4259
+
4260
+ /**
4261
+ * Windows-specific open flag: open the file in text mode. The default is binary mode. Used in {@link open}.
4262
+ *
4263
+ * NOTE: this property is only present on windows
4264
+ */
4265
+ export var O_TEXT: number | undefined;
1848
4266
 
1849
4267
  /** Close the file with descriptor `fd`. */
1850
4268
  export function close(fd: number): void;
@@ -1958,26 +4376,167 @@ declare module "os" {
1958
4376
  */
1959
4377
  export function lstat(path: string): Stats;
1960
4378
 
1961
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
4379
+ /**
4380
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4381
+ *
4382
+ * Mask for getting type of file from mode.
4383
+ */
1962
4384
  export var S_IFMT: number;
1963
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
4385
+
4386
+ /**
4387
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4388
+ *
4389
+ * File type: named pipe (fifo)
4390
+ */
1964
4391
  export var S_IFIFO: number;
1965
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
4392
+
4393
+ /**
4394
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4395
+ *
4396
+ * File type: character special
4397
+ */
1966
4398
  export var S_IFCHR: number;
1967
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
4399
+
4400
+ /**
4401
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4402
+ *
4403
+ * File type: directory
4404
+ */
1968
4405
  export var S_IFDIR: number;
1969
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
4406
+
4407
+ /**
4408
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4409
+ *
4410
+ * File type: block special
4411
+ */
1970
4412
  export var S_IFBLK: number;
1971
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
4413
+
4414
+ /**
4415
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4416
+ *
4417
+ * File type: regular
4418
+ */
1972
4419
  export var S_IFREG: number;
1973
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
1974
- export var S_IFSOCK: number;
1975
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
1976
- export var S_IFLNK: number;
1977
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
1978
- export var S_ISGID: number;
1979
- /** Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`. */
1980
- export var S_ISUID: number;
4420
+
4421
+ /**
4422
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4423
+ *
4424
+ * File type: socket
4425
+ *
4426
+ * NOTE: this property is not present on windows
4427
+ */
4428
+ export var S_IFSOCK: number | undefined;
4429
+
4430
+ /**
4431
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4432
+ *
4433
+ * File type: symbolic link
4434
+ *
4435
+ * NOTE: this property is not present on windows
4436
+ */
4437
+ export var S_IFLNK: number | undefined;
4438
+
4439
+ /**
4440
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4441
+ *
4442
+ * Flag: set group id on execution
4443
+ *
4444
+ * NOTE: this property is not present on windows
4445
+ */
4446
+ export var S_ISGID: number | undefined;
4447
+
4448
+ /**
4449
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4450
+ *
4451
+ * Flag: set user id on execution
4452
+ *
4453
+ * NOTE: this property is not present on windows
4454
+ */
4455
+ export var S_ISUID: number | undefined;
4456
+
4457
+ /**
4458
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4459
+ *
4460
+ * Mask for getting RWX permissions for owner
4461
+ */
4462
+ export var S_IRWXU: number;
4463
+
4464
+ /**
4465
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4466
+ *
4467
+ * Permission: read for owner
4468
+ */
4469
+ export var S_IRUSR: number;
4470
+
4471
+ /**
4472
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4473
+ *
4474
+ * Permission: write for owner
4475
+ */
4476
+ export var S_IWUSR: number;
4477
+
4478
+ /**
4479
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4480
+ *
4481
+ * Permission: execute for owner
4482
+ */
4483
+ export var S_IXUSR: number;
4484
+
4485
+ /**
4486
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4487
+ *
4488
+ * Mask for getting RWX permissions for group
4489
+ */
4490
+ export var S_IRWXG: number;
4491
+
4492
+ /**
4493
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4494
+ *
4495
+ * Permission: read for group
4496
+ */
4497
+ export var S_IRGRP: number;
4498
+
4499
+ /**
4500
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4501
+ *
4502
+ * Permission: write for group
4503
+ */
4504
+ export var S_IWGRP: number;
4505
+
4506
+ /**
4507
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4508
+ *
4509
+ * Permission: execute for group
4510
+ */
4511
+ export var S_IXGRP: number;
4512
+
4513
+ /**
4514
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4515
+ *
4516
+ * Mask for getting RWX permissions for others
4517
+ */
4518
+ export var S_IRWXO: number;
4519
+
4520
+ /**
4521
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4522
+ *
4523
+ * Permission: read for others
4524
+ */
4525
+ export var S_IROTH: number;
4526
+
4527
+ /**
4528
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4529
+ *
4530
+ * Permission: write for others
4531
+ */
4532
+ export var S_IWOTH: number;
4533
+
4534
+ /**
4535
+ * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
4536
+ *
4537
+ * Permission: execute for others
4538
+ */
4539
+ export var S_IXOTH: number;
1981
4540
 
1982
4541
  /**
1983
4542
  * Change the access and modification times of the file path.
@@ -2025,6 +4584,39 @@ declare module "os" {
2025
4584
  /** POSIX signal number. */
2026
4585
  export var SIGTERM: number;
2027
4586
 
4587
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4588
+ export var SIGQUIT: number | undefined;
4589
+
4590
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4591
+ export var SIGPIPE: number | undefined;
4592
+
4593
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4594
+ export var SIGALRM: number | undefined;
4595
+
4596
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4597
+ export var SIGUSR1: number | undefined;
4598
+
4599
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4600
+ export var SIGUSR2: number | undefined;
4601
+
4602
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4603
+ export var SIGCHLD: number | undefined;
4604
+
4605
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4606
+ export var SIGCONT: number | undefined;
4607
+
4608
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4609
+ export var SIGSTOP: number | undefined;
4610
+
4611
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4612
+ export var SIGTSTP: number | undefined;
4613
+
4614
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4615
+ export var SIGTTIN: number | undefined;
4616
+
4617
+ /** POSIX signal number. NOTE: this signal is not present on windows. */
4618
+ export var SIGTTOU: number | undefined;
4619
+
2028
4620
  /** Send the signal `sig` to the process `pid`. Use `os.SIG*` constants. */
2029
4621
  export function kill(pid: number, sig: number): void;
2030
4622
 
@@ -2319,29 +4911,19 @@ declare interface InspectFunction {
2319
4911
  declare var inspect: InspectFunction;
2320
4912
 
2321
4913
  /**
2322
- * A class which represents a module namespace object. Note, however, that
2323
- * instances of this class cannot be constructed manually, and must instead be
2324
- * obtained from `import * as`, `import()`, `std.importModule`, or `require`.
4914
+ * A global which lets you configure the module loader (import/export/require).
4915
+ * You can use these properties to add support for importing new filetypes.
2325
4916
  *
2326
- * The static properties on `Module` let you configure the module loader
2327
- * (import/export/require). You can use these properties to add support for
2328
- * importing new filetypes.
4917
+ * This global can also be used to identify whether an object is a module
4918
+ * namespace record.
2329
4919
  */
2330
- declare class Module {
2331
- /** A module namespace object has arbitrary exports. */
2332
- [key: string | number | symbol]: any;
2333
-
2334
- /**
2335
- * Module objects are not constructable.
2336
- *
2337
- * You must instead obtain them using import or require.
2338
- */
2339
- private constructor();
2340
-
4920
+ interface ModuleGlobal {
2341
4921
  /**
2342
4922
  * Returns true if `target` is a module namespace object.
2343
4923
  */
2344
- static [Symbol.hasInstance](target: any): target is Module;
4924
+ [Symbol.hasInstance](target: any): target is {
4925
+ [key: string | number | symbol]: any;
4926
+ };
2345
4927
 
2346
4928
  /**
2347
4929
  * A list of filetype extensions that may be omitted from an import specifier
@@ -2356,7 +4938,7 @@ declare class Module {
2356
4938
  * NOTE: If you add a new extension to this array, you will likely also want
2357
4939
  * to add to {@link Module.compilers}.
2358
4940
  */
2359
- static searchExtensions: Array<string>;
4941
+ searchExtensions: Array<string>;
2360
4942
 
2361
4943
  /**
2362
4944
  * User-defined functions which will handle getting the JavaScript code
@@ -2397,7 +4979,7 @@ declare class Module {
2397
4979
  * NOTE: When adding to this object, you may also wish to add to
2398
4980
  * {@link Module.searchExtensions}.
2399
4981
  */
2400
- static compilers: {
4982
+ compilers: {
2401
4983
  [extensionWithDot: string]: (filename: string, content: string) => string;
2402
4984
  };
2403
4985
 
@@ -2405,50 +4987,74 @@ declare class Module {
2405
4987
  * Create a virtual built-in module whose exports consist of the own
2406
4988
  * enumerable properties of `obj`.
2407
4989
  */
2408
- static define(name: string, obj: { [key: string]: any }): void;
4990
+ define(name: string, obj: { [key: string]: any }): void;
4991
+
4992
+ /**
4993
+ * Resolves a require/import request from `fromFile` into a canonicalized path.
4994
+ *
4995
+ * To change native module resolution behavior, replace this function with
4996
+ * your own implementation. Note that you must handle
4997
+ * `Module.searchExtensions` yourself in your replacement implementation.
4998
+ */
4999
+ resolve(name: string, fromFile: string): string;
5000
+
5001
+ /**
5002
+ * Reads the contents of the given resolved module name into a string.
5003
+ *
5004
+ * To change native module loading behavior, replace this function with your
5005
+ * own implementation. Note that you must handle `Module.compilers` yourself
5006
+ * in your replacement implementation.
5007
+ */
5008
+ read(modulePath: string): string;
2409
5009
  }
2410
5010
 
2411
- /**
2412
- * Synchronously import a module.
2413
- *
2414
- * `source` will be resolved relative to the calling file.
2415
- *
2416
- * If `source` does not have a file extension, and a file without an extension
2417
- * cannot be found, the engine will check for files with the extensions in
2418
- * {@link Module.searchExtensions}, and use one of those if present. This
2419
- * behavior also happens when using normal `import` statements.
2420
- *
2421
- * For example, if you write:
2422
- *
2423
- * ```js
2424
- * import something from "./somewhere";
2425
- * ```
2426
- *
2427
- * but there's no file named `somewhere` in the same directory as the file
2428
- * where that import appears, and `Module.searchExtensions` is the default
2429
- * value:
2430
- *
2431
- * ```js
2432
- * [".js"]
2433
- * ```
2434
- *
2435
- * then the engine will look for `somewhere.js`. If that doesn't exist, the
2436
- * engine will look for `somewhere/index.js`. If *that* doesn't exist, an error
2437
- * will be thrown.
2438
- *
2439
- * If you add more extensions to `Module.searchExtensions`, then the engine
2440
- * will use those, too. It will search in the same order as the strings appear
2441
- * in the `Module.searchExtensions` array.
2442
- */
2443
- declare var require: ((source: string) => { [key: string]: any }) & {
5011
+ declare var Module: ModuleGlobal;
5012
+
5013
+ interface RequireFunction {
5014
+ /**
5015
+ * Synchronously import a module.
5016
+ *
5017
+ * `source` will be resolved relative to the calling file.
5018
+ *
5019
+ * If `source` does not have a file extension, and a file without an extension
5020
+ * cannot be found, the engine will check for files with the extensions in
5021
+ * {@link Module.searchExtensions}, and use one of those if present. This
5022
+ * behavior also happens when using normal `import` statements.
5023
+ *
5024
+ * For example, if you write:
5025
+ *
5026
+ * ```js
5027
+ * import something from "./somewhere";
5028
+ * ```
5029
+ *
5030
+ * but there's no file named `somewhere` in the same directory as the file
5031
+ * where that import appears, and `Module.searchExtensions` is the default
5032
+ * value:
5033
+ *
5034
+ * ```js
5035
+ * [".js"]
5036
+ * ```
5037
+ *
5038
+ * then the engine will look for `somewhere.js`. If that doesn't exist, the
5039
+ * engine will look for `somewhere/index.js`. If *that* doesn't exist, an error
5040
+ * will be thrown.
5041
+ *
5042
+ * If you add more extensions to `Module.searchExtensions`, then the engine
5043
+ * will use those, too. It will search in the same order as the strings appear
5044
+ * in the `Module.searchExtensions` array.
5045
+ */
5046
+ (source: string): any;
5047
+
2444
5048
  /**
2445
5049
  * Resolves the normalized path to a modules, relative to the calling file.
2446
5050
  */
2447
5051
  resolve: (source: string) => string;
2448
- };
5052
+ }
5053
+
5054
+ declare var require: RequireFunction;
2449
5055
 
2450
- declare var setTimeout: typeof import("os").setTimeout;
2451
- declare var clearTimeout: typeof import("os").clearTimeout;
5056
+ declare var setTimeout: typeof import("quickjs:os").setTimeout;
5057
+ declare var clearTimeout: typeof import("quickjs:os").clearTimeout;
2452
5058
 
2453
5059
  declare type Interval = { [Symbol.toStringTag]: "Interval" };
2454
5060
 
@@ -2508,3 +5114,208 @@ interface StringConstructor {
2508
5114
  ): Func;
2509
5115
  };
2510
5116
  }
5117
+
5118
+ declare module "quickjs:bytecode" {
5119
+ /**
5120
+ * Convert the module or script in the specified file into bytecode.
5121
+ *
5122
+ * When converted back to a value, it will be a function.
5123
+ */
5124
+ export function fromFile(
5125
+ path: string,
5126
+ options?: { byteSwap?: boolean; sourceType?: "module" | "script" }
5127
+ ): ArrayBuffer;
5128
+
5129
+ /**
5130
+ * Convert the provided value into bytecode. Doesn't work with all values.
5131
+ */
5132
+ export function fromValue(
5133
+ value: any,
5134
+ options?: { byteSwap?: boolean }
5135
+ ): ArrayBuffer;
5136
+
5137
+ /**
5138
+ * Convert the provided bytecode into a value.
5139
+ */
5140
+ export function toValue(bytecode: ArrayBuffer): any;
5141
+ }
5142
+
5143
+ declare module "quickjs:context" {
5144
+ /**
5145
+ * A separate global context (or 'realm') within which code can be executed.
5146
+ */
5147
+ export class Context {
5148
+ /**
5149
+ * Create a new global context (or 'realm') within code can be executed.
5150
+ *
5151
+ * @param options Options for what globals/modules/etc to make available within the context.
5152
+ *
5153
+ * The following globals are always present, regardless of options:
5154
+ *
5155
+ * - Object
5156
+ * - Function
5157
+ * - Error
5158
+ * - EvalError
5159
+ * - RangeError
5160
+ * - ReferenceError
5161
+ * - SyntaxError
5162
+ * - TypeError
5163
+ * - URIError
5164
+ * - InternalError
5165
+ * - AggregateError
5166
+ * - Array
5167
+ * - parseInt
5168
+ * - parseFloat
5169
+ * - isNaN
5170
+ * - isFinite
5171
+ * - decodeURI
5172
+ * - decodeURIComponent
5173
+ * - encodeURI
5174
+ * - encodeURIComponent
5175
+ * - escape
5176
+ * - unescape
5177
+ * - Infinity
5178
+ * - NaN
5179
+ * - undefined
5180
+ * - __date_clock
5181
+ * - Number
5182
+ * - Boolean
5183
+ * - String
5184
+ * - Math
5185
+ * - Reflect
5186
+ * - Symbol
5187
+ * - eval (but it doesn't work unless the `eval` option is enabled)
5188
+ * - globalThis
5189
+ */
5190
+ constructor(options?: {
5191
+ /** Enables `Date`. Defaults to `true` */
5192
+ date?: boolean;
5193
+
5194
+ /** Enables `eval`. Defaults to `true` */
5195
+ eval?: boolean;
5196
+
5197
+ /** Enables `String.prototype.normalize`. Defaults to `true`. */
5198
+ stringNormalize?: boolean;
5199
+
5200
+ /** Enables `RegExp`. Defaults to `true`. */
5201
+ regExp?: boolean;
5202
+
5203
+ /** Enables `JSON`. Defaults to `true`. */
5204
+ json?: boolean;
5205
+
5206
+ /** Enables `Proxy`. Defaults to `true`. */
5207
+ proxy?: boolean;
5208
+
5209
+ /** Enables `Map` and `Set`. Defaults to `true`. */
5210
+ mapSet?: boolean;
5211
+
5212
+ /**
5213
+ * Enables:
5214
+ *
5215
+ * - ArrayBuffer
5216
+ * - SharedArrayBuffer
5217
+ * - Uint8ClampedArray
5218
+ * - Int8Array
5219
+ * - Uint8Array
5220
+ * - Int16Array
5221
+ * - Uint16Array
5222
+ * - Int32Array
5223
+ * - Uint32Array
5224
+ * - BigInt64Array
5225
+ * - BigUint64Array
5226
+ * - Float32Array
5227
+ * - Float64Array
5228
+ * - DataView
5229
+ *
5230
+ * Defaults to `true`.
5231
+ */
5232
+ typedArrays?: boolean;
5233
+
5234
+ /**
5235
+ * Enables:
5236
+ *
5237
+ * - Promise
5238
+ * - async functions
5239
+ * - async iterators
5240
+ * - async generators
5241
+ *
5242
+ * Defaults to `true`.
5243
+ */
5244
+ promise?: boolean;
5245
+
5246
+ /** Enables `BigInt`. Defaults to `true`. */
5247
+ bigint?: boolean;
5248
+
5249
+ /** Enables `BigFloat`. Defaults to `true`. */
5250
+ bigfloat?: boolean;
5251
+
5252
+ /** Enables `BigDecimal`. Defaults to `true`. */
5253
+ bigdecimal?: boolean;
5254
+
5255
+ /**
5256
+ * Enables:
5257
+ *
5258
+ * - Operators
5259
+ * - OperatorSet creation
5260
+ * - operator overloading
5261
+ *
5262
+ * Defaults to `true`.
5263
+ */
5264
+ operators?: boolean;
5265
+
5266
+ /** Enables "use math". Defaults to `true`. */
5267
+ useMath?: boolean;
5268
+
5269
+ /**
5270
+ * Enables:
5271
+ *
5272
+ * - inspect
5273
+ * - console
5274
+ * - print
5275
+ * - require (and require.resolve)
5276
+ * - setTimeout
5277
+ * - clearTimeout
5278
+ * - setInterval
5279
+ * - clearInterval
5280
+ * - String.cooked
5281
+ * - String.dedent
5282
+ *
5283
+ * Defaults to `true`.
5284
+ *
5285
+ * NOTE: The following globals, normally part of `js_std_add_helpers`, are NEVER added:
5286
+ *
5287
+ * - Module
5288
+ * - scriptArgs
5289
+ *
5290
+ * If you need them in the new context, copy them over from your context's globalThis onto the child context's globalThis.
5291
+ */
5292
+ stdHelpers?: boolean;
5293
+
5294
+ /** Enable builtin modules. */
5295
+ modules?: {
5296
+ /** Enables the "quickjs:std" module. Defaults to `true`. */
5297
+ "quickjs:std"?: boolean;
5298
+ /** Enables the "quickjs:os" module. Defaults to `true`. */
5299
+ "quickjs:os"?: boolean;
5300
+ /** Enables the "quickjs:bytecode" module. Defaults to `true`. */
5301
+ "quickjs:bytecode"?: boolean;
5302
+ /** Enables the "quickjs:context" module. Defaults to `true`. */
5303
+ "quickjs:context"?: boolean;
5304
+ };
5305
+ });
5306
+
5307
+ /**
5308
+ * The `globalThis` object used by this context.
5309
+ *
5310
+ * You can add to or remove from it to change what is visible to the context.
5311
+ */
5312
+ globalThis: typeof globalThis;
5313
+
5314
+ /**
5315
+ * Runs code within the context and returns the result.
5316
+ *
5317
+ * @param code The code to run.
5318
+ */
5319
+ eval(code: string): any;
5320
+ }
5321
+ }