added version

This commit is contained in:
2026-02-22 12:27:05 +03:30
parent f5928601fa
commit 2edf23a065
603 changed files with 5281 additions and 4037 deletions
+13 -1
View File
@@ -5,6 +5,7 @@ import {
NEGATIVE_INFINITY,
NEGATIVE_ZERO,
POSITIVE_INFINITY,
SPARSE,
UNDEFINED
} from './constants.js';
@@ -201,6 +202,17 @@ export function unflatten(parsed, revivers) {
default:
throw new Error(`Unknown type ${type}`);
}
} else if (value[0] === SPARSE) {
// Sparse array encoding: [SPARSE, length, idx, val, idx, val, ...]
const len = value[1];
const array = new Array(len);
hydrated[index] = array;
for (let i = 2; i < value.length; i += 2) {
const idx = value[i];
array[idx] = hydrate(value[i + 1]);
}
} else {
const array = new Array(value.length);
hydrated[index] = array;
@@ -217,7 +229,7 @@ export function unflatten(parsed, revivers) {
const object = {};
hydrated[index] = object;
for (const key in value) {
for (const key of Object.keys(value)) {
if (key === '__proto__') {
throw new Error('Cannot parse an object with a `__proto__` property');
}