@amritk/nish-x86_64-linux 0.27.2 → 0.29.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 +16 -8
- package/bin/nish +0 -0
- package/docs/AI.md +118 -26
- package/package.json +1 -1
- package/runtime/core/host.d.ts +2 -1
- package/runtime/core/host.mjs +4 -0
- package/runtime/core.d.ts +47 -0
- package/runtime/core.mjs +67 -0
- package/runtime/nish.d.ts +176 -0
- package/runtime/nish.h +120 -6
- package/runtime/nish.mjs +24 -4
- package/runtime/runtime-checksum.c +270 -0
- package/runtime/runtime-net.c +386 -5
- package/runtime/runtime-os.c +59 -8
- package/runtime/runtime-parallel.c +81 -5
- package/runtime/runtime-sandbox.c +479 -0
- package/runtime/runtime-sha256.c +239 -0
- package/runtime/runtime-shm.c +541 -0
- package/runtime/runtime.c +827 -791
- package/scripts/build.sh +79 -28
- package/std/README.md +25 -13
- package/std/collections.ts +5 -5
- package/std/compress/checksum.ts +88 -75
- package/std/compress/deflate.ts +224 -0
- package/std/compress/gzip.ts +52 -0
- package/std/crypto/bcrypt.ts +816 -280
- package/std/crypto/hmac.ts +305 -2
- package/std/crypto/jwt.ts +1661 -0
- package/std/json-equal.ts +335 -0
- package/std/json-format.ts +1070 -0
- package/std/json-number.ts +428 -0
- package/std/json-pointer.ts +245 -0
- package/std/json-typed.ts +34 -0
- package/std/json-value.ts +510 -17
- package/std/json.ts +35 -6
- package/std/net/handler.ts +1348 -0
- package/std/net/http-client.ts +97 -16
- package/std/net/http-compress.ts +301 -16
- package/std/net/http1-client.ts +104 -19
- package/std/net/http1-server.ts +127 -24
- package/std/net/http1.ts +24 -4
- package/std/net/outbound.ts +409 -0
- package/std/net/postgres.ts +405 -0
- package/std/net/prefork.ts +344 -20
- package/std/net/websocket.ts +295 -14
- package/std/regex.ts +613 -52
- package/std/secret.ts +1 -1
- package/std/sync/ring.ts +587 -0
- package/std/sync/shm.ts +284 -0
- package/std/term-io.ts +35 -8
- package/std/term-rate.ts +13 -1
- package/std/threads.ts +35 -3
- package/std/yaml-json.ts +841 -0
- /package/runtime/{LICENSE-ryu → LICENSE-zmij} +0 -0
package/std/json-typed.ts
CHANGED
|
@@ -54,6 +54,40 @@
|
|
|
54
54
|
* A map is emptied and filled in the input's order, and every map of one
|
|
55
55
|
* decoding takes at most `maxMapKeys` keys between them.
|
|
56
56
|
*
|
|
57
|
+
* **Which keys were given.** An optional field's missing key and a key given
|
|
58
|
+
* the field's initializer leave the same value; the `presence` option tells
|
|
59
|
+
* them apart. It names, for a field, a `boolean` field of the same class that
|
|
60
|
+
* each decoding sets to whether the input gave that field's key — true for a
|
|
61
|
+
* key given `null` too:
|
|
62
|
+
*
|
|
63
|
+
* class UserPatch {
|
|
64
|
+
* static readonly json = { optional: ["name", "email"], presence: { name: "hasName", email: "hasEmail" } };
|
|
65
|
+
* name: string = "";
|
|
66
|
+
* email: string | null = null;
|
|
67
|
+
* hasName: boolean = false;
|
|
68
|
+
* hasEmail: boolean = false;
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* Any field can be recorded, of any kind and optional or not. A presence
|
|
72
|
+
* field is off the wire: no key reads it, encoding leaves it out, and no option
|
|
73
|
+
* renames it, makes it optional or records it. It is set when the object
|
|
74
|
+
* closes, from the flag the decoder already keeps per field to find a
|
|
75
|
+
* duplicate or a missing key, so recording costs one store per recorded field
|
|
76
|
+
* and allocates nothing, and a class that records nothing compiles to the code
|
|
77
|
+
* it did before. Each object sets its own, so a nested class or an array
|
|
78
|
+
* element answers for its own keys. A decoding that fails may set some of
|
|
79
|
+
* them and not others (when the input is not an object, none), so read them
|
|
80
|
+
* only when `jsonDecode` answered `JSON_DECODE_OK`.
|
|
81
|
+
*
|
|
82
|
+
* **A merge patch (RFC 7396)** is that option's use: a patch class whose
|
|
83
|
+
* every field is optional and recorded, decoded and then applied a field at a
|
|
84
|
+
* time — a recorded key replaces its member, `null` on a `| null` field
|
|
85
|
+
* removes it, an object field is applied the same way one level down, and an
|
|
86
|
+
* array is replaced whole. `null` on a field that is not `| null` is
|
|
87
|
+
* `JSON_DECODE_TYPE`, so a patch that removes what the type cannot lose is
|
|
88
|
+
* refused before any of it is applied. `examples/merge-patch.ts` is the
|
|
89
|
+
* recipe in full.
|
|
90
|
+
*
|
|
57
91
|
* **Errors are sticky codes**, as the tokenizer's and the writer's are. The
|
|
58
92
|
* first error sets `failed` to a negative code — a `JSON_DECODE_*` code here,
|
|
59
93
|
* or the tokenizer's own `JSON_TOK_ERR_*` code when the text is not JSON or
|