@elaraai/east 1.0.61 → 1.0.63
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/dist/src/comparison.d.ts +16 -1
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +42 -16
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +69 -64
- package/dist/src/compile.js.map +1 -1
- package/dist/src/expr/blob.d.ts +3 -1
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +3 -1
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/regex_validation.d.ts +0 -1
- package/dist/src/expr/regex_validation.d.ts.map +1 -1
- package/dist/src/expr/regex_validation.js +0 -40
- package/dist/src/expr/regex_validation.js.map +1 -1
- package/dist/src/frozen.d.ts +41 -0
- package/dist/src/frozen.d.ts.map +1 -0
- package/dist/src/frozen.js +70 -0
- package/dist/src/frozen.js.map +1 -0
- package/dist/src/fuzz.d.ts +9 -0
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +63 -40
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/patch/diff.js +3 -3
- package/dist/src/patch/diff.js.map +1 -1
- package/dist/src/patch/fuzz.d.ts +5 -0
- package/dist/src/patch/fuzz.d.ts.map +1 -1
- package/dist/src/patch/fuzz.js +5 -1
- package/dist/src/patch/fuzz.js.map +1 -1
- package/dist/src/serialization/beast2/index.d.ts +1 -1
- package/dist/src/serialization/beast2/index.d.ts.map +1 -1
- package/dist/src/serialization/beast2/index.js.map +1 -1
- package/dist/src/serialization/beast2/shared.d.ts +7 -0
- package/dist/src/serialization/beast2/shared.d.ts.map +1 -1
- package/dist/src/serialization/beast2/shared.js.map +1 -1
- package/dist/src/serialization/beast2/v4/container.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v4/container.js +79 -40
- package/dist/src/serialization/beast2/v4/container.js.map +1 -1
- package/dist/src/serialization/beast2/v5/codec.d.ts +5 -0
- package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/codec.js +82 -38
- package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.d.ts +24 -2
- package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.js +107 -14
- package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.js +9 -3
- package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
- package/dist/src/serialization/csv.d.ts +12 -2
- package/dist/src/serialization/csv.d.ts.map +1 -1
- package/dist/src/serialization/csv.js +31 -1
- package/dist/src/serialization/csv.js.map +1 -1
- package/dist/src/serialization/csv.spec.js +80 -0
- package/dist/src/serialization/csv.spec.js.map +1 -1
- package/dist/src/serialization/east.d.ts +11 -2
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +15 -6
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/index.d.ts +1 -1
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +13 -4
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/serialization/json.spec.js +8 -6
- package/dist/src/serialization/json.spec.js.map +1 -1
- package/package.json +1 -1
package/dist/src/expr/blob.d.ts
CHANGED
|
@@ -162,7 +162,9 @@ export declare class BlobExpr extends Expr<BlobType> {
|
|
|
162
162
|
* column is an error. For defensive ingestion, `defaults` maps column
|
|
163
163
|
* names to CSV-text fallback values applied when a present field fails to
|
|
164
164
|
* decode or a column is absent from the header (constant-fill), e.g.
|
|
165
|
-
* `defaults: new Map([["price", "0.0"]])
|
|
165
|
+
* `defaults: new Map([["price", "0.0"]])`, and `skipShortRows: true` drops
|
|
166
|
+
* ragged rows with too few fields for the required columns instead of
|
|
167
|
+
* erroring.
|
|
166
168
|
*
|
|
167
169
|
* @example
|
|
168
170
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../../src/expr/blob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAsC,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhH,OAAO,EAAa,IAAI,EAAiB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAA8C,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,QAAS,SAAQ,IAAI,CAAC,QAAQ,CAAC;gBAC9B,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM;IAIxC;;;;;;;;;;;;;;;OAeG;IACH,IAAI,IAAI,WAAW;IAWnB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,WAAW;IAanD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAU,IAAI,UAAU;IAWxB;;;;;;;;;;;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;;;;;;;;;OAmBG;IACH,WAAW,IAAI,UAAU;IAWzB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,WAAW,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,IAAI,GAAG,IAAW,GAAG,QAAQ,CAAC,CAAC,CAAC;IAwBlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC;IAevF;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW;IAIjD;;;;;;;;;;;;;;;;;OAiBG;IACH,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW;IAQpD,+BAA+B;IAC/B,EAAE,UA/BY,QAAQ,GAAG,UAAU,KAAG,WAAW,CA+BhC;IACjB,+BAA+B;IAC/B,KAAK,UAjCS,QAAQ,GAAG,UAAU,KAAG,WAAW,CAiC7B;IAEpB,kCAAkC;IAClC,EAAE,UAde,QAAQ,GAAG,UAAU,KAAG,WAAW,CAchC;IACpB,kCAAkC;IAClC,QAAQ,UAhBS,QAAQ,GAAG,UAAU,KAAG,WAAW,CAgB1B;CAC3B"}
|
package/dist/src/expr/blob.js
CHANGED
|
@@ -218,7 +218,9 @@ export class BlobExpr extends Expr {
|
|
|
218
218
|
* column is an error. For defensive ingestion, `defaults` maps column
|
|
219
219
|
* names to CSV-text fallback values applied when a present field fails to
|
|
220
220
|
* decode or a column is absent from the header (constant-fill), e.g.
|
|
221
|
-
* `defaults: new Map([["price", "0.0"]])
|
|
221
|
+
* `defaults: new Map([["price", "0.0"]])`, and `skipShortRows: true` drops
|
|
222
|
+
* ragged rows with too few fields for the required columns instead of
|
|
223
|
+
* erroring.
|
|
222
224
|
*
|
|
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AAO,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,SAAS,CAAC,KAA4B;QACpC,OAAO,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,+EAA+E;IAC/E,oCAAoC;IACpC,+EAA+E;IAE/E,+BAA+B;IAC/B,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;IACjB,+BAA+B;IAC/B,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IAEpB,kCAAkC;IAClC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;IACpB,kCAAkC;IAClC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;CAC3B"}
|
|
@@ -8,7 +8,6 @@ interface ValidationResult {
|
|
|
8
8
|
errors: string[];
|
|
9
9
|
}
|
|
10
10
|
export declare function validateCrossPlatformCompatible(regex: RegExp): ValidationResult;
|
|
11
|
-
export declare function runCompatibilityTests(): void;
|
|
12
11
|
export declare const RECOMMENDED_PATTERNS: {
|
|
13
12
|
email: RegExp;
|
|
14
13
|
phoneUS: RegExp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regex_validation.d.ts","sourceRoot":"","sources":["../../../src/expr/regex_validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAkB/E;AAqED,
|
|
1
|
+
{"version":3,"file":"regex_validation.d.ts","sourceRoot":"","sources":["../../../src/expr/regex_validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAkB/E;AAqED,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAWhC,CAAC"}
|
|
@@ -74,43 +74,6 @@ function validatePattern(pattern, result) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
// Example usage and test cases
|
|
78
|
-
export function runCompatibilityTests() {
|
|
79
|
-
console.log("=== Cross-Platform RegExp Validation Tests ===\n");
|
|
80
|
-
const testCases = [
|
|
81
|
-
// ✅ Safe cross-platform patterns
|
|
82
|
-
{ name: "Basic word pattern", regex: /\w+/, expectedValid: true },
|
|
83
|
-
{ name: "Email pattern", regex: /\w+@\w+\.\w+/, expectedValid: true },
|
|
84
|
-
{ name: "Case insensitive", regex: /hello/i, expectedValid: true },
|
|
85
|
-
{ name: "Multiline mode", regex: /^test$/m, expectedValid: true },
|
|
86
|
-
{ name: "Dotall mode", regex: /a.*b/s, expectedValid: true },
|
|
87
|
-
{ name: "Character class", regex: /[a-z0-9]+/i, expectedValid: true },
|
|
88
|
-
{ name: "Anchors", regex: /^start.*end$/, expectedValid: true },
|
|
89
|
-
{ name: "Groups and alternation", regex: /(cat|dog)/, expectedValid: true },
|
|
90
|
-
{ name: "Quantifiers", regex: /a{2,5}b*c+d?/, expectedValid: true },
|
|
91
|
-
// ⚠️ Problematic patterns
|
|
92
|
-
{ name: "Global flag", regex: /test/g, expectedValid: false }, // Has warnings
|
|
93
|
-
{ name: "Unicode flag", regex: /test/u, expectedValid: false },
|
|
94
|
-
{ name: "Sticky flag", regex: /test/y, expectedValid: false },
|
|
95
|
-
// ❌ JavaScript-only features
|
|
96
|
-
{ name: "Named backreference", regex: /(?<name>\w+)\k<name>/, expectedValid: false },
|
|
97
|
-
{ name: "Unicode property", regex: /\p{Letter}/u, expectedValid: false },
|
|
98
|
-
];
|
|
99
|
-
for (const testCase of testCases) {
|
|
100
|
-
const result = validateCrossPlatformCompatible(testCase.regex);
|
|
101
|
-
const status = result.isValid ? "✅" : "❌";
|
|
102
|
-
const expected = testCase.expectedValid ? "should pass" : "should fail";
|
|
103
|
-
console.log(`${status} ${testCase.name} (${expected})`);
|
|
104
|
-
console.log(` Pattern: ${testCase.regex}`);
|
|
105
|
-
if (result.errors.length > 0) {
|
|
106
|
-
console.log(` Errors: ${result.errors.join(", ")}`);
|
|
107
|
-
}
|
|
108
|
-
if (result.warnings.length > 0) {
|
|
109
|
-
console.log(` Warnings: ${result.warnings.join(", ")}`);
|
|
110
|
-
}
|
|
111
|
-
console.log();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
77
|
// Recommended patterns that work well across different regex backends
|
|
115
78
|
export const RECOMMENDED_PATTERNS = {
|
|
116
79
|
email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
|
|
@@ -124,7 +87,4 @@ export const RECOMMENDED_PATTERNS = {
|
|
|
124
87
|
word: /\b\w+\b/,
|
|
125
88
|
lineBreak: /\r?\n/
|
|
126
89
|
};
|
|
127
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
128
|
-
runCompatibilityTests();
|
|
129
|
-
}
|
|
130
90
|
//# sourceMappingURL=regex_validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regex_validation.js","sourceRoot":"","sources":["../../../src/expr/regex_validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,UAAU,+BAA+B,CAAC,KAAa;IAC3D,MAAM,MAAM,GAAqB;QAC/B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAE1B,4BAA4B;IAC5B,aAAa,CAAC,KAAK,EA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AAE,CAAC;QACvC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,MAAM,QAAQ,GAAG;QACf,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,2EAA2E,EAAE;QACxG,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,8EAA8E,EAAE;QAC5G,EAAE,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE,iEAAiE,EAAE;KAC7G,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,kDAAkD;IACzD,OAAO,EAAE,2BAA2B;IACpC,IAAI,EAAE,iEAAiE;IACvE,IAAI,EAAE,uFAAuF;IAC7F,GAAG,EAAE,6EAA6E;IAClF,UAAU,EAAE,0BAA0B;IACtC,MAAM,EAAE,gCAAgC;IACxC,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,OAAO;CACnB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Brands a value as frozen in the registry.
|
|
7
|
+
*
|
|
8
|
+
* Used by the frozen decode paths for values `Object.freeze` cannot brand
|
|
9
|
+
* (typed arrays, lazy pager-backed collections). Non-objects pass through
|
|
10
|
+
* untouched.
|
|
11
|
+
*
|
|
12
|
+
* @param value - the value to brand
|
|
13
|
+
* @returns the same value
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function markFrozen<T>(value: T): T;
|
|
17
|
+
/**
|
|
18
|
+
* Tests whether a value is a frozen East value.
|
|
19
|
+
*
|
|
20
|
+
* A value is frozen when a frozen decode/parse constructed it — either
|
|
21
|
+
* branded with `Object.freeze` or recorded in the frozen registry (typed
|
|
22
|
+
* arrays and lazy pager-backed collections, which cannot be `Object.freeze`d).
|
|
23
|
+
* Host code may also `Object.freeze` a container itself; such a container is
|
|
24
|
+
* treated as frozen too, since it is equally immutable.
|
|
25
|
+
*
|
|
26
|
+
* Frozen `Array`/`Set`/`Dict`/`Vector`/`Matrix` values are value types:
|
|
27
|
+
* `Is` compares two frozen operands by deep value equality (the `Blob`
|
|
28
|
+
* precedent), and every mutating builtin throws.
|
|
29
|
+
*
|
|
30
|
+
* @param value - the value to test
|
|
31
|
+
* @returns `true` when the value is frozen
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const decoded = decodeBeast2For(ArrayType(IntegerType), { frozen: true })(blob);
|
|
36
|
+
* isFrozenValue(decoded); // true
|
|
37
|
+
* isFrozenValue([1n]); // false
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function isFrozenValue(value: unknown): boolean;
|
|
41
|
+
//# sourceMappingURL=frozen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frozen.d.ts","sourceRoot":"","sources":["../../src/frozen.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0BH;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAKzC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The frozen-value registry.
|
|
7
|
+
*
|
|
8
|
+
* Frozen East values are produced by the frozen decode/parse surfaces
|
|
9
|
+
* (`decodeBeast2For(type, { frozen: true })`, `parseFor(type, true)`,
|
|
10
|
+
* `fromJSONFor(type, true)`, `openBeast2LazyFor(type, { frozen: true })`) and
|
|
11
|
+
* are deeply immutable: mutating builtins throw, and frozen collections
|
|
12
|
+
* compare as value types under `Is`.
|
|
13
|
+
*
|
|
14
|
+
* Most frozen values are branded with `Object.freeze` at construction. This
|
|
15
|
+
* registry brands the ones `Object.freeze` cannot:
|
|
16
|
+
*
|
|
17
|
+
* - non-empty typed arrays (Vector values, Matrix data, Blob bytes) — the
|
|
18
|
+
* spec forbids freezing array buffer views with elements,
|
|
19
|
+
* - lazy pager-backed collections — freezing them would break their own
|
|
20
|
+
* internal hydration writes (and probing a lazy Array proxy with
|
|
21
|
+
* `Object.isFrozen` must not touch its traps).
|
|
22
|
+
*
|
|
23
|
+
* Registry membership OR `Object.isFrozen` together define frozen-ness; use
|
|
24
|
+
* {@link isFrozenValue} rather than either primitive directly.
|
|
25
|
+
*/
|
|
26
|
+
const frozenValues = new WeakSet();
|
|
27
|
+
/**
|
|
28
|
+
* Brands a value as frozen in the registry.
|
|
29
|
+
*
|
|
30
|
+
* Used by the frozen decode paths for values `Object.freeze` cannot brand
|
|
31
|
+
* (typed arrays, lazy pager-backed collections). Non-objects pass through
|
|
32
|
+
* untouched.
|
|
33
|
+
*
|
|
34
|
+
* @param value - the value to brand
|
|
35
|
+
* @returns the same value
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export function markFrozen(value) {
|
|
39
|
+
if (typeof value === "object" && value !== null) {
|
|
40
|
+
frozenValues.add(value);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Tests whether a value is a frozen East value.
|
|
46
|
+
*
|
|
47
|
+
* A value is frozen when a frozen decode/parse constructed it — either
|
|
48
|
+
* branded with `Object.freeze` or recorded in the frozen registry (typed
|
|
49
|
+
* arrays and lazy pager-backed collections, which cannot be `Object.freeze`d).
|
|
50
|
+
* Host code may also `Object.freeze` a container itself; such a container is
|
|
51
|
+
* treated as frozen too, since it is equally immutable.
|
|
52
|
+
*
|
|
53
|
+
* Frozen `Array`/`Set`/`Dict`/`Vector`/`Matrix` values are value types:
|
|
54
|
+
* `Is` compares two frozen operands by deep value equality (the `Blob`
|
|
55
|
+
* precedent), and every mutating builtin throws.
|
|
56
|
+
*
|
|
57
|
+
* @param value - the value to test
|
|
58
|
+
* @returns `true` when the value is frozen
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const decoded = decodeBeast2For(ArrayType(IntegerType), { frozen: true })(blob);
|
|
63
|
+
* isFrozenValue(decoded); // true
|
|
64
|
+
* isFrozenValue([1n]); // false
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function isFrozenValue(value) {
|
|
68
|
+
return typeof value === "object" && value !== null && (frozenValues.has(value) || Object.isFrozen(value));
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=frozen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frozen.js","sourceRoot":"","sources":["../../src/frozen.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,YAAY,GAAG,IAAI,OAAO,EAAU,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAI,KAAQ;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5G,CAAC"}
|
package/dist/src/fuzz.d.ts
CHANGED
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type EastType, type ValueTypeOf } from "./types.js";
|
|
8
8
|
import { type EastTypeValue } from "./type_of_type.js";
|
|
9
|
+
/**
|
|
10
|
+
* Reseeds the fuzz generator's deterministic random stream.
|
|
11
|
+
*
|
|
12
|
+
* Call at the start of a generation run so the produced types and values are
|
|
13
|
+
* reproducible regardless of what consumed the stream before.
|
|
14
|
+
*
|
|
15
|
+
* @param seed - the stream seed; equal seeds reproduce equal output
|
|
16
|
+
*/
|
|
17
|
+
export declare function seedFuzz(seed: number): void;
|
|
9
18
|
/**
|
|
10
19
|
* Generates a random East type for fuzz testing.
|
|
11
20
|
*
|
package/dist/src/fuzz.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzz.d.ts","sourceRoot":"","sources":["../../src/fuzz.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,WAAW,EAmBjB,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAiBxE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CACxB,KAAK,GAAE,MAAU,EACjB,OAAO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E;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,GACvE,QAAQ,CAkEV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,IAAI,QAAQ,CAmD9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,QAAQ,CAqB7C;AA+TD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,CAAC;AAC/D,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC;AAuBlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,EACrD,OAAO,GAAE,MAAY,EACrB,SAAS,GAAE,MAAW,EACtB,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,GACvE,OAAO,CAAC,OAAO,CAAC,CA4DlB"}
|
package/dist/src/fuzz.js
CHANGED
|
@@ -14,11 +14,34 @@ import { printType } from "./types.js";
|
|
|
14
14
|
import { printFor } from "./serialization/east.js";
|
|
15
15
|
import { toEastTypeValue } from "./type_of_type.js";
|
|
16
16
|
import { ref } from "./containers/ref.js";
|
|
17
|
+
/** Deterministic PRNG state (mulberry32). The fuzz output is a cross-runtime
|
|
18
|
+
* REPLAY corpus: east-c and east-py compliance and the eager-replay pins all
|
|
19
|
+
* key on the generated suite names, so generation must reproduce byte-for-byte
|
|
20
|
+
* across exports. Reseed with {@link seedFuzz}; mint a fresh corpus by bumping
|
|
21
|
+
* the seed deliberately, never by reverting to `Math.random`. */
|
|
22
|
+
let fuzzState = 0xea57 | 0;
|
|
23
|
+
function random() {
|
|
24
|
+
fuzzState = (fuzzState + 0x6d2b79f5) | 0;
|
|
25
|
+
let t = Math.imul(fuzzState ^ (fuzzState >>> 15), 1 | fuzzState);
|
|
26
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
27
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reseeds the fuzz generator's deterministic random stream.
|
|
31
|
+
*
|
|
32
|
+
* Call at the start of a generation run so the produced types and values are
|
|
33
|
+
* reproducible regardless of what consumed the stream before.
|
|
34
|
+
*
|
|
35
|
+
* @param seed - the stream seed; equal seeds reproduce equal output
|
|
36
|
+
*/
|
|
37
|
+
export function seedFuzz(seed) {
|
|
38
|
+
fuzzState = seed | 0;
|
|
39
|
+
}
|
|
17
40
|
/**
|
|
18
41
|
* Generates a random primitive East type.
|
|
19
42
|
*/
|
|
20
43
|
function randomPrimitiveType() {
|
|
21
|
-
const r =
|
|
44
|
+
const r = random() * 7;
|
|
22
45
|
if (r < 1)
|
|
23
46
|
return NullType;
|
|
24
47
|
if (r < 2)
|
|
@@ -56,7 +79,7 @@ export function randomType(depth = 0, options = {}) {
|
|
|
56
79
|
const maxDepth = 3;
|
|
57
80
|
// Higher chance of primitives at deeper levels
|
|
58
81
|
const primitiveWeight = depth >= maxDepth ? 0.9 : 0.5;
|
|
59
|
-
if (
|
|
82
|
+
if (random() < primitiveWeight) {
|
|
60
83
|
return randomPrimitiveType();
|
|
61
84
|
}
|
|
62
85
|
// Complex type - weights adjusted based on options
|
|
@@ -65,7 +88,7 @@ export function randomType(depth = 0, options = {}) {
|
|
|
65
88
|
totalWeight += 1; // Recursive only at top level
|
|
66
89
|
if (includeFunctions)
|
|
67
90
|
totalWeight += 1;
|
|
68
|
-
const r =
|
|
91
|
+
const r = random() * totalWeight;
|
|
69
92
|
if (r < 1) {
|
|
70
93
|
// Array
|
|
71
94
|
return ArrayType(randomType(depth + 1, { includeRecursive: false, includeFunctions: false }));
|
|
@@ -80,7 +103,7 @@ export function randomType(depth = 0, options = {}) {
|
|
|
80
103
|
}
|
|
81
104
|
else if (r < 4) {
|
|
82
105
|
// Struct with 0-4 fields
|
|
83
|
-
const fieldCount = Math.floor(
|
|
106
|
+
const fieldCount = Math.floor(random() * 5);
|
|
84
107
|
const fields = {};
|
|
85
108
|
for (let i = 0; i < fieldCount; i++) {
|
|
86
109
|
fields[`field${i}`] = randomType(depth + 1, { includeRecursive: false, includeFunctions: false });
|
|
@@ -89,13 +112,13 @@ export function randomType(depth = 0, options = {}) {
|
|
|
89
112
|
}
|
|
90
113
|
else if (r < 5) {
|
|
91
114
|
// Variant
|
|
92
|
-
if (
|
|
115
|
+
if (random() < 0.3) {
|
|
93
116
|
// Option type (common variant pattern)
|
|
94
117
|
return OptionType(randomType(depth + 1, { includeRecursive: false, includeFunctions: false }));
|
|
95
118
|
}
|
|
96
119
|
else {
|
|
97
120
|
// Custom variant with 1-3 cases
|
|
98
|
-
const caseCount = 1 + Math.floor(
|
|
121
|
+
const caseCount = 1 + Math.floor(random() * 3);
|
|
99
122
|
const cases = {};
|
|
100
123
|
for (let i = 0; i < caseCount; i++) {
|
|
101
124
|
cases[`case${i}`] = randomType(depth + 1, { includeRecursive: false, includeFunctions: false });
|
|
@@ -106,12 +129,12 @@ export function randomType(depth = 0, options = {}) {
|
|
|
106
129
|
else if (r < 6) {
|
|
107
130
|
// Vector with random numeric element type
|
|
108
131
|
const elemTypes = [FloatType, IntegerType, BooleanType];
|
|
109
|
-
return VectorType(elemTypes[Math.floor(
|
|
132
|
+
return VectorType(elemTypes[Math.floor(random() * elemTypes.length)]);
|
|
110
133
|
}
|
|
111
134
|
else if (r < 7) {
|
|
112
135
|
// Matrix with random numeric element type
|
|
113
136
|
const elemTypes = [FloatType, IntegerType, BooleanType];
|
|
114
|
-
return MatrixType(elemTypes[Math.floor(
|
|
137
|
+
return MatrixType(elemTypes[Math.floor(random() * elemTypes.length)]);
|
|
115
138
|
}
|
|
116
139
|
else if (r < 8 && includeRecursive && depth === 0) {
|
|
117
140
|
// Recursive type - only at top level to avoid nested recursion complexity
|
|
@@ -137,7 +160,7 @@ export function randomType(depth = 0, options = {}) {
|
|
|
137
160
|
*/
|
|
138
161
|
export function randomRecursiveType() {
|
|
139
162
|
const innerType = randomPrimitiveType();
|
|
140
|
-
const pattern = Math.floor(
|
|
163
|
+
const pattern = Math.floor(random() * 5);
|
|
141
164
|
switch (pattern) {
|
|
142
165
|
case 0:
|
|
143
166
|
// Linked list: rec t. <nil: Null, cons: (head: T, tail: t)>
|
|
@@ -182,17 +205,17 @@ export function randomRecursiveType() {
|
|
|
182
205
|
* Output types are also kept simple to avoid excessive nesting.
|
|
183
206
|
*/
|
|
184
207
|
export function randomFunctionType() {
|
|
185
|
-
const argCount = Math.floor(
|
|
208
|
+
const argCount = Math.floor(random() * 4);
|
|
186
209
|
const args = [];
|
|
187
210
|
for (let i = 0; i < argCount; i++) {
|
|
188
211
|
// Use simple types for arguments to keep things manageable
|
|
189
|
-
const argType =
|
|
212
|
+
const argType = random() < 0.7
|
|
190
213
|
? randomPrimitiveType()
|
|
191
214
|
: ArrayType(randomPrimitiveType());
|
|
192
215
|
args.push(argType);
|
|
193
216
|
}
|
|
194
217
|
// Output type - also keep simple
|
|
195
|
-
const outputType =
|
|
218
|
+
const outputType = random() < 0.7
|
|
196
219
|
? randomPrimitiveType()
|
|
197
220
|
: StructType({
|
|
198
221
|
result: randomPrimitiveType(),
|
|
@@ -244,14 +267,14 @@ function buildValueGenerator(type, ctx) {
|
|
|
244
267
|
return () => null;
|
|
245
268
|
}
|
|
246
269
|
else if (type.type === "Boolean") {
|
|
247
|
-
return () =>
|
|
270
|
+
return () => random() < 0.5;
|
|
248
271
|
}
|
|
249
272
|
else if (type.type === "Integer") {
|
|
250
|
-
return () => BigInt(Math.floor(
|
|
273
|
+
return () => BigInt(Math.floor(random() * 200) - 100);
|
|
251
274
|
}
|
|
252
275
|
else if (type.type === "Float") {
|
|
253
276
|
return () => {
|
|
254
|
-
const r =
|
|
277
|
+
const r = random();
|
|
255
278
|
if (r < 0.05)
|
|
256
279
|
return NaN;
|
|
257
280
|
if (r < 0.10)
|
|
@@ -262,30 +285,30 @@ function buildValueGenerator(type, ctx) {
|
|
|
262
285
|
return 0.0;
|
|
263
286
|
if (r < 0.25)
|
|
264
287
|
return -0.0;
|
|
265
|
-
return
|
|
288
|
+
return random() * 200 - 100;
|
|
266
289
|
};
|
|
267
290
|
}
|
|
268
291
|
else if (type.type === "String") {
|
|
269
292
|
return () => {
|
|
270
|
-
const length = Math.floor(
|
|
293
|
+
const length = Math.floor(random() * 20);
|
|
271
294
|
if (length === 0)
|
|
272
295
|
return "";
|
|
273
|
-
return
|
|
296
|
+
return random().toString(36).substring(2, 2 + length);
|
|
274
297
|
};
|
|
275
298
|
}
|
|
276
299
|
else if (type.type === "DateTime") {
|
|
277
300
|
return () => {
|
|
278
301
|
const year2025 = new Date("2025-01-01T00:00:00.000Z").valueOf();
|
|
279
302
|
const oneYear = 1000 * 60 * 60 * 24 * 365;
|
|
280
|
-
return new Date(year2025 + Math.floor(
|
|
303
|
+
return new Date(year2025 + Math.floor(random() * oneYear));
|
|
281
304
|
};
|
|
282
305
|
}
|
|
283
306
|
else if (type.type === "Blob") {
|
|
284
307
|
return () => {
|
|
285
|
-
const length = Math.floor(
|
|
308
|
+
const length = Math.floor(random() * 100);
|
|
286
309
|
const arr = new Uint8Array(length);
|
|
287
310
|
for (let i = 0; i < length; i++) {
|
|
288
|
-
arr[i] = Math.floor(
|
|
311
|
+
arr[i] = Math.floor(random() * 256);
|
|
289
312
|
}
|
|
290
313
|
return arr;
|
|
291
314
|
};
|
|
@@ -301,7 +324,7 @@ function buildValueGenerator(type, ctx) {
|
|
|
301
324
|
let itemGen;
|
|
302
325
|
const ret = (depth) => {
|
|
303
326
|
const maxLen = depth >= ctx.maxDepth ? 0 : Math.max(1, 5 - depth);
|
|
304
|
-
const length = Math.floor(
|
|
327
|
+
const length = Math.floor(random() * (maxLen + 1));
|
|
305
328
|
return Array.from({ length }, () => itemGen(depth));
|
|
306
329
|
};
|
|
307
330
|
itemGen = buildValueGenerator(type.value, ctx);
|
|
@@ -316,7 +339,7 @@ function buildValueGenerator(type, ctx) {
|
|
|
316
339
|
let itemGen;
|
|
317
340
|
const ret = (depth) => {
|
|
318
341
|
const maxLen = depth >= ctx.maxDepth ? 0 : 5;
|
|
319
|
-
const length = Math.floor(
|
|
342
|
+
const length = Math.floor(random() * (maxLen + 1));
|
|
320
343
|
const set = new SortedSet(undefined, keyComparer);
|
|
321
344
|
for (let i = 0; i < length; i++) {
|
|
322
345
|
set.add(itemGen(depth));
|
|
@@ -332,7 +355,7 @@ function buildValueGenerator(type, ctx) {
|
|
|
332
355
|
let valueGen;
|
|
333
356
|
const ret = (depth) => {
|
|
334
357
|
const maxLen = depth >= ctx.maxDepth ? 0 : 5;
|
|
335
|
-
const length = Math.floor(
|
|
358
|
+
const length = Math.floor(random() * (maxLen + 1));
|
|
336
359
|
const dict = new SortedMap(undefined, keyComparer);
|
|
337
360
|
for (let i = 0; i < length; i++) {
|
|
338
361
|
dict.set(keyGen(depth), valueGen(depth));
|
|
@@ -365,19 +388,19 @@ function buildValueGenerator(type, ctx) {
|
|
|
365
388
|
const nonTerminalCases = caseInfos.filter((c) => !c.isTerminal);
|
|
366
389
|
let chosen;
|
|
367
390
|
if (depth >= ctx.maxDepth && terminalCases.length > 0) {
|
|
368
|
-
chosen = terminalCases[Math.floor(
|
|
391
|
+
chosen = terminalCases[Math.floor(random() * terminalCases.length)];
|
|
369
392
|
}
|
|
370
393
|
else if (terminalCases.length > 0 && nonTerminalCases.length > 0) {
|
|
371
394
|
const terminalProb = Math.min(0.3 + depth * 0.2, 0.9);
|
|
372
|
-
if (
|
|
373
|
-
chosen = terminalCases[Math.floor(
|
|
395
|
+
if (random() < terminalProb) {
|
|
396
|
+
chosen = terminalCases[Math.floor(random() * terminalCases.length)];
|
|
374
397
|
}
|
|
375
398
|
else {
|
|
376
|
-
chosen = nonTerminalCases[Math.floor(
|
|
399
|
+
chosen = nonTerminalCases[Math.floor(random() * nonTerminalCases.length)];
|
|
377
400
|
}
|
|
378
401
|
}
|
|
379
402
|
else {
|
|
380
|
-
chosen = caseInfos[Math.floor(
|
|
403
|
+
chosen = caseInfos[Math.floor(random() * caseInfos.length)];
|
|
381
404
|
}
|
|
382
405
|
return variant(chosen.name, chosen.gen(depth));
|
|
383
406
|
};
|
|
@@ -425,11 +448,11 @@ function buildValueGenerator(type, ctx) {
|
|
|
425
448
|
else if (type.type === "Vector") {
|
|
426
449
|
const elemType = type.value;
|
|
427
450
|
return () => {
|
|
428
|
-
const length = Math.floor(
|
|
451
|
+
const length = Math.floor(random() * 10);
|
|
429
452
|
if (elemType.type === "Float") {
|
|
430
453
|
const arr = new Float64Array(length);
|
|
431
454
|
for (let i = 0; i < length; i++) {
|
|
432
|
-
const r =
|
|
455
|
+
const r = random();
|
|
433
456
|
if (r < 0.05)
|
|
434
457
|
arr[i] = NaN;
|
|
435
458
|
else if (r < 0.10)
|
|
@@ -437,20 +460,20 @@ function buildValueGenerator(type, ctx) {
|
|
|
437
460
|
else if (r < 0.15)
|
|
438
461
|
arr[i] = -Infinity;
|
|
439
462
|
else
|
|
440
|
-
arr[i] =
|
|
463
|
+
arr[i] = random() * 200 - 100;
|
|
441
464
|
}
|
|
442
465
|
return arr;
|
|
443
466
|
}
|
|
444
467
|
else if (elemType.type === "Integer") {
|
|
445
468
|
const arr = new BigInt64Array(length);
|
|
446
469
|
for (let i = 0; i < length; i++)
|
|
447
|
-
arr[i] = BigInt(Math.floor(
|
|
470
|
+
arr[i] = BigInt(Math.floor(random() * 200) - 100);
|
|
448
471
|
return arr;
|
|
449
472
|
}
|
|
450
473
|
else {
|
|
451
474
|
const arr = new Uint8ClampedArray(length);
|
|
452
475
|
for (let i = 0; i < length; i++)
|
|
453
|
-
arr[i] =
|
|
476
|
+
arr[i] = random() < 0.5 ? 1 : 0;
|
|
454
477
|
return arr;
|
|
455
478
|
}
|
|
456
479
|
};
|
|
@@ -458,13 +481,13 @@ function buildValueGenerator(type, ctx) {
|
|
|
458
481
|
else if (type.type === "Matrix") {
|
|
459
482
|
const elemType = type.value;
|
|
460
483
|
return () => {
|
|
461
|
-
const rows = Math.floor(
|
|
462
|
-
const cols = rows === 0 ? 0 : Math.floor(
|
|
484
|
+
const rows = Math.floor(random() * 5);
|
|
485
|
+
const cols = rows === 0 ? 0 : Math.floor(random() * 5);
|
|
463
486
|
const totalLen = rows * cols;
|
|
464
487
|
if (elemType.type === "Float") {
|
|
465
488
|
const data = new Float64Array(totalLen);
|
|
466
489
|
for (let i = 0; i < totalLen; i++) {
|
|
467
|
-
const r =
|
|
490
|
+
const r = random();
|
|
468
491
|
if (r < 0.05)
|
|
469
492
|
data[i] = NaN;
|
|
470
493
|
else if (r < 0.10)
|
|
@@ -472,20 +495,20 @@ function buildValueGenerator(type, ctx) {
|
|
|
472
495
|
else if (r < 0.15)
|
|
473
496
|
data[i] = -Infinity;
|
|
474
497
|
else
|
|
475
|
-
data[i] =
|
|
498
|
+
data[i] = random() * 200 - 100;
|
|
476
499
|
}
|
|
477
500
|
return matrix(data, rows, cols);
|
|
478
501
|
}
|
|
479
502
|
else if (elemType.type === "Integer") {
|
|
480
503
|
const data = new BigInt64Array(totalLen);
|
|
481
504
|
for (let i = 0; i < totalLen; i++)
|
|
482
|
-
data[i] = BigInt(Math.floor(
|
|
505
|
+
data[i] = BigInt(Math.floor(random() * 200) - 100);
|
|
483
506
|
return matrix(data, rows, cols);
|
|
484
507
|
}
|
|
485
508
|
else {
|
|
486
509
|
const data = new Uint8ClampedArray(totalLen);
|
|
487
510
|
for (let i = 0; i < totalLen; i++)
|
|
488
|
-
data[i] =
|
|
511
|
+
data[i] = random() < 0.5 ? 1 : 0;
|
|
489
512
|
return matrix(data, rows, cols);
|
|
490
513
|
}
|
|
491
514
|
};
|