functionalscript 0.35.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/fs/base64/module.f.js +6 -5
- package/fs/base64/proof.f.d.ts +1 -0
- package/fs/base64/proof.f.js +10 -1
- package/fs/cas/mcp/module.f.d.ts +8 -4
- package/fs/cas/mcp/module.f.js +33 -21
- package/fs/cas/mcp/proof.f.d.ts +0 -7
- package/fs/cas/mcp/proof.f.js +47 -139
- package/fs/cas/module.f.js +3 -10
- package/fs/ci/config/module.f.d.ts +7 -7
- package/fs/ci/config/module.f.js +8 -8
- package/fs/crypto/sha2/module.f.js +20 -19
- package/fs/crypto/sha2/proof.f.d.ts +1 -0
- package/fs/crypto/sha2/proof.f.js +18 -0
- package/fs/djs/parser/proof.f.js +12 -0
- package/fs/effects/module.f.d.ts +15 -0
- package/fs/effects/module.f.js +14 -0
- package/fs/effects/node/module.f.js +5 -15
- package/fs/effects/node/module.js +3 -1
- package/fs/effects/node/proof.f.d.ts +3 -0
- package/fs/effects/node/proof.f.js +19 -1
- package/fs/effects/node/virtual/module.f.js +1 -2
- package/fs/effects/proof.f.d.ts +5 -0
- package/fs/effects/proof.f.js +22 -1
- package/fs/fjs/proof.f.d.ts +1 -0
- package/fs/fjs/proof.f.js +6 -0
- package/fs/fsc/module.f.d.ts +1 -0
- package/fs/fsc/module.f.js +5 -1
- package/fs/js/tokenizer/module.f.d.ts +1 -1
- package/fs/js/tokenizer/module.f.js +7 -1
- package/fs/js/tokenizer/proof.f.js +59 -0
- package/fs/json/parser/proof.f.js +18 -0
- package/fs/path/module.f.d.ts +6 -0
- package/fs/path/module.f.js +6 -0
- package/fs/path/proof.f.d.ts +1 -0
- package/fs/path/proof.f.js +40 -2
- package/fs/text/utf8/module.f.d.ts +6 -0
- package/fs/text/utf8/module.f.js +15 -2
- package/fs/text/utf8/proof.f.js +53 -0
- package/fs/types/result/module.f.d.ts +4 -0
- package/fs/types/result/module.f.js +4 -0
- package/fs/types/result/proof.f.d.ts +1 -0
- package/fs/types/result/proof.f.js +12 -2
- package/package.json +1 -1
package/fs/text/utf8/proof.f.js
CHANGED
|
@@ -65,6 +65,45 @@ export const proof = {
|
|
|
65
65
|
if (result !== '[-2147448800,-2147432416]') {
|
|
66
66
|
throw result;
|
|
67
67
|
}
|
|
68
|
+
},
|
|
69
|
+
// Overlong 3-byte encodings (E0 80..9F ..) are rejected, not decoded.
|
|
70
|
+
() => {
|
|
71
|
+
const result = stringify(toArray(toCodePointList([224, 128, 128])));
|
|
72
|
+
if (result !== '[-2147483424,-2147483520,-2147483520]') {
|
|
73
|
+
throw result;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
() => {
|
|
77
|
+
const result = stringify(toArray(toCodePointList([224, 159, 191])));
|
|
78
|
+
if (result !== '[-2147483424,-2147483489,-2147483457]') {
|
|
79
|
+
throw result;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
// Overlong 4-byte encodings (F0 80..8F .. ..) are rejected, not decoded.
|
|
83
|
+
() => {
|
|
84
|
+
const result = stringify(toArray(toCodePointList([240, 128, 128, 128])));
|
|
85
|
+
if (result !== '[-2147483408,-2147483520,-2147483520,-2147483520]') {
|
|
86
|
+
throw result;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
() => {
|
|
90
|
+
const result = stringify(toArray(toCodePointList([240, 143, 191, 191])));
|
|
91
|
+
if (result !== '[-2147483408,-2147483505,-2147483457,-2147483457]') {
|
|
92
|
+
throw result;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
// Valid boundary cases still decode: E0 A0 80 -> U+0800, F0 90 80 80 -> U+10000.
|
|
96
|
+
() => {
|
|
97
|
+
const result = stringify(toArray(toCodePointList([224, 160, 128])));
|
|
98
|
+
if (result !== '[2048]') {
|
|
99
|
+
throw result;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
() => {
|
|
103
|
+
const result = stringify(toArray(toCodePointList([240, 144, 128, 128])));
|
|
104
|
+
if (result !== '[65536]') {
|
|
105
|
+
throw result;
|
|
106
|
+
}
|
|
68
107
|
}
|
|
69
108
|
],
|
|
70
109
|
fromCodePointList: [
|
|
@@ -229,5 +268,19 @@ export const proof = {
|
|
|
229
268
|
throw 'expected empty string';
|
|
230
269
|
}
|
|
231
270
|
},
|
|
271
|
+
// Overlong 3-byte encoding (E0 80 80, would decode to U+0000) → null
|
|
272
|
+
() => {
|
|
273
|
+
const v = u8ListToVec(msb)([0xe0, 0x80, 0x80]);
|
|
274
|
+
if (fromVec(v) !== null) {
|
|
275
|
+
throw 'expected null for overlong 3-byte encoding';
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
// Overlong 4-byte encoding (F0 80 80 80, would decode to U+0000) → null
|
|
279
|
+
() => {
|
|
280
|
+
const v = u8ListToVec(msb)([0xf0, 0x80, 0x80, 0x80]);
|
|
281
|
+
if (fromVec(v) !== null) {
|
|
282
|
+
throw 'expected null for overlong 4-byte encoding';
|
|
283
|
+
}
|
|
284
|
+
},
|
|
232
285
|
]
|
|
233
286
|
};
|
|
@@ -55,3 +55,7 @@ export declare const unwrap: <T, E>([kind, v]: Result<T, E>) => T;
|
|
|
55
55
|
* Swaps the `ok` and `error` cases of a result.
|
|
56
56
|
*/
|
|
57
57
|
export declare const invert: <T, E>([k, v]: Result<T, E>) => Result<E, T>;
|
|
58
|
+
/**
|
|
59
|
+
* Maps the `ok` case of a result, passing an `error` through unchanged.
|
|
60
|
+
*/
|
|
61
|
+
export declare const mapOk: <T, R>(f: (value: T) => R) => <E>(r: Result<T, E>) => Result<R, E>;
|
|
@@ -48,3 +48,7 @@ export const unwrap = ([kind, v]) => {
|
|
|
48
48
|
* Swaps the `ok` and `error` cases of a result.
|
|
49
49
|
*/
|
|
50
50
|
export const invert = ([k, v]) => k === 'ok' ? error(v) : ok(v);
|
|
51
|
+
/**
|
|
52
|
+
* Maps the `ok` case of a result, passing an `error` through unchanged.
|
|
53
|
+
*/
|
|
54
|
+
export const mapOk = (f) => (r) => r[0] === 'ok' ? ok(f(r[1])) : r;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { error, ok, unwrap, invert } from "./module.f.js";
|
|
1
|
+
import { error, ok, unwrap, invert, mapOk } from "./module.f.js";
|
|
2
2
|
const example = () => {
|
|
3
3
|
const success = ok(42);
|
|
4
4
|
const failure = error('Something went wrong');
|
|
@@ -39,4 +39,14 @@ const unwrapError = () => {
|
|
|
39
39
|
throw 'expected throw';
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
const mapOkTest = () => {
|
|
43
|
+
const [k0, v0] = mapOk((n) => n + 1)(ok(41));
|
|
44
|
+
if (k0 !== 'ok' || v0 !== 42) {
|
|
45
|
+
throw [k0, v0];
|
|
46
|
+
}
|
|
47
|
+
const [k1, v1] = mapOk((n) => n + 1)(error('oops'));
|
|
48
|
+
if (k1 !== 'error' || v1 !== 'oops') {
|
|
49
|
+
throw [k1, v1];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const proof = { example, invertTest, unwrapError, mapOkTest };
|