seroval 1.3.1 → 1.3.2
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/cjs/development/index.cjs +127 -129
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +4 -4
- package/dist/esm/development/index.mjs +127 -129
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/context/deserializer.d.ts +1 -0
- package/dist/types/core/context/deserializer.d.ts.map +1 -1
- package/dist/types/core/context/parser/async.d.ts +1 -1
- package/dist/types/core/context/parser/async.d.ts.map +1 -1
- package/dist/types/core/context/parser/sync.d.ts +1 -1
- package/dist/types/core/context/parser/sync.d.ts.map +1 -1
- package/dist/types/core/tree/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/core/context/deserializer.ts +80 -73
- package/src/core/context/parser/async.ts +19 -23
- package/src/core/context/parser/stream.ts +4 -4
- package/src/core/context/parser/sync.ts +15 -19
- package/src/core/cross/index.ts +5 -5
- package/src/core/tree/index.ts +6 -6
|
@@ -1461,7 +1461,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1461
1461
|
const nodes = [];
|
|
1462
1462
|
for (let i = 0, len = current.length; i < len; i++) {
|
|
1463
1463
|
if (i in current) {
|
|
1464
|
-
nodes[i] = await this.
|
|
1464
|
+
nodes[i] = await this.parse(current[i]);
|
|
1465
1465
|
}
|
|
1466
1466
|
}
|
|
1467
1467
|
return nodes;
|
|
@@ -1475,7 +1475,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1475
1475
|
const valueNodes = [];
|
|
1476
1476
|
for (let i = 0, len = entries.length; i < len; i++) {
|
|
1477
1477
|
keyNodes.push(serializeString(entries[i][0]));
|
|
1478
|
-
valueNodes.push(await this.
|
|
1478
|
+
valueNodes.push(await this.parse(entries[i][1]));
|
|
1479
1479
|
}
|
|
1480
1480
|
let symbol = Symbol.iterator;
|
|
1481
1481
|
if (symbol in properties) {
|
|
@@ -1483,7 +1483,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1483
1483
|
valueNodes.push(
|
|
1484
1484
|
createIteratorFactoryInstanceNode(
|
|
1485
1485
|
this.parseIteratorFactory(),
|
|
1486
|
-
await this.
|
|
1486
|
+
await this.parse(
|
|
1487
1487
|
iteratorToSequence(properties)
|
|
1488
1488
|
)
|
|
1489
1489
|
)
|
|
@@ -1495,7 +1495,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1495
1495
|
valueNodes.push(
|
|
1496
1496
|
createAsyncIteratorFactoryInstanceNode(
|
|
1497
1497
|
this.parseAsyncIteratorFactory(),
|
|
1498
|
-
await this.
|
|
1498
|
+
await this.parse(
|
|
1499
1499
|
createStreamFromAsyncIterable(
|
|
1500
1500
|
properties
|
|
1501
1501
|
)
|
|
@@ -1528,24 +1528,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1528
1528
|
);
|
|
1529
1529
|
}
|
|
1530
1530
|
async parseBoxed(id, current) {
|
|
1531
|
-
return createBoxedNode(id, await this.
|
|
1531
|
+
return createBoxedNode(id, await this.parse(current.valueOf()));
|
|
1532
1532
|
}
|
|
1533
1533
|
async parseTypedArray(id, current) {
|
|
1534
|
-
return createTypedArrayNode(
|
|
1535
|
-
id,
|
|
1536
|
-
current,
|
|
1537
|
-
await this.parseTop(current.buffer)
|
|
1538
|
-
);
|
|
1534
|
+
return createTypedArrayNode(id, current, await this.parse(current.buffer));
|
|
1539
1535
|
}
|
|
1540
1536
|
async parseBigIntTypedArray(id, current) {
|
|
1541
1537
|
return createBigIntTypedArrayNode(
|
|
1542
1538
|
id,
|
|
1543
1539
|
current,
|
|
1544
|
-
await this.
|
|
1540
|
+
await this.parse(current.buffer)
|
|
1545
1541
|
);
|
|
1546
1542
|
}
|
|
1547
1543
|
async parseDataView(id, current) {
|
|
1548
|
-
return createDataViewNode(id, current, await this.
|
|
1544
|
+
return createDataViewNode(id, current, await this.parse(current.buffer));
|
|
1549
1545
|
}
|
|
1550
1546
|
async parseError(id, current) {
|
|
1551
1547
|
const options = getErrorOptions(current, this.features);
|
|
@@ -1567,15 +1563,15 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1567
1563
|
const keyNodes = [];
|
|
1568
1564
|
const valueNodes = [];
|
|
1569
1565
|
for (const [key, value] of current.entries()) {
|
|
1570
|
-
keyNodes.push(await this.
|
|
1571
|
-
valueNodes.push(await this.
|
|
1566
|
+
keyNodes.push(await this.parse(key));
|
|
1567
|
+
valueNodes.push(await this.parse(value));
|
|
1572
1568
|
}
|
|
1573
1569
|
return this.createMapNode(id, keyNodes, valueNodes, current.size);
|
|
1574
1570
|
}
|
|
1575
1571
|
async parseSet(id, current) {
|
|
1576
1572
|
const items = [];
|
|
1577
1573
|
for (const item of current.keys()) {
|
|
1578
|
-
items.push(await this.
|
|
1574
|
+
items.push(await this.parse(item));
|
|
1579
1575
|
}
|
|
1580
1576
|
return createSetNode(id, current.size, items);
|
|
1581
1577
|
}
|
|
@@ -1591,7 +1587,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1591
1587
|
NIL,
|
|
1592
1588
|
NIL,
|
|
1593
1589
|
NIL,
|
|
1594
|
-
await this.
|
|
1590
|
+
await this.parse(result),
|
|
1595
1591
|
NIL,
|
|
1596
1592
|
NIL
|
|
1597
1593
|
);
|
|
@@ -1623,7 +1619,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1623
1619
|
const cleanup = current.on({
|
|
1624
1620
|
next: (value) => {
|
|
1625
1621
|
this.markRef(id);
|
|
1626
|
-
this.
|
|
1622
|
+
this.parse(value).then(
|
|
1627
1623
|
(data) => {
|
|
1628
1624
|
sequence.push(createStreamNextNode(id, data));
|
|
1629
1625
|
},
|
|
@@ -1635,7 +1631,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1635
1631
|
},
|
|
1636
1632
|
throw: (value) => {
|
|
1637
1633
|
this.markRef(id);
|
|
1638
|
-
this.
|
|
1634
|
+
this.parse(value).then(
|
|
1639
1635
|
(data) => {
|
|
1640
1636
|
sequence.push(createStreamThrowNode(id, data));
|
|
1641
1637
|
resolve(sequence);
|
|
@@ -1649,7 +1645,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1649
1645
|
},
|
|
1650
1646
|
return: (value) => {
|
|
1651
1647
|
this.markRef(id);
|
|
1652
|
-
this.
|
|
1648
|
+
this.parse(value).then(
|
|
1653
1649
|
(data) => {
|
|
1654
1650
|
sequence.push(createStreamReturnNode(id, data));
|
|
1655
1651
|
resolve(sequence);
|
|
@@ -1675,7 +1671,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1675
1671
|
}
|
|
1676
1672
|
const currentClass = current.constructor;
|
|
1677
1673
|
if (currentClass === OpaqueReference) {
|
|
1678
|
-
return this.
|
|
1674
|
+
return this.parse(
|
|
1679
1675
|
current.replacement
|
|
1680
1676
|
);
|
|
1681
1677
|
}
|
|
@@ -1772,7 +1768,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1772
1768
|
}
|
|
1773
1769
|
throw new SerovalUnsupportedTypeError(current);
|
|
1774
1770
|
}
|
|
1775
|
-
async
|
|
1771
|
+
async parse(current) {
|
|
1776
1772
|
switch (typeof current) {
|
|
1777
1773
|
case "boolean":
|
|
1778
1774
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
@@ -1799,9 +1795,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1799
1795
|
throw new SerovalUnsupportedTypeError(current);
|
|
1800
1796
|
}
|
|
1801
1797
|
}
|
|
1802
|
-
async
|
|
1798
|
+
async parseTop(current) {
|
|
1803
1799
|
try {
|
|
1804
|
-
return await this.
|
|
1800
|
+
return await this.parse(current);
|
|
1805
1801
|
} catch (error) {
|
|
1806
1802
|
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
1807
1803
|
}
|
|
@@ -2014,7 +2010,10 @@ var BaseDeserializerContext = class {
|
|
|
2014
2010
|
throw new SerovalMissingPluginError(node.c);
|
|
2015
2011
|
}
|
|
2016
2012
|
deserializePromiseConstructor(node) {
|
|
2017
|
-
return this.assignIndexedValue(
|
|
2013
|
+
return this.assignIndexedValue(
|
|
2014
|
+
node.i,
|
|
2015
|
+
this.assignIndexedValue(node.s, createDeferred()).promise
|
|
2016
|
+
);
|
|
2018
2017
|
}
|
|
2019
2018
|
deserializePromiseResolve(node) {
|
|
2020
2019
|
const deferred = this.refs.get(node.i);
|
|
@@ -2074,83 +2073,86 @@ var BaseDeserializerContext = class {
|
|
|
2074
2073
|
this.deserialize(node.a[1]);
|
|
2075
2074
|
return void 0;
|
|
2076
2075
|
}
|
|
2077
|
-
|
|
2076
|
+
deserializeTop(node) {
|
|
2078
2077
|
try {
|
|
2079
|
-
|
|
2080
|
-
case 2 /* Constant */:
|
|
2081
|
-
return CONSTANT_VAL[node.s];
|
|
2082
|
-
case 0 /* Number */:
|
|
2083
|
-
return node.s;
|
|
2084
|
-
case 1 /* String */:
|
|
2085
|
-
return deserializeString(node.s);
|
|
2086
|
-
case 3 /* BigInt */:
|
|
2087
|
-
return BigInt(node.s);
|
|
2088
|
-
case 4 /* IndexedValue */:
|
|
2089
|
-
return this.refs.get(node.i);
|
|
2090
|
-
case 18 /* Reference */:
|
|
2091
|
-
return this.deserializeReference(node);
|
|
2092
|
-
case 9 /* Array */:
|
|
2093
|
-
return this.deserializeArray(node);
|
|
2094
|
-
case 10 /* Object */:
|
|
2095
|
-
case 11 /* NullConstructor */:
|
|
2096
|
-
return this.deserializeObject(node);
|
|
2097
|
-
case 5 /* Date */:
|
|
2098
|
-
return this.deserializeDate(node);
|
|
2099
|
-
case 6 /* RegExp */:
|
|
2100
|
-
return this.deserializeRegExp(node);
|
|
2101
|
-
case 7 /* Set */:
|
|
2102
|
-
return this.deserializeSet(node);
|
|
2103
|
-
case 8 /* Map */:
|
|
2104
|
-
return this.deserializeMap(node);
|
|
2105
|
-
case 19 /* ArrayBuffer */:
|
|
2106
|
-
return this.deserializeArrayBuffer(node);
|
|
2107
|
-
case 16 /* BigIntTypedArray */:
|
|
2108
|
-
case 15 /* TypedArray */:
|
|
2109
|
-
return this.deserializeTypedArray(node);
|
|
2110
|
-
case 20 /* DataView */:
|
|
2111
|
-
return this.deserializeDataView(node);
|
|
2112
|
-
case 14 /* AggregateError */:
|
|
2113
|
-
return this.deserializeAggregateError(node);
|
|
2114
|
-
case 13 /* Error */:
|
|
2115
|
-
return this.deserializeError(node);
|
|
2116
|
-
case 12 /* Promise */:
|
|
2117
|
-
return this.deserializePromise(node);
|
|
2118
|
-
case 17 /* WKSymbol */:
|
|
2119
|
-
return SYMBOL_REF[node.s];
|
|
2120
|
-
case 21 /* Boxed */:
|
|
2121
|
-
return this.deserializeBoxed(node);
|
|
2122
|
-
case 25 /* Plugin */:
|
|
2123
|
-
return this.deserializePlugin(node);
|
|
2124
|
-
case 22 /* PromiseConstructor */:
|
|
2125
|
-
return this.deserializePromiseConstructor(node);
|
|
2126
|
-
case 23 /* PromiseSuccess */:
|
|
2127
|
-
return this.deserializePromiseResolve(node);
|
|
2128
|
-
case 24 /* PromiseFailure */:
|
|
2129
|
-
return this.deserializePromiseReject(node);
|
|
2130
|
-
case 28 /* IteratorFactoryInstance */:
|
|
2131
|
-
return this.deserializeIteratorFactoryInstance(node);
|
|
2132
|
-
case 30 /* AsyncIteratorFactoryInstance */:
|
|
2133
|
-
return this.deserializeAsyncIteratorFactoryInstance(node);
|
|
2134
|
-
case 31 /* StreamConstructor */:
|
|
2135
|
-
return this.deserializeStreamConstructor(node);
|
|
2136
|
-
case 32 /* StreamNext */:
|
|
2137
|
-
return this.deserializeStreamNext(node);
|
|
2138
|
-
case 33 /* StreamThrow */:
|
|
2139
|
-
return this.deserializeStreamThrow(node);
|
|
2140
|
-
case 34 /* StreamReturn */:
|
|
2141
|
-
return this.deserializeStreamReturn(node);
|
|
2142
|
-
case 27 /* IteratorFactory */:
|
|
2143
|
-
return this.deserializeIteratorFactory(node);
|
|
2144
|
-
case 29 /* AsyncIteratorFactory */:
|
|
2145
|
-
return this.deserializeAsyncIteratorFactory(node);
|
|
2146
|
-
// case SerovalNodeType.SpecialReference:
|
|
2147
|
-
default:
|
|
2148
|
-
throw new SerovalUnsupportedNodeError(node);
|
|
2149
|
-
}
|
|
2078
|
+
return this.deserialize(node);
|
|
2150
2079
|
} catch (error) {
|
|
2151
2080
|
throw new SerovalDeserializationError(error);
|
|
2152
2081
|
}
|
|
2153
2082
|
}
|
|
2083
|
+
deserialize(node) {
|
|
2084
|
+
switch (node.t) {
|
|
2085
|
+
case 2 /* Constant */:
|
|
2086
|
+
return CONSTANT_VAL[node.s];
|
|
2087
|
+
case 0 /* Number */:
|
|
2088
|
+
return node.s;
|
|
2089
|
+
case 1 /* String */:
|
|
2090
|
+
return deserializeString(node.s);
|
|
2091
|
+
case 3 /* BigInt */:
|
|
2092
|
+
return BigInt(node.s);
|
|
2093
|
+
case 4 /* IndexedValue */:
|
|
2094
|
+
return this.refs.get(node.i);
|
|
2095
|
+
case 18 /* Reference */:
|
|
2096
|
+
return this.deserializeReference(node);
|
|
2097
|
+
case 9 /* Array */:
|
|
2098
|
+
return this.deserializeArray(node);
|
|
2099
|
+
case 10 /* Object */:
|
|
2100
|
+
case 11 /* NullConstructor */:
|
|
2101
|
+
return this.deserializeObject(node);
|
|
2102
|
+
case 5 /* Date */:
|
|
2103
|
+
return this.deserializeDate(node);
|
|
2104
|
+
case 6 /* RegExp */:
|
|
2105
|
+
return this.deserializeRegExp(node);
|
|
2106
|
+
case 7 /* Set */:
|
|
2107
|
+
return this.deserializeSet(node);
|
|
2108
|
+
case 8 /* Map */:
|
|
2109
|
+
return this.deserializeMap(node);
|
|
2110
|
+
case 19 /* ArrayBuffer */:
|
|
2111
|
+
return this.deserializeArrayBuffer(node);
|
|
2112
|
+
case 16 /* BigIntTypedArray */:
|
|
2113
|
+
case 15 /* TypedArray */:
|
|
2114
|
+
return this.deserializeTypedArray(node);
|
|
2115
|
+
case 20 /* DataView */:
|
|
2116
|
+
return this.deserializeDataView(node);
|
|
2117
|
+
case 14 /* AggregateError */:
|
|
2118
|
+
return this.deserializeAggregateError(node);
|
|
2119
|
+
case 13 /* Error */:
|
|
2120
|
+
return this.deserializeError(node);
|
|
2121
|
+
case 12 /* Promise */:
|
|
2122
|
+
return this.deserializePromise(node);
|
|
2123
|
+
case 17 /* WKSymbol */:
|
|
2124
|
+
return SYMBOL_REF[node.s];
|
|
2125
|
+
case 21 /* Boxed */:
|
|
2126
|
+
return this.deserializeBoxed(node);
|
|
2127
|
+
case 25 /* Plugin */:
|
|
2128
|
+
return this.deserializePlugin(node);
|
|
2129
|
+
case 22 /* PromiseConstructor */:
|
|
2130
|
+
return this.deserializePromiseConstructor(node);
|
|
2131
|
+
case 23 /* PromiseSuccess */:
|
|
2132
|
+
return this.deserializePromiseResolve(node);
|
|
2133
|
+
case 24 /* PromiseFailure */:
|
|
2134
|
+
return this.deserializePromiseReject(node);
|
|
2135
|
+
case 28 /* IteratorFactoryInstance */:
|
|
2136
|
+
return this.deserializeIteratorFactoryInstance(node);
|
|
2137
|
+
case 30 /* AsyncIteratorFactoryInstance */:
|
|
2138
|
+
return this.deserializeAsyncIteratorFactoryInstance(node);
|
|
2139
|
+
case 31 /* StreamConstructor */:
|
|
2140
|
+
return this.deserializeStreamConstructor(node);
|
|
2141
|
+
case 32 /* StreamNext */:
|
|
2142
|
+
return this.deserializeStreamNext(node);
|
|
2143
|
+
case 33 /* StreamThrow */:
|
|
2144
|
+
return this.deserializeStreamThrow(node);
|
|
2145
|
+
case 34 /* StreamReturn */:
|
|
2146
|
+
return this.deserializeStreamReturn(node);
|
|
2147
|
+
case 27 /* IteratorFactory */:
|
|
2148
|
+
return this.deserializeIteratorFactory(node);
|
|
2149
|
+
case 29 /* AsyncIteratorFactory */:
|
|
2150
|
+
return this.deserializeAsyncIteratorFactory(node);
|
|
2151
|
+
// case SerovalNodeType.SpecialReference:
|
|
2152
|
+
default:
|
|
2153
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2154
2156
|
};
|
|
2155
2157
|
|
|
2156
2158
|
// src/core/cross/deserializer.ts
|
|
@@ -2994,7 +2996,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
2994
2996
|
const nodes = [];
|
|
2995
2997
|
for (let i = 0, len = current.length; i < len; i++) {
|
|
2996
2998
|
if (i in current) {
|
|
2997
|
-
nodes[i] = this.
|
|
2999
|
+
nodes[i] = this.parse(current[i]);
|
|
2998
3000
|
}
|
|
2999
3001
|
}
|
|
3000
3002
|
return nodes;
|
|
@@ -3008,7 +3010,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3008
3010
|
const valueNodes = [];
|
|
3009
3011
|
for (let i = 0, len = entries.length; i < len; i++) {
|
|
3010
3012
|
keyNodes.push(serializeString(entries[i][0]));
|
|
3011
|
-
valueNodes.push(this.
|
|
3013
|
+
valueNodes.push(this.parse(entries[i][1]));
|
|
3012
3014
|
}
|
|
3013
3015
|
let symbol = Symbol.iterator;
|
|
3014
3016
|
if (symbol in properties) {
|
|
@@ -3016,7 +3018,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3016
3018
|
valueNodes.push(
|
|
3017
3019
|
createIteratorFactoryInstanceNode(
|
|
3018
3020
|
this.parseIteratorFactory(),
|
|
3019
|
-
this.
|
|
3021
|
+
this.parse(
|
|
3020
3022
|
iteratorToSequence(properties)
|
|
3021
3023
|
)
|
|
3022
3024
|
)
|
|
@@ -3028,7 +3030,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3028
3030
|
valueNodes.push(
|
|
3029
3031
|
createAsyncIteratorFactoryInstanceNode(
|
|
3030
3032
|
this.parseAsyncIteratorFactory(),
|
|
3031
|
-
this.
|
|
3033
|
+
this.parse(createStream())
|
|
3032
3034
|
)
|
|
3033
3035
|
);
|
|
3034
3036
|
}
|
|
@@ -3057,20 +3059,16 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3057
3059
|
);
|
|
3058
3060
|
}
|
|
3059
3061
|
parseBoxed(id, current) {
|
|
3060
|
-
return createBoxedNode(id, this.
|
|
3062
|
+
return createBoxedNode(id, this.parse(current.valueOf()));
|
|
3061
3063
|
}
|
|
3062
3064
|
parseTypedArray(id, current) {
|
|
3063
|
-
return createTypedArrayNode(id, current, this.
|
|
3065
|
+
return createTypedArrayNode(id, current, this.parse(current.buffer));
|
|
3064
3066
|
}
|
|
3065
3067
|
parseBigIntTypedArray(id, current) {
|
|
3066
|
-
return createBigIntTypedArrayNode(
|
|
3067
|
-
id,
|
|
3068
|
-
current,
|
|
3069
|
-
this.parseTop(current.buffer)
|
|
3070
|
-
);
|
|
3068
|
+
return createBigIntTypedArrayNode(id, current, this.parse(current.buffer));
|
|
3071
3069
|
}
|
|
3072
3070
|
parseDataView(id, current) {
|
|
3073
|
-
return createDataViewNode(id, current, this.
|
|
3071
|
+
return createDataViewNode(id, current, this.parse(current.buffer));
|
|
3074
3072
|
}
|
|
3075
3073
|
parseError(id, current) {
|
|
3076
3074
|
const options = getErrorOptions(current, this.features);
|
|
@@ -3092,15 +3090,15 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3092
3090
|
const keyNodes = [];
|
|
3093
3091
|
const valueNodes = [];
|
|
3094
3092
|
for (const [key, value] of current.entries()) {
|
|
3095
|
-
keyNodes.push(this.
|
|
3096
|
-
valueNodes.push(this.
|
|
3093
|
+
keyNodes.push(this.parse(key));
|
|
3094
|
+
valueNodes.push(this.parse(value));
|
|
3097
3095
|
}
|
|
3098
3096
|
return this.createMapNode(id, keyNodes, valueNodes, current.size);
|
|
3099
3097
|
}
|
|
3100
3098
|
parseSet(id, current) {
|
|
3101
3099
|
const items = [];
|
|
3102
3100
|
for (const item of current.keys()) {
|
|
3103
|
-
items.push(this.
|
|
3101
|
+
items.push(this.parse(item));
|
|
3104
3102
|
}
|
|
3105
3103
|
return createSetNode(id, current.size, items);
|
|
3106
3104
|
}
|
|
@@ -3142,7 +3140,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3142
3140
|
}
|
|
3143
3141
|
const currentClass = current.constructor;
|
|
3144
3142
|
if (currentClass === OpaqueReference) {
|
|
3145
|
-
return this.
|
|
3143
|
+
return this.parse(
|
|
3146
3144
|
current.replacement
|
|
3147
3145
|
);
|
|
3148
3146
|
}
|
|
@@ -3239,7 +3237,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3239
3237
|
}
|
|
3240
3238
|
throw new SerovalUnsupportedTypeError(current);
|
|
3241
3239
|
}
|
|
3242
|
-
|
|
3240
|
+
parse(current) {
|
|
3243
3241
|
switch (typeof current) {
|
|
3244
3242
|
case "boolean":
|
|
3245
3243
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
@@ -3267,9 +3265,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3267
3265
|
throw new SerovalUnsupportedTypeError(current);
|
|
3268
3266
|
}
|
|
3269
3267
|
}
|
|
3270
|
-
|
|
3268
|
+
parseTop(current) {
|
|
3271
3269
|
try {
|
|
3272
|
-
return this.
|
|
3270
|
+
return this.parse(current);
|
|
3273
3271
|
} catch (error) {
|
|
3274
3272
|
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
3275
3273
|
}
|
|
@@ -3335,7 +3333,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3335
3333
|
const valueNodes = [];
|
|
3336
3334
|
for (let i = 0, len = entries.length; i < len; i++) {
|
|
3337
3335
|
keyNodes.push(serializeString(entries[i][0]));
|
|
3338
|
-
valueNodes.push(this.
|
|
3336
|
+
valueNodes.push(this.parse(entries[i][1]));
|
|
3339
3337
|
}
|
|
3340
3338
|
let symbol = Symbol.iterator;
|
|
3341
3339
|
if (symbol in properties) {
|
|
@@ -3343,7 +3341,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3343
3341
|
valueNodes.push(
|
|
3344
3342
|
createIteratorFactoryInstanceNode(
|
|
3345
3343
|
this.parseIteratorFactory(),
|
|
3346
|
-
this.
|
|
3344
|
+
this.parse(
|
|
3347
3345
|
iteratorToSequence(properties)
|
|
3348
3346
|
)
|
|
3349
3347
|
)
|
|
@@ -3355,7 +3353,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3355
3353
|
valueNodes.push(
|
|
3356
3354
|
createAsyncIteratorFactoryInstanceNode(
|
|
3357
3355
|
this.parseAsyncIteratorFactory(),
|
|
3358
|
-
this.
|
|
3356
|
+
this.parse(
|
|
3359
3357
|
createStreamFromAsyncIterable(
|
|
3360
3358
|
properties
|
|
3361
3359
|
)
|
|
@@ -3494,7 +3492,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3494
3492
|
}
|
|
3495
3493
|
parseWithError(current) {
|
|
3496
3494
|
try {
|
|
3497
|
-
return this.
|
|
3495
|
+
return this.parse(current);
|
|
3498
3496
|
} catch (err) {
|
|
3499
3497
|
this.onError(err);
|
|
3500
3498
|
return NIL;
|
|
@@ -3552,7 +3550,7 @@ function crossSerialize(source, options = {}) {
|
|
|
3552
3550
|
disabledFeatures: options.disabledFeatures,
|
|
3553
3551
|
refs: options.refs
|
|
3554
3552
|
});
|
|
3555
|
-
const tree = ctx.
|
|
3553
|
+
const tree = ctx.parseTop(source);
|
|
3556
3554
|
const serial = new CrossSerializerContext({
|
|
3557
3555
|
plugins,
|
|
3558
3556
|
features: ctx.features,
|
|
@@ -3568,7 +3566,7 @@ async function crossSerializeAsync(source, options = {}) {
|
|
|
3568
3566
|
disabledFeatures: options.disabledFeatures,
|
|
3569
3567
|
refs: options.refs
|
|
3570
3568
|
});
|
|
3571
|
-
const tree = await ctx.
|
|
3569
|
+
const tree = await ctx.parseTop(source);
|
|
3572
3570
|
const serial = new CrossSerializerContext({
|
|
3573
3571
|
plugins,
|
|
3574
3572
|
features: ctx.features,
|
|
@@ -3584,7 +3582,7 @@ function toCrossJSON(source, options = {}) {
|
|
|
3584
3582
|
disabledFeatures: options.disabledFeatures,
|
|
3585
3583
|
refs: options.refs
|
|
3586
3584
|
});
|
|
3587
|
-
return ctx.
|
|
3585
|
+
return ctx.parseTop(source);
|
|
3588
3586
|
}
|
|
3589
3587
|
async function toCrossJSONAsync(source, options = {}) {
|
|
3590
3588
|
const plugins = resolvePlugins(options.plugins);
|
|
@@ -3593,7 +3591,7 @@ async function toCrossJSONAsync(source, options = {}) {
|
|
|
3593
3591
|
disabledFeatures: options.disabledFeatures,
|
|
3594
3592
|
refs: options.refs
|
|
3595
3593
|
});
|
|
3596
|
-
return await ctx.
|
|
3594
|
+
return await ctx.parseTop(source);
|
|
3597
3595
|
}
|
|
3598
3596
|
function crossSerializeStream(source, options) {
|
|
3599
3597
|
const plugins = resolvePlugins(options.plugins);
|
|
@@ -3644,7 +3642,7 @@ function fromCrossJSON(source, options) {
|
|
|
3644
3642
|
plugins,
|
|
3645
3643
|
refs: options.refs
|
|
3646
3644
|
});
|
|
3647
|
-
return ctx.
|
|
3645
|
+
return ctx.deserializeTop(source);
|
|
3648
3646
|
}
|
|
3649
3647
|
|
|
3650
3648
|
// src/core/tree/async.ts
|
|
@@ -3772,7 +3770,7 @@ function serialize(source, options = {}) {
|
|
|
3772
3770
|
plugins,
|
|
3773
3771
|
disabledFeatures: options.disabledFeatures
|
|
3774
3772
|
});
|
|
3775
|
-
const tree = ctx.
|
|
3773
|
+
const tree = ctx.parseTop(source);
|
|
3776
3774
|
const serial = new VanillaSerializerContext({
|
|
3777
3775
|
plugins,
|
|
3778
3776
|
features: ctx.features,
|
|
@@ -3786,7 +3784,7 @@ async function serializeAsync(source, options = {}) {
|
|
|
3786
3784
|
plugins,
|
|
3787
3785
|
disabledFeatures: options.disabledFeatures
|
|
3788
3786
|
});
|
|
3789
|
-
const tree = await ctx.
|
|
3787
|
+
const tree = await ctx.parseTop(source);
|
|
3790
3788
|
const serial = new VanillaSerializerContext({
|
|
3791
3789
|
plugins,
|
|
3792
3790
|
features: ctx.features,
|
|
@@ -3804,7 +3802,7 @@ function toJSON(source, options = {}) {
|
|
|
3804
3802
|
disabledFeatures: options.disabledFeatures
|
|
3805
3803
|
});
|
|
3806
3804
|
return {
|
|
3807
|
-
t: ctx.
|
|
3805
|
+
t: ctx.parseTop(source),
|
|
3808
3806
|
f: ctx.features,
|
|
3809
3807
|
m: Array.from(ctx.marked)
|
|
3810
3808
|
};
|
|
@@ -3816,7 +3814,7 @@ async function toJSONAsync(source, options = {}) {
|
|
|
3816
3814
|
disabledFeatures: options.disabledFeatures
|
|
3817
3815
|
});
|
|
3818
3816
|
return {
|
|
3819
|
-
t: await ctx.
|
|
3817
|
+
t: await ctx.parseTop(source),
|
|
3820
3818
|
f: ctx.features,
|
|
3821
3819
|
m: Array.from(ctx.marked)
|
|
3822
3820
|
};
|
|
@@ -3836,7 +3834,7 @@ function fromJSON(source, options = {}) {
|
|
|
3836
3834
|
plugins,
|
|
3837
3835
|
markedRefs: source.m
|
|
3838
3836
|
});
|
|
3839
|
-
return ctx.
|
|
3837
|
+
return ctx.deserializeTop(source.t);
|
|
3840
3838
|
}
|
|
3841
3839
|
|
|
3842
3840
|
// src/core/Serializer.ts
|