@amritk/nish-x86_64-linux 0.34.1 → 0.36.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 +22 -13
- package/bin/nish +0 -0
- package/docs/AI.md +86 -16
- package/package.json +1 -1
- package/runtime/async.d.mts +49 -0
- package/runtime/async.mjs +27 -0
- package/runtime/nish.d.ts +4681 -427
- package/runtime/nish.h +6 -2
- package/runtime/nish.mjs +4 -0
- package/runtime/runtime-net.c +22 -0
- package/runtime/runtime-shm.c +93 -2
- package/runtime/vite.d.ts +30 -0
- package/runtime/vite.mjs +150 -0
- package/scripts/build.sh +108 -13
- package/std/README.md +131 -131
- package/std/base64.ts +34 -5
- package/std/bytes.ts +258 -42
- 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 +80 -9
- package/std/crypto/base64url.ts +22 -0
- package/std/crypto/bcrypt-batch.ts +88 -21
- package/std/crypto/bcrypt.ts +60 -0
- package/std/crypto/chacha20poly1305.ts +53 -0
- package/std/crypto/ct.ts +32 -13
- package/std/crypto/ed25519.ts +47 -0
- package/std/crypto/hkdf.ts +198 -13
- package/std/crypto/hmac.ts +235 -31
- package/std/crypto/jwt.ts +192 -63
- package/std/crypto/p256.ts +159 -16
- package/std/crypto/p384.ts +28 -3
- package/std/crypto/pki-roots.ts +32 -2
- package/std/crypto/pki.ts +81 -15
- package/std/crypto/rsa.ts +33 -3
- 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 +152 -14
- package/std/crypto/x509-random.ts +10 -0
- package/std/crypto/x509.ts +67 -7
- package/std/json-equal.ts +19 -0
- package/std/json-format.ts +112 -13
- package/std/json-number.ts +64 -14
- package/std/json-pointer.ts +23 -1
- package/std/json-tokenizer.ts +100 -29
- package/std/json-typed.ts +713 -66
- package/std/json-value.ts +400 -124
- package/std/json.ts +138 -10
- 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 +151 -61
- package/std/net/handler.ts +278 -80
- package/std/net/hpack.ts +262 -52
- package/std/net/http-compress.ts +125 -15
- package/std/net/http-fields.ts +85 -9
- package/std/net/http1-client-codec.ts +100 -19
- package/std/net/http1-codec.ts +297 -77
- package/std/net/http1-server.ts +430 -94
- package/std/net/http2-frame.ts +272 -35
- package/std/net/http2-tls.ts +135 -34
- package/std/net/http2.ts +247 -106
- package/std/net/http3-frame.ts +154 -17
- package/std/net/http3-server.ts +275 -101
- package/std/net/http3.ts +307 -115
- package/std/net/outbound.ts +37 -3
- package/std/net/postgres-carrier.ts +144 -8
- package/std/net/postgres.ts +801 -112
- package/std/net/prefork.ts +164 -31
- package/std/net/qpack.ts +105 -18
- package/std/net/quic-conn-ack.ts +59 -12
- package/std/net/quic-conn-cid.ts +124 -27
- package/std/net/quic-conn-params.ts +70 -10
- package/std/net/quic-datagram.ts +43 -3
- package/std/net/quic-frame.ts +286 -12
- package/std/net/quic-listener.ts +101 -32
- package/std/net/quic-packet.ts +302 -21
- package/std/net/quic-recovery.ts +264 -52
- package/std/net/quic-stream.ts +353 -91
- package/std/net/quic.ts +1124 -201
- package/std/net/router.ts +87 -40
- package/std/net/tls/client.ts +166 -51
- package/std/net/tls/codec.ts +413 -56
- package/std/net/tls/record-client.ts +110 -55
- package/std/net/tls/record-server.ts +159 -59
- package/std/net/tls/record.ts +109 -12
- package/std/net/tls/schedule.ts +235 -26
- package/std/net/tls/ticket.ts +159 -40
- package/std/net/tls/verify.ts +49 -3
- package/std/net/tls-tcp.ts +250 -45
- package/std/net/tls.ts +221 -59
- package/std/net/upstream.ts +81 -45
- package/std/net/url.ts +97 -13
- package/std/net/websocket.ts +122 -12
- package/std/net/webtransport.ts +220 -89
- package/std/pair.ts +10 -2
- package/std/random.ts +34 -9
- package/std/regex.ts +352 -198
- 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 +430 -40
- package/std/sync/shm.ts +222 -15
- package/std/term-io.ts +137 -64
- package/std/term-pixels.ts +144 -19
- package/std/term-probe.ts +66 -25
- package/std/term-rate.ts +128 -57
- package/std/term.ts +332 -121
- package/std/testing.ts +130 -32
- package/std/text.ts +73 -7
- package/std/threads.ts +229 -41
- package/std/yaml-json.ts +94 -82
- package/std/yaml-lines.ts +47 -15
- package/std/yaml-write.ts +24 -16
- package/std/yaml.ts +764 -384
package/std/pair.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `std/pair` — two values answered by one call.
|
|
3
3
|
*
|
|
4
|
-
* It exists for the function that has two things to say, like the
|
|
5
|
-
* `scanEscape
|
|
4
|
+
* It exists for the function that has two things to say, like the
|
|
5
|
+
* `scanEscape` below: where an escape ended, and whether it was malformed. Without a
|
|
6
6
|
* pair, the second answer lives in a field on some object, written by the
|
|
7
7
|
* callee and read back by the caller three lines later. With one, both come
|
|
8
8
|
* back in the return:
|
|
@@ -23,6 +23,14 @@
|
|
|
23
23
|
* compiler; `docs/wp23-language-surface.md` §5 is the argument for that.
|
|
24
24
|
*/
|
|
25
25
|
export interface Pair<A, B> {
|
|
26
|
+
/**
|
|
27
|
+
* The first of the two answers. What it means is the returning function's
|
|
28
|
+
* contract, which its own doc states.
|
|
29
|
+
*/
|
|
26
30
|
first: A
|
|
31
|
+
/**
|
|
32
|
+
* The second of the two answers, with its meaning set by the returning
|
|
33
|
+
* function as `first`'s is.
|
|
34
|
+
*/
|
|
27
35
|
second: B
|
|
28
36
|
}
|
package/std/random.ts
CHANGED
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* import { Rng } from "nish/random";
|
|
6
6
|
*
|
|
7
|
-
* const
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* export const main = (): i32 => {
|
|
8
|
+
* const r = new Rng(42);
|
|
9
|
+
* const die: i32 = r.nextInt(1, 6); // 1 to 6, each with equal chance
|
|
10
|
+
* const u: f64 = r.nextF64(); // in [0, 1)
|
|
11
|
+
* return die;
|
|
12
|
+
* };
|
|
10
13
|
*
|
|
11
|
-
* The state is one 32-bit integer
|
|
14
|
+
* **The state is one 32-bit integer.** Each step adds the odd constant
|
|
12
15
|
* 0x9E3779B9 (2^32 divided by the golden ratio) to it, wrapping, so the
|
|
13
16
|
* states walk all 2^32 values before any repeats, whatever the seed — 0
|
|
14
17
|
* included. Each answer is MurmurHash3's 32-bit finaliser applied to the new
|
|
@@ -31,10 +34,10 @@
|
|
|
31
34
|
* below 2^53, so its products and sums are exact both ways. The program a test prints under
|
|
32
35
|
* Node is the one it prints compiled (docs/RUN_UNDER_NODE.md).
|
|
33
36
|
*
|
|
34
|
-
* It is not for cryptography
|
|
37
|
+
* **It is not for cryptography**: a key or a nonce comes from
|
|
35
38
|
* `crypto.getRandomValues`.
|
|
36
39
|
*
|
|
37
|
-
* An `Rng` is an ordinary object
|
|
40
|
+
* **An `Rng` is an ordinary object**, so a parallel body or a task that makes one
|
|
38
41
|
* of its own may step it as it likes: what a function allocates is its own
|
|
39
42
|
* memory (docs/LANGUAGE.md, "Data parallelism"). One shared by several tasks
|
|
40
43
|
* would be a write their caller can see, and is refused as any such write is;
|
|
@@ -100,14 +103,28 @@ const mix = (h: i32): i32 => {
|
|
|
100
103
|
/** A generator of pseudo-random numbers: a Weyl sequence from its seed, each state mixed. */
|
|
101
104
|
export class Rng {
|
|
102
105
|
/** Where the walk is: the seed plus the increment times the steps taken, wrapped. */
|
|
103
|
-
state: i32
|
|
106
|
+
private state: i32
|
|
104
107
|
|
|
105
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* A generator whose sequence `seed` decides: two made from one seed answer
|
|
110
|
+
* the same numbers.
|
|
111
|
+
*
|
|
112
|
+
* @param seed any `i32`, 0 and negatives included. The walk is one cycle
|
|
113
|
+
* of 2^32 states, so seeds are starting points on it, not separate
|
|
114
|
+
* sequences: `seed + k * 0x9E3779B9`, wrapped, answers the same numbers as
|
|
115
|
+
* `seed`, `k` steps later.
|
|
116
|
+
*/
|
|
106
117
|
constructor(seed: i32) {
|
|
107
118
|
this.state = seed
|
|
108
119
|
}
|
|
109
120
|
|
|
110
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* The next 32 bits, as an `i32`: over 2^32 steps each value is answered
|
|
123
|
+
* exactly once.
|
|
124
|
+
*
|
|
125
|
+
* @returns any `i32`, negatives included, each equally likely; the generator
|
|
126
|
+
* steps once.
|
|
127
|
+
*/
|
|
111
128
|
nextI32(): i32 {
|
|
112
129
|
this.state = wrappingAdd(this.state, GOLDEN)
|
|
113
130
|
return mix(this.state)
|
|
@@ -117,6 +134,9 @@ export class Rng {
|
|
|
117
134
|
* The next number in [0, 1), from two steps: the high 27 bits of one and
|
|
118
135
|
* the high 26 of the next make a 53-bit integer, which a double holds
|
|
119
136
|
* exactly, scaled by 2^-53.
|
|
137
|
+
*
|
|
138
|
+
* @returns a multiple of 2^-53 at least 0 and below 1; the generator steps
|
|
139
|
+
* twice.
|
|
120
140
|
*/
|
|
121
141
|
nextF64(): f64 {
|
|
122
142
|
const hi: i32 = this.nextI32() >>> 5
|
|
@@ -136,6 +156,11 @@ export class Rng {
|
|
|
136
156
|
* answer equally often. Fewer than half the draws are ever refused, so an
|
|
137
157
|
* answer takes one `nextI32()` step usually and fewer than two on average,
|
|
138
158
|
* and a sequence is still the seed's.
|
|
159
|
+
*
|
|
160
|
+
* @param lo the smallest answer allowed.
|
|
161
|
+
* @param hi the largest answer allowed; equal to `lo` answers `lo`, and below
|
|
162
|
+
* it stops the program.
|
|
163
|
+
* @returns an integer from `lo` to `hi` inclusive.
|
|
139
164
|
*/
|
|
140
165
|
nextInt(lo: i32, hi: i32): i32 {
|
|
141
166
|
if (lo > hi) {
|