@amritk/nish-aarch64-darwin 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALL.md +73 -59
- package/bin/nish +0 -0
- package/docs/AI.md +50 -4
- package/package.json +1 -1
- package/runtime/async.d.mts +2 -0
- package/runtime/async.mjs +7 -0
- package/runtime/nish.d.ts +4849 -430
- package/runtime/nish.h +25 -0
- package/runtime/page.d.ts +53 -0
- package/runtime/page.mjs +146 -0
- package/runtime/runtime-async.c +557 -0
- package/runtime/runtime-wasm.c +63 -7
- package/runtime/vite.d.ts +30 -0
- package/runtime/vite.mjs +150 -0
- package/scripts/build.sh +252 -15
- package/std/README.md +107 -82
- package/std/base64.ts +34 -5
- package/std/bytes.ts +279 -59
- package/std/cli-args.ts +296 -70
- package/std/cli-flags.ts +184 -19
- package/std/cli.ts +475 -54
- package/std/collections.ts +121 -23
- package/std/compress/checksum.ts +44 -14
- package/std/compress/deflate.ts +224 -111
- package/std/compress/gzip.ts +217 -53
- package/std/compress/zlib.ts +63 -7
- package/std/crypto/aes.ts +128 -52
- package/std/crypto/base64url.ts +29 -5
- package/std/crypto/bcrypt-batch.ts +101 -34
- package/std/crypto/bcrypt.ts +93 -27
- package/std/crypto/chacha20poly1305.ts +69 -14
- package/std/crypto/ct.ts +32 -13
- package/std/crypto/ed25519.ts +66 -16
- package/std/crypto/hkdf.ts +198 -13
- package/std/crypto/hmac.ts +242 -37
- package/std/crypto/jwt.ts +204 -72
- package/std/crypto/p256.ts +222 -72
- package/std/crypto/p384.ts +51 -23
- package/std/crypto/pki-roots.ts +32 -2
- package/std/crypto/pki.ts +99 -30
- package/std/crypto/rsa.ts +56 -22
- package/std/crypto/sha1.ts +3 -0
- package/std/crypto/sha256.ts +24 -1
- package/std/crypto/sha512.ts +99 -14
- package/std/crypto/x25519.ts +163 -24
- package/std/crypto/x509-random.ts +10 -0
- package/std/crypto/x509.ts +133 -66
- package/std/host/ring.ts +124 -0
- package/std/json-equal.ts +31 -11
- package/std/json-format.ts +112 -13
- package/std/json-number.ts +76 -26
- package/std/json-pointer.ts +23 -1
- package/std/json-tokenizer.ts +126 -51
- package/std/json-typed.ts +757 -96
- package/std/json-value.ts +438 -157
- package/std/json.ts +170 -38
- package/std/map.ts +25 -7
- package/std/math.ts +36 -4
- package/std/net/buffer-pool.ts +42 -11
- package/std/net/dns-config.ts +109 -23
- package/std/net/dns-message.ts +62 -7
- package/std/net/dns-resolver.ts +247 -53
- package/std/net/dns.ts +203 -35
- package/std/net/fetch.ts +1267 -290
- package/std/net/handler.ts +296 -80
- package/std/net/hpack.ts +290 -77
- package/std/net/http-compress.ts +152 -36
- package/std/net/http-fields.ts +85 -9
- package/std/net/http1-client-codec.ts +129 -44
- package/std/net/http1-codec.ts +279 -114
- package/std/net/http1-server.ts +409 -139
- package/std/net/http2-frame.ts +289 -51
- package/std/net/http2-tls.ts +152 -49
- package/std/net/http2.ts +314 -160
- package/std/net/http3-frame.ts +165 -27
- package/std/net/http3-server.ts +282 -131
- package/std/net/http3.ts +377 -173
- package/std/net/outbound.ts +37 -3
- package/std/net/postgres-carrier.ts +144 -8
- package/std/net/postgres.ts +898 -260
- package/std/net/prefork.ts +202 -65
- package/std/net/qpack.ts +120 -32
- package/std/net/quic-conn-ack.ts +60 -12
- package/std/net/quic-conn-cid.ts +135 -27
- package/std/net/quic-conn-params.ts +109 -22
- package/std/net/quic-datagram.ts +50 -3
- package/std/net/quic-frame.ts +333 -23
- package/std/net/quic-listener.ts +161 -75
- package/std/net/quic-packet.ts +373 -73
- package/std/net/quic-recovery.ts +287 -65
- package/std/net/quic-stream.ts +436 -146
- package/std/net/quic.ts +693 -323
- package/std/net/router.ts +87 -40
- package/std/net/tls/client.ts +167 -51
- package/std/net/tls/codec.ts +494 -68
- package/std/net/tls/record-client.ts +140 -73
- package/std/net/tls/record-server.ts +233 -105
- package/std/net/tls/record.ts +142 -36
- package/std/net/tls/schedule.ts +235 -26
- package/std/net/tls/ticket.ts +161 -40
- package/std/net/tls/verify.ts +57 -10
- package/std/net/tls-tcp.ts +308 -95
- package/std/net/tls.ts +276 -102
- package/std/net/upstream.ts +81 -45
- package/std/net/url.ts +109 -22
- package/std/net/websocket.ts +140 -26
- package/std/net/webtransport.ts +243 -106
- package/std/pair.ts +10 -2
- package/std/random.ts +42 -15
- package/std/regex.ts +422 -257
- package/std/region.ts +70 -15
- package/std/secret.ts +52 -11
- package/std/sort.ts +17 -2
- package/std/sqlite.ts +256 -35
- package/std/sync/ring.ts +229 -56
- package/std/sync/shm.ts +203 -23
- package/std/term-io.ts +154 -78
- package/std/term-pixels.ts +144 -19
- package/std/term-probe.ts +77 -35
- package/std/term-rate.ts +199 -118
- package/std/term.ts +400 -175
- package/std/testing.ts +130 -32
- package/std/text.ts +84 -17
- package/std/threads.ts +248 -56
- package/std/yaml-json.ts +111 -97
- package/std/yaml-lines.ts +47 -15
- package/std/yaml-write.ts +45 -30
- package/std/yaml.ts +764 -384
package/INSTALL.md
CHANGED
|
@@ -52,7 +52,12 @@ export PATH="$(brew --prefix llvm@18)/bin:$PATH" # add to your shell profile
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Xcode's `clang` (`xcode-select --install`) also works for native binaries;
|
|
55
|
-
the Homebrew LLVM is needed for the `wasm` and `wasi` profiles (`wasm-ld`).
|
|
55
|
+
the Homebrew LLVM is needed for the `wasm`, `wasm-host` and `wasi` profiles (`wasm-ld`).
|
|
56
|
+
|
|
57
|
+
`wasm-opt` (binaryen: `apt-get install binaryen`, `brew install binaryen`) is
|
|
58
|
+
optional. When it is on `PATH`, `scripts/build.sh --profile wasm-host` runs
|
|
59
|
+
`wasm-opt -Oz` on the module, and the build line says whether it ran. Without
|
|
60
|
+
it the module is complete, just not as small.
|
|
56
61
|
|
|
57
62
|
<a id="wasi-optional-for---profile-wasi" style="scroll-margin-top: 65px"></a>
|
|
58
63
|
|
|
@@ -150,13 +155,15 @@ tarball's SHA-256 with the release's `SHA256SUMS` (or with the digest pinned
|
|
|
150
155
|
for releases that predate it) and refuses a mismatch. For releases after
|
|
151
156
|
0.21.0 it also checks the release's **build provenance attestation** when a
|
|
152
157
|
signed-in GitHub CLI is present whose `gh attestation verify` takes the
|
|
153
|
-
options below.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
options below.
|
|
159
|
+
|
|
160
|
+
The attestation is a Sigstore-signed statement, made by
|
|
161
|
+
`actions/attest-build-provenance` in the release workflow, that every file in
|
|
162
|
+
`SHA256SUMS` was built by `.github/workflows/release.yml` at the release's tag
|
|
163
|
+
on a GitHub-hosted runner. A failed verification refuses the install; with no
|
|
164
|
+
`gh`, a signed-out one or one too old for those options, the check is skipped
|
|
165
|
+
with a note saying so, and the SHA-256 still applies. The same command by hand,
|
|
166
|
+
on a tarball you downloaded:
|
|
160
167
|
|
|
161
168
|
```bash
|
|
162
169
|
gh attestation verify nish-<version>-<asset>.tar.gz \
|
|
@@ -400,11 +407,13 @@ header — and `runtime/sqlite/`, SQLite's vendored source),
|
|
|
400
407
|
`docs/AI.md` (the rules card). The
|
|
401
408
|
compiler itself is not in it: it arrives as one prebuilt
|
|
402
409
|
`@amritk/nish-<asset>` package per platform, and `bin/nish` hands over to
|
|
403
|
-
whichever one npm installed.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
410
|
+
whichever one npm installed.
|
|
411
|
+
|
|
412
|
+
That package carries its own copy of all of these, and its `docs/AI.md` is the
|
|
413
|
+
one an agent's `nish --help` names. `nish` locates the runtime, the script and
|
|
414
|
+
`std/` relative to its own install directory, so a global install works from
|
|
415
|
+
any working directory — and the binary runs from inside its own platform
|
|
416
|
+
package for exactly that reason.
|
|
408
417
|
|
|
409
418
|
Building the IR yourself rather than through `--link` means naming the runtime
|
|
410
419
|
on the `clang` line, and it is sixteen files:
|
|
@@ -420,26 +429,31 @@ clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
|
|
|
420
429
|
`runtime.c` is the part every program touches — the arena, strings, arrays,
|
|
421
430
|
number formatting, the panics — and `runtime-os.c` wraps the system calls:
|
|
422
431
|
files, directories, subprocesses, `getenv`, the monotonic clock.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
`runtime-
|
|
430
|
-
`runtime-
|
|
431
|
-
blocks to on a CPU with the
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
`
|
|
436
|
-
|
|
437
|
-
`runtime-
|
|
438
|
-
`runtime-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
432
|
+
|
|
433
|
+
`runtime-parallel.c` divides work across threads for `nish/threads` (a program
|
|
434
|
+
built with `--threads`, as every importer of `nish/threads` is, also needs
|
|
435
|
+
`-DNISH_THREADS=1 -pthread` on the line), `runtime-cross.c` copies the strings
|
|
436
|
+
and arrays a task answers, a channel sends or a `Mutex` keeps out of the arena
|
|
437
|
+
they were made in, `runtime-host.c` holds the wall clock, entropy, file times
|
|
438
|
+
and signals, `runtime-net.c` the sockets of `nish:net`, `runtime-simd.c` and
|
|
439
|
+
`runtime-aes.c` the vector text search and AES-GCM, `runtime-sha256.c` the
|
|
440
|
+
SHA-256 block kernel `nish/crypto/sha256` hands its blocks to on a CPU with the
|
|
441
|
+
SHA instructions (`NISH_SHA256=soft` keeps the portable path),
|
|
442
|
+
`runtime-chacha20.c` the ChaCha20 keystream `nish/crypto/chacha20poly1305`
|
|
443
|
+
hands a message of 256 bytes or more to on a CPU with AVX2 or NEON
|
|
444
|
+
(`NISH_CHACHA20=soft` keeps the portable path), `runtime-term.c` the stdin
|
|
445
|
+
reads and terminal calls of `nish:term`, `runtime-bytes.c` the byte-class runs
|
|
446
|
+
of `nish/bytes`, which `nish/json` steps over, `runtime-checksum.c` the CRC-32
|
|
447
|
+
kernels of `nish/compress/checksum`, `runtime-sandbox.c` the confinement a
|
|
448
|
+
`--sandbox` build applies, and `runtime-shm.c` the shared-memory regions of
|
|
449
|
+
`nish/sync/shm`. They are separate so that each carries its own measured size
|
|
450
|
+
ceiling
|
|
451
|
+
([docs/wp7-runtime.md](https://github.com/amritk/nish/blob/main/docs/wp7-runtime.md));
|
|
452
|
+
nothing in the core calls into the others, so a line that names only
|
|
453
|
+
`runtime.c` and `runtime-os.c` still links a program that uses none of the
|
|
454
|
+
other nine.
|
|
455
|
+
|
|
456
|
+
`scripts/build.sh` compiles the other
|
|
443
457
|
nine beside any
|
|
444
458
|
`runtime.c` it is handed, so a build that goes through it — every `--link`,
|
|
445
459
|
and every `--profile` recipe in these documents — needs to name only the one.
|
|
@@ -468,19 +482,19 @@ The seed builds stage1, stage1 builds stage2, and stage2 is installed as
|
|
|
468
482
|
own IR is only reported beside them, because a codegen change since the
|
|
469
483
|
release is expected to move it. `--stages 1` stops one link sooner.
|
|
470
484
|
|
|
471
|
-
`build/nish` is then the compiler you run: it takes the same `-o`, `--link`
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
`
|
|
480
|
-
`
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
485
|
+
`build/nish` is then the compiler you run: it takes the same `-o`, `--link` and
|
|
486
|
+
`--profile` spellings as an installed `nish`, because it is the same program,
|
|
487
|
+
and makes every directory in the way of the IR, a sidecar or the binary itself.
|
|
488
|
+
It looks for `scripts/build.sh` and the `runtime/*.c` files one level up from
|
|
489
|
+
wherever it was invoked (and one level up from the file a symbolic link to it
|
|
490
|
+
names), so it wants a checkout or an installed package around it the way `nish`
|
|
491
|
+
does. It falls back to the working directory only when the compiler itself lies
|
|
492
|
+
inside that directory, so a checkout you merely `cd` into cannot hand it a
|
|
493
|
+
`scripts/build.sh` to run. Keep `bin/nish` beside `scripts/`, `runtime/` and
|
|
494
|
+
`std/`, as every install above does, and keep that directory's parent writable
|
|
495
|
+
only by you: the package root is the parent of the compiler's directory, so a
|
|
496
|
+
compiler at `/tmp/x/nish` would trust `/tmp/scripts/build.sh` (CLI-9 in
|
|
497
|
+
[docs/security/cli.md](security/cli.md)).
|
|
484
498
|
|
|
485
499
|
Because the seed is the last release, `src/` may only *use* in its own
|
|
486
500
|
source the constructs that release compiles. A new construct is implemented
|
|
@@ -532,24 +546,24 @@ nish run hello.ts
|
|
|
532
546
|
`nish run [options] <file.ts> [args ...]` compiles the file, links it into
|
|
533
547
|
`$XDG_CACHE_HOME/nish/run` (or `~/.cache/nish/run`) when that program has not
|
|
534
548
|
been linked before, and starts it with the arguments after the file. The first
|
|
535
|
-
run of a new edit pays for one link, and later runs start the cached binary.
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
549
|
+
run of a new edit pays for one link, and later runs start the cached binary. It
|
|
550
|
+
needs clang only for that link. It needs `HOME` or `XDG_CACHE_HOME` set to an
|
|
551
|
+
absolute path (a relative one is ignored, as if it were unset), and refuses the
|
|
552
|
+
run without one rather than keep a binary in a shared directory. The first run
|
|
553
|
+
that builds into the cache makes its root `0700`, so no other user can plant a
|
|
554
|
+
binary in it ([docs/security/cli.md](security/cli.md)).
|
|
541
555
|
|
|
542
556
|
Every link with the debug, speed or size profile, `nish run`'s and `--link`'s
|
|
543
557
|
alike, keeps the compiled C runtime in `$XDG_CACHE_HOME/nish/runtime` (or
|
|
544
558
|
`~/.cache/nish/runtime`), one entry per profile, `-g`, `--threads`, `CC` and
|
|
545
559
|
the version that compiler reports, made `0700` the same way. The first link
|
|
546
|
-
compiles the runtime's six files at once into it, and every later link
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
560
|
+
compiles the runtime's six files at once into it, and every later link compiles
|
|
561
|
+
only the program's modules, also at once, and links against the entry: a
|
|
562
|
+
`hello.ts` debug link goes from about half a second to about a tenth. `--link`
|
|
563
|
+
with no absolute `HOME` or `XDG_CACHE_HOME`, or with a root it cannot make
|
|
564
|
+
private, compiles the runtime itself as it always did; the wasi profile and
|
|
565
|
+
`scripts/build.sh` called directly never use the cache. Removing the directory
|
|
566
|
+
is always safe.
|
|
553
567
|
|
|
554
568
|
<a id="4-exit-codes" style="scroll-margin-top: 65px"></a>
|
|
555
569
|
|
package/bin/nish
CHANGED
|
Binary file
|
package/docs/AI.md
CHANGED
|
@@ -1480,6 +1480,13 @@ export const main = (): i32 => {
|
|
|
1480
1480
|
```
|
|
1481
1481
|
|
|
1482
1482
|
- **No body, and it cannot be `export`ed.**
|
|
1483
|
+
- **Not in a `--target wasm32` build, nor an `--emit-dts` one with no
|
|
1484
|
+
`--target`** (NL2666; `--target wasm32-wasi` keeps it): there a function the page
|
|
1485
|
+
supplies is imported from a host module, the page's own TypeScript file
|
|
1486
|
+
named by `--host`, and becomes a wasm import from module `host`. Only
|
|
1487
|
+
scalars, enums, `HostHandle<"kind">` (a nominal `i32` for an object the
|
|
1488
|
+
page keeps) and buffer windows (an array, then `at: u32, n: u32`) cross; `import { Canvas, fill } from "./host.ts"`, no `type`
|
|
1489
|
+
modifier.
|
|
1483
1490
|
- **A class with a `CPtr` field is a handle class: open one with `using`.**
|
|
1484
1491
|
`using f = new File(p)` closes `f` once at every exit of its block (falling
|
|
1485
1492
|
off the end, `return`, `break`, `continue`, `orReturn()`), so never call the
|
|
@@ -1513,12 +1520,51 @@ emitted and no initialiser runs** — every use lowers to the value itself.
|
|
|
1513
1520
|
array, class or interface constant would need an allocation, and there is no
|
|
1514
1521
|
code to run it.
|
|
1515
1522
|
- The initialiser is literals, other constants (declared anywhere, or
|
|
1516
|
-
imported), and arithmetic over them. A call, a
|
|
1517
|
-
|
|
1523
|
+
imported), and arithmetic over them. A call, a local — anything else — is
|
|
1524
|
+
rejected. The one `new` allowed is module storage, below.
|
|
1518
1525
|
- Folding uses the language's own arithmetic, so an overflowing fold is an
|
|
1519
1526
|
error rather than a wrap, and `1 / 0` in a constant is refused at compile
|
|
1520
1527
|
time.
|
|
1521
1528
|
|
|
1529
|
+
### Module storage
|
|
1530
|
+
|
|
1531
|
+
```ts nish:ok
|
|
1532
|
+
const SCORES = new Int32Array(4);
|
|
1533
|
+
|
|
1534
|
+
const sum = (xs: Int32Array): i32 => {
|
|
1535
|
+
let total: i32 = 0;
|
|
1536
|
+
for (let i = 0; i < xs.length; i++) {
|
|
1537
|
+
total += xs[i];
|
|
1538
|
+
}
|
|
1539
|
+
return total;
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
export const main = (): i32 => {
|
|
1543
|
+
SCORES[0] = 30;
|
|
1544
|
+
SCORES[3] = 4;
|
|
1545
|
+
console.log(`${sum(SCORES)} ${SCORES[1]}`); // 34 0
|
|
1546
|
+
return 0;
|
|
1547
|
+
};
|
|
1548
|
+
```
|
|
1549
|
+
|
|
1550
|
+
A top-level `const` holding `new Array<T>(n)` or a typed-array `new` of a
|
|
1551
|
+
constant length is **module storage**: a static, zero-filled array that keeps
|
|
1552
|
+
its values between calls, with no initialiser that runs. It is the only
|
|
1553
|
+
state a module keeps (there is no top-level `let`).
|
|
1554
|
+
|
|
1555
|
+
- The length is a constant from 1 to 16,777,216, at most 256 MiB in all. The element is pointer-free:
|
|
1556
|
+
a number, `boolean`, an enum or range whose zero is a member, a
|
|
1557
|
+
`HostHandle`, or an interface no class implements with fields of those.
|
|
1558
|
+
- **It never grows or moves**: no method call on it (`push`, `pop`, `sort`,
|
|
1559
|
+
NL2688) and no `length =`. Keep a count beside it.
|
|
1560
|
+
- **Its name is a place, not a value**: index it and read `length`; never bind,
|
|
1561
|
+
store or return it. Lend it only to a parameter spelled with a typed-array
|
|
1562
|
+
name (`xs: Int32Array`) or to a host function's buffer window. A record
|
|
1563
|
+
element is a place too: `bodies[i].x = 1` and `bodies[i] = bodies[j]` are
|
|
1564
|
+
fine, `const b = bodies[i]` is refused; pass the index.
|
|
1565
|
+
- Under `--profile wasm-host` the page reads and writes it through `layout`
|
|
1566
|
+
and `views()` in the `.d.ts`. The rules: `LANGUAGE.md` → "Module storage".
|
|
1567
|
+
|
|
1522
1568
|
### Classes and interfaces
|
|
1523
1569
|
|
|
1524
1570
|
```ts nish:ok
|
|
@@ -3019,8 +3065,8 @@ export const first = (xs: i32[]): i32 => uncheckedGet(xs, 0);
|
|
|
3019
3065
|
A package that must not touch the network says so in `package.json`,
|
|
3020
3066
|
`"nish": { "capabilities": { "deny": ["net"] } }`, and `--deny net` or an
|
|
3021
3067
|
allowlist such as `--allow fs.read,exit` says the same on the command line.
|
|
3022
|
-
The `"nish"` field holds `noPanic` and `
|
|
3023
|
-
written once; anything more is refused (NL3036) rather than skipped. A
|
|
3068
|
+
The `"nish"` field holds `noPanic`, `capabilities` and `host` and nothing
|
|
3069
|
+
else, each written once; anything more is refused (NL3036) rather than skipped. A
|
|
3024
3070
|
program whose `main` — or, in a library or a header build, any export —
|
|
3025
3071
|
reaches more is refused (NL2459), spanned at the first call and naming the
|
|
3026
3072
|
whole chain to the builtin; nothing changes in a program
|
package/package.json
CHANGED
package/runtime/async.d.mts
CHANGED
|
@@ -45,5 +45,7 @@ export declare function awaitAll<A, B, C, D, E, F, G, H>(
|
|
|
45
45
|
g: Promise<G>,
|
|
46
46
|
h: Promise<H>,
|
|
47
47
|
): Promise<[A, B, C, D, E, F, G, H]>;
|
|
48
|
+
/** `true` once `ms` milliseconds have passed; `false` at once for a negative `ms`. */
|
|
49
|
+
export declare function sleep(ms: number): Promise<boolean>;
|
|
48
50
|
/** Waits for every task `spawn` started, the tasks those tasks start included. */
|
|
49
51
|
export declare function settleTasks(): Promise<void>;
|
package/runtime/async.mjs
CHANGED
|
@@ -19,6 +19,13 @@ export const spawn = (task) => {
|
|
|
19
19
|
|
|
20
20
|
export const awaitAll = (...tasks) => Promise.all(tasks);
|
|
21
21
|
|
|
22
|
+
// `sleep` is a timer: `true` once `ms` milliseconds have passed, `false` for a
|
|
23
|
+
// negative `ms`, as natively. `readable` and `writable` have no counterpart in
|
|
24
|
+
// Node, whose descriptors are not polled from JavaScript, so `--emit-ts`
|
|
25
|
+
// refuses them (NL4017) and this file does not export them.
|
|
26
|
+
export const sleep = (ms) =>
|
|
27
|
+
ms < 0 ? Promise.resolve(false) : new Promise((resolve) => setTimeout(() => resolve(true), ms));
|
|
28
|
+
|
|
22
29
|
export const settleTasks = async () => {
|
|
23
30
|
for (let i = 0; i < pending.length; i++) {
|
|
24
31
|
await pending[i];
|