@amritk/nish-aarch64-linux 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.
Files changed (128) hide show
  1. package/INSTALL.md +73 -59
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +50 -4
  4. package/package.json +1 -1
  5. package/runtime/async.d.mts +2 -0
  6. package/runtime/async.mjs +7 -0
  7. package/runtime/nish.d.ts +4849 -430
  8. package/runtime/nish.h +25 -0
  9. package/runtime/page.d.ts +53 -0
  10. package/runtime/page.mjs +146 -0
  11. package/runtime/runtime-async.c +557 -0
  12. package/runtime/runtime-wasm.c +63 -7
  13. package/runtime/vite.d.ts +30 -0
  14. package/runtime/vite.mjs +150 -0
  15. package/scripts/build.sh +252 -15
  16. package/std/README.md +107 -82
  17. package/std/base64.ts +34 -5
  18. package/std/bytes.ts +279 -59
  19. package/std/cli-args.ts +296 -70
  20. package/std/cli-flags.ts +184 -19
  21. package/std/cli.ts +475 -54
  22. package/std/collections.ts +121 -23
  23. package/std/compress/checksum.ts +44 -14
  24. package/std/compress/deflate.ts +224 -111
  25. package/std/compress/gzip.ts +217 -53
  26. package/std/compress/zlib.ts +63 -7
  27. package/std/crypto/aes.ts +128 -52
  28. package/std/crypto/base64url.ts +29 -5
  29. package/std/crypto/bcrypt-batch.ts +101 -34
  30. package/std/crypto/bcrypt.ts +93 -27
  31. package/std/crypto/chacha20poly1305.ts +69 -14
  32. package/std/crypto/ct.ts +32 -13
  33. package/std/crypto/ed25519.ts +66 -16
  34. package/std/crypto/hkdf.ts +198 -13
  35. package/std/crypto/hmac.ts +242 -37
  36. package/std/crypto/jwt.ts +204 -72
  37. package/std/crypto/p256.ts +222 -72
  38. package/std/crypto/p384.ts +51 -23
  39. package/std/crypto/pki-roots.ts +32 -2
  40. package/std/crypto/pki.ts +99 -30
  41. package/std/crypto/rsa.ts +56 -22
  42. package/std/crypto/sha1.ts +3 -0
  43. package/std/crypto/sha256.ts +24 -1
  44. package/std/crypto/sha512.ts +99 -14
  45. package/std/crypto/x25519.ts +163 -24
  46. package/std/crypto/x509-random.ts +10 -0
  47. package/std/crypto/x509.ts +133 -66
  48. package/std/host/ring.ts +124 -0
  49. package/std/json-equal.ts +31 -11
  50. package/std/json-format.ts +112 -13
  51. package/std/json-number.ts +76 -26
  52. package/std/json-pointer.ts +23 -1
  53. package/std/json-tokenizer.ts +126 -51
  54. package/std/json-typed.ts +757 -96
  55. package/std/json-value.ts +438 -157
  56. package/std/json.ts +170 -38
  57. package/std/map.ts +25 -7
  58. package/std/math.ts +36 -4
  59. package/std/net/buffer-pool.ts +42 -11
  60. package/std/net/dns-config.ts +109 -23
  61. package/std/net/dns-message.ts +62 -7
  62. package/std/net/dns-resolver.ts +247 -53
  63. package/std/net/dns.ts +203 -35
  64. package/std/net/fetch.ts +1267 -290
  65. package/std/net/handler.ts +296 -80
  66. package/std/net/hpack.ts +290 -77
  67. package/std/net/http-compress.ts +152 -36
  68. package/std/net/http-fields.ts +85 -9
  69. package/std/net/http1-client-codec.ts +129 -44
  70. package/std/net/http1-codec.ts +279 -114
  71. package/std/net/http1-server.ts +409 -139
  72. package/std/net/http2-frame.ts +289 -51
  73. package/std/net/http2-tls.ts +152 -49
  74. package/std/net/http2.ts +314 -160
  75. package/std/net/http3-frame.ts +165 -27
  76. package/std/net/http3-server.ts +282 -131
  77. package/std/net/http3.ts +377 -173
  78. package/std/net/outbound.ts +37 -3
  79. package/std/net/postgres-carrier.ts +144 -8
  80. package/std/net/postgres.ts +898 -260
  81. package/std/net/prefork.ts +202 -65
  82. package/std/net/qpack.ts +120 -32
  83. package/std/net/quic-conn-ack.ts +60 -12
  84. package/std/net/quic-conn-cid.ts +135 -27
  85. package/std/net/quic-conn-params.ts +109 -22
  86. package/std/net/quic-datagram.ts +50 -3
  87. package/std/net/quic-frame.ts +333 -23
  88. package/std/net/quic-listener.ts +161 -75
  89. package/std/net/quic-packet.ts +373 -73
  90. package/std/net/quic-recovery.ts +287 -65
  91. package/std/net/quic-stream.ts +436 -146
  92. package/std/net/quic.ts +693 -323
  93. package/std/net/router.ts +87 -40
  94. package/std/net/tls/client.ts +167 -51
  95. package/std/net/tls/codec.ts +494 -68
  96. package/std/net/tls/record-client.ts +140 -73
  97. package/std/net/tls/record-server.ts +233 -105
  98. package/std/net/tls/record.ts +142 -36
  99. package/std/net/tls/schedule.ts +235 -26
  100. package/std/net/tls/ticket.ts +161 -40
  101. package/std/net/tls/verify.ts +57 -10
  102. package/std/net/tls-tcp.ts +308 -95
  103. package/std/net/tls.ts +276 -102
  104. package/std/net/upstream.ts +81 -45
  105. package/std/net/url.ts +109 -22
  106. package/std/net/websocket.ts +140 -26
  107. package/std/net/webtransport.ts +243 -106
  108. package/std/pair.ts +10 -2
  109. package/std/random.ts +42 -15
  110. package/std/regex.ts +422 -257
  111. package/std/region.ts +70 -15
  112. package/std/secret.ts +52 -11
  113. package/std/sort.ts +17 -2
  114. package/std/sqlite.ts +256 -35
  115. package/std/sync/ring.ts +229 -56
  116. package/std/sync/shm.ts +203 -23
  117. package/std/term-io.ts +154 -78
  118. package/std/term-pixels.ts +144 -19
  119. package/std/term-probe.ts +77 -35
  120. package/std/term-rate.ts +199 -118
  121. package/std/term.ts +400 -175
  122. package/std/testing.ts +130 -32
  123. package/std/text.ts +84 -17
  124. package/std/threads.ts +248 -56
  125. package/std/yaml-json.ts +111 -97
  126. package/std/yaml-lines.ts +47 -15
  127. package/std/yaml-write.ts +45 -30
  128. 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 lexer's
5
- * `scanEscape`: where an escape ended, and whether it was malformed. Without a
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 r = new Rng(42);
8
- * const die: i32 = r.nextInt(1, 6); // 1 to 6, each with equal chance
9
- * const u: f64 = r.nextF64(); // in [0, 1)
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. Each step adds the odd constant
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
@@ -24,17 +27,19 @@
24
27
  * two's-complement wrap natively and answer `(a + b) | 0` and `Math.imul(a, b)`
25
28
  * under Node (docs/LANGUAGE.md, "nish:unsafe"); every shift has a constant
26
29
  * count, and `^` and `>>> 16` answer the same 32 bits in JavaScript as in the
27
- * compiled program. `nextInt` reads its span and its draws as unsigned
28
- * counts with no `u32` (whose conversions saturate under Node): the sign bit
29
- * flipped orders them under a signed compare, and the remainder is taken in
30
- * pieces that stay below 2^31. `nextF64` builds its double from integers
31
- * below 2^53, so its products and sums are exact both ways. The program a test prints under
32
- * Node is the one it prints compiled (docs/RUN_UNDER_NODE.md).
30
+ * compiled program.
33
31
  *
34
- * It is not for cryptography: a key or a nonce comes from
32
+ * `nextInt` reads its span and its draws as unsigned counts with no `u32`
33
+ * (whose conversions saturate under Node): the sign bit flipped orders them
34
+ * under a signed compare, and the remainder is taken in pieces that stay below
35
+ * 2^31. `nextF64` builds its double from integers below 2^53, so its products
36
+ * and sums are exact both ways. The program a test prints under Node is the one
37
+ * it prints compiled (docs/RUN_UNDER_NODE.md).
38
+ *
39
+ * **It is not for cryptography**: a key or a nonce comes from
35
40
  * `crypto.getRandomValues`.
36
41
  *
37
- * An `Rng` is an ordinary object, so a parallel body or a task that makes one
42
+ * **An `Rng` is an ordinary object**, so a parallel body or a task that makes one
38
43
  * of its own may step it as it likes: what a function allocates is its own
39
44
  * memory (docs/LANGUAGE.md, "Data parallelism"). One shared by several tasks
40
45
  * would be a write their caller can see, and is refused as any such write is;
@@ -100,14 +105,28 @@ const mix = (h: i32): i32 => {
100
105
  /** A generator of pseudo-random numbers: a Weyl sequence from its seed, each state mixed. */
101
106
  export class Rng {
102
107
  /** Where the walk is: the seed plus the increment times the steps taken, wrapped. */
103
- state: i32
108
+ private state: i32
104
109
 
105
- /** A generator whose sequence `seed` decides: two made from one seed answer the same numbers. */
110
+ /**
111
+ * A generator whose sequence `seed` decides: two made from one seed answer
112
+ * the same numbers.
113
+ *
114
+ * @param seed any `i32`, 0 and negatives included. The walk is one cycle
115
+ * of 2^32 states, so seeds are starting points on it, not separate
116
+ * sequences: `seed + k * 0x9E3779B9`, wrapped, answers the same numbers as
117
+ * `seed`, `k` steps later.
118
+ */
106
119
  constructor(seed: i32) {
107
120
  this.state = seed
108
121
  }
109
122
 
110
- /** The next 32 bits, as an `i32`: over 2^32 steps each value is answered exactly once. */
123
+ /**
124
+ * The next 32 bits, as an `i32`: over 2^32 steps each value is answered
125
+ * exactly once.
126
+ *
127
+ * @returns any `i32`, negatives included, each equally likely; the generator
128
+ * steps once.
129
+ */
111
130
  nextI32(): i32 {
112
131
  this.state = wrappingAdd(this.state, GOLDEN)
113
132
  return mix(this.state)
@@ -117,6 +136,9 @@ export class Rng {
117
136
  * The next number in [0, 1), from two steps: the high 27 bits of one and
118
137
  * the high 26 of the next make a 53-bit integer, which a double holds
119
138
  * exactly, scaled by 2^-53.
139
+ *
140
+ * @returns a multiple of 2^-53 at least 0 and below 1; the generator steps
141
+ * twice.
120
142
  */
121
143
  nextF64(): f64 {
122
144
  const hi: i32 = this.nextI32() >>> 5
@@ -136,6 +158,11 @@ export class Rng {
136
158
  * answer equally often. Fewer than half the draws are ever refused, so an
137
159
  * answer takes one `nextI32()` step usually and fewer than two on average,
138
160
  * and a sequence is still the seed's.
161
+ *
162
+ * @param lo the smallest answer allowed.
163
+ * @param hi the largest answer allowed; equal to `lo` answers `lo`, and below
164
+ * it stops the program.
165
+ * @returns an integer from `lo` to `hi` inclusive.
139
166
  */
140
167
  nextInt(lo: i32, hi: i32): i32 {
141
168
  if (lo > hi) {