seroval 0.9.0 → 0.10.1

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.
Files changed (90) hide show
  1. package/README.md +4 -287
  2. package/dist/cjs/development/index.cjs +3500 -1135
  3. package/dist/cjs/development/index.cjs.map +4 -4
  4. package/dist/cjs/production/index.cjs +12 -3
  5. package/dist/esm/development/index.mjs +3502 -1135
  6. package/dist/esm/development/index.mjs.map +4 -4
  7. package/dist/esm/production/index.mjs +12 -3
  8. package/dist/types/core/Serializer.d.ts +14 -0
  9. package/dist/types/{tree → core}/UnsupportedTypeError.d.ts +4 -3
  10. package/dist/types/{assert.d.ts → core/assert.d.ts} +1 -1
  11. package/dist/types/core/assignments.d.ts +33 -0
  12. package/dist/types/core/base-primitives.d.ts +12 -0
  13. package/dist/types/{compat.d.ts → core/compat.d.ts} +22 -22
  14. package/dist/types/core/constants.d.ts +89 -0
  15. package/dist/types/core/context.d.ts +9 -0
  16. package/dist/types/core/cross/async.d.ts +3 -0
  17. package/dist/types/core/cross/context.d.ts +30 -0
  18. package/dist/types/core/cross/index.d.ts +7 -0
  19. package/dist/types/core/cross/primitives.d.ts +9 -0
  20. package/dist/types/core/cross/serialize.d.ts +5 -0
  21. package/dist/types/core/cross/stream.d.ts +3 -0
  22. package/dist/types/core/cross/sync.d.ts +3 -0
  23. package/dist/types/core/cross/web-api.d.ts +4 -0
  24. package/dist/types/{get-identifier.d.ts → core/get-identifier.d.ts} +1 -1
  25. package/dist/types/core/keys.d.ts +12 -0
  26. package/dist/types/{tree/constants.d.ts → core/literals.d.ts} +9 -11
  27. package/dist/types/core/promise-to-result.d.ts +1 -0
  28. package/dist/types/{tree → core}/reference.d.ts +5 -6
  29. package/dist/types/{tree → core}/shared.d.ts +13 -13
  30. package/dist/types/{string.d.ts → core/string.d.ts} +3 -3
  31. package/dist/types/core/tree/async.d.ts +3 -0
  32. package/dist/types/core/tree/context.d.ts +45 -0
  33. package/dist/types/core/tree/deserialize.d.ts +3 -0
  34. package/dist/types/core/tree/index.d.ts +15 -0
  35. package/dist/types/core/tree/primitives.d.ts +9 -0
  36. package/dist/types/core/tree/serialize.d.ts +4 -0
  37. package/dist/types/core/tree/sync.d.ts +3 -0
  38. package/dist/types/core/tree/web-api.d.ts +4 -0
  39. package/dist/types/{tree → core}/types.d.ts +228 -238
  40. package/dist/types/core/web-api.d.ts +4 -0
  41. package/dist/types/index.d.ts +9 -19
  42. package/dist/types/types.d.ts +20 -20
  43. package/package.json +5 -5
  44. package/src/core/Serializer.ts +46 -0
  45. package/src/{tree → core}/UnsupportedTypeError.ts +1 -1
  46. package/src/core/assignments.ts +159 -0
  47. package/src/{tree/primitives.ts → core/base-primitives.ts} +33 -136
  48. package/src/core/constants.ts +169 -0
  49. package/src/core/context.ts +15 -0
  50. package/src/core/cross/async.ts +614 -0
  51. package/src/core/cross/context.ts +79 -0
  52. package/src/core/cross/index.ts +154 -0
  53. package/src/core/cross/primitives.ts +137 -0
  54. package/src/core/cross/serialize.ts +846 -0
  55. package/src/core/cross/stream.ts +740 -0
  56. package/src/core/cross/sync.ts +561 -0
  57. package/src/core/cross/web-api.ts +55 -0
  58. package/src/core/header.js +65 -0
  59. package/src/core/keys.ts +33 -0
  60. package/src/core/literals.ts +28 -0
  61. package/src/core/promise-to-result.ts +9 -0
  62. package/src/{tree → core}/reference.ts +6 -7
  63. package/src/{tree → core}/shared.ts +4 -4
  64. package/src/{tree → core/tree}/async.ts +46 -34
  65. package/src/core/tree/context.ts +136 -0
  66. package/src/{tree → core/tree}/deserialize.ts +68 -55
  67. package/src/core/tree/index.ts +146 -0
  68. package/src/core/tree/primitives.ts +132 -0
  69. package/src/{tree → core/tree}/serialize.ts +87 -193
  70. package/src/{tree → core/tree}/sync.ts +50 -39
  71. package/src/{tree → core/tree}/web-api.ts +8 -52
  72. package/src/{tree → core}/types.ts +76 -60
  73. package/src/core/web-api.ts +51 -0
  74. package/src/index.ts +7 -141
  75. package/src/types.ts +1 -1
  76. package/dist/types/context.d.ts +0 -67
  77. package/dist/types/tree/async.d.ts +0 -3
  78. package/dist/types/tree/deserialize.d.ts +0 -3
  79. package/dist/types/tree/primitives.d.ts +0 -19
  80. package/dist/types/tree/serialize.d.ts +0 -4
  81. package/dist/types/tree/symbols.d.ts +0 -33
  82. package/dist/types/tree/sync.d.ts +0 -3
  83. package/dist/types/tree/web-api.d.ts +0 -6
  84. package/src/context.ts +0 -164
  85. package/src/tree/constants.ts +0 -73
  86. package/src/tree/symbols.ts +0 -65
  87. /package/src/{assert.ts → core/assert.ts} +0 -0
  88. /package/src/{compat.ts → core/compat.ts} +0 -0
  89. /package/src/{get-identifier.ts → core/get-identifier.ts} +0 -0
  90. /package/src/{string.ts → core/string.ts} +0 -0
@@ -1,20 +1,20 @@
1
- import type { WellKnownSymbols } from './tree/symbols';
2
- export type PrimitiveValue = boolean | string | number | undefined | null | WellKnownSymbols;
3
- export type ErrorValue = Error | AggregateError | EvalError | RangeError | ReferenceError | TypeError | SyntaxError | URIError;
4
- export type TypedArrayValue = Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
5
- export type BigIntTypedArrayValue = BigInt64Array | BigUint64Array;
6
- export type WebAPIValue = URL | URLSearchParams | Blob | File;
7
- export type SemiPrimitiveValue = RegExp | Date | ArrayBuffer | DataView | TypedArrayValue | BigIntTypedArrayValue | bigint | WebAPIValue;
8
- export type CommonServerValue = PrimitiveValue | SemiPrimitiveValue | ErrorValue;
9
- export type ServerValue = CommonServerValue | Array<ServerValue> | readonly ServerValue[] | Iterable<ServerValue> | {
10
- [key: string | number]: ServerValue;
11
- } | {
12
- readonly [key: string | number]: ServerValue;
13
- } | Set<ServerValue> | Map<ServerValue, ServerValue>;
14
- export type AsyncServerValue = CommonServerValue | Array<AsyncServerValue> | readonly AsyncServerValue[] | Iterable<AsyncServerValue> | {
15
- [key: string | number]: AsyncServerValue;
16
- } | {
17
- readonly [key: string | number]: AsyncServerValue;
18
- } | Set<AsyncServerValue> | Map<AsyncServerValue, AsyncServerValue> | Promise<AsyncServerValue>;
19
- export type NonPrimitiveServerValue<T> = T extends PrimitiveValue ? never : T;
20
- export type MaybePromise<T> = T | Promise<T>;
1
+ import type { WellKnownSymbols } from './core/constants';
2
+ export type PrimitiveValue = boolean | string | number | undefined | null | WellKnownSymbols;
3
+ export type ErrorValue = Error | AggregateError | EvalError | RangeError | ReferenceError | TypeError | SyntaxError | URIError;
4
+ export type TypedArrayValue = Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
5
+ export type BigIntTypedArrayValue = BigInt64Array | BigUint64Array;
6
+ export type WebAPIValue = URL | URLSearchParams | Blob | File;
7
+ export type SemiPrimitiveValue = RegExp | Date | ArrayBuffer | DataView | TypedArrayValue | BigIntTypedArrayValue | bigint | WebAPIValue;
8
+ export type CommonServerValue = PrimitiveValue | SemiPrimitiveValue | ErrorValue;
9
+ export type ServerValue = CommonServerValue | Array<ServerValue> | readonly ServerValue[] | Iterable<ServerValue> | {
10
+ [key: string | number]: ServerValue;
11
+ } | {
12
+ readonly [key: string | number]: ServerValue;
13
+ } | Set<ServerValue> | Map<ServerValue, ServerValue>;
14
+ export type AsyncServerValue = CommonServerValue | Array<AsyncServerValue> | readonly AsyncServerValue[] | Iterable<AsyncServerValue> | {
15
+ [key: string | number]: AsyncServerValue;
16
+ } | {
17
+ readonly [key: string | number]: AsyncServerValue;
18
+ } | Set<AsyncServerValue> | Map<AsyncServerValue, AsyncServerValue> | Promise<AsyncServerValue>;
19
+ export type NonPrimitiveServerValue<T> = T extends PrimitiveValue ? never : T;
20
+ export type MaybePromise<T> = T | Promise<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "seroval",
3
3
  "type": "module",
4
- "version": "0.9.0",
4
+ "version": "0.10.1",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
@@ -14,9 +14,9 @@
14
14
  "pridepack"
15
15
  ],
16
16
  "devDependencies": {
17
- "@types/node": "^20.4.0",
18
- "@vitest/ui": "^0.33.0",
19
- "eslint": "^8.44.0",
17
+ "@types/node": "^20.6.2",
18
+ "@vitest/ui": "^0.34.4",
19
+ "eslint": "^8.49.0",
20
20
  "eslint-config-lxsmnsyc": "^0.6.5",
21
21
  "node-fetch-native": "^1.1.0",
22
22
  "pridepack": "2.4.4",
@@ -67,5 +67,5 @@
67
67
  "typesVersions": {
68
68
  "*": {}
69
69
  },
70
- "gitHead": "a3bfdc3ac2246b5b067f67af1f10d7a416bfed5f"
70
+ "gitHead": "aa589c20369bfbeb28d7a3d9ab0e86ed92205195"
71
71
  }
@@ -0,0 +1,46 @@
1
+ import { crossSerializeStream } from './cross';
2
+ import { serializeString } from './string';
3
+
4
+ export interface SerializerOptions {
5
+ globalIdentifier: string;
6
+ disabledFeatures?: number;
7
+ onData: (result: string) => void;
8
+ }
9
+
10
+ export default class Serializer {
11
+ private alive = true;
12
+
13
+ private cleanups: (() => void)[] = [];
14
+
15
+ private refs = new Map<unknown, number>();
16
+
17
+ constructor(
18
+ private options: SerializerOptions,
19
+ ) {
20
+ }
21
+
22
+ write(key: string, value: unknown): void {
23
+ if (this.alive) {
24
+ this.cleanups.push(crossSerializeStream(value, {
25
+ refs: this.refs,
26
+ disabledFeatures: this.options.disabledFeatures,
27
+ onSerialize: (data, initial) => {
28
+ this.options.onData(
29
+ initial
30
+ ? this.options.globalIdentifier + '["' + serializeString(key) + '"]=' + data
31
+ : data,
32
+ );
33
+ },
34
+ }));
35
+ }
36
+ }
37
+
38
+ close(): void {
39
+ if (this.alive) {
40
+ for (let i = 0, len = this.cleanups.length; i < len; i++) {
41
+ this.cleanups[i]();
42
+ }
43
+ this.alive = false;
44
+ }
45
+ }
46
+ }
@@ -2,7 +2,7 @@
2
2
  const { toString } = Object.prototype;
3
3
 
4
4
  export default class UnsupportedTypeError extends Error {
5
- constructor(value: unknown) {
5
+ constructor(public value: unknown) {
6
6
  super('Unsupported type "' + toString.call(value) + '"');
7
7
  }
8
8
  }
@@ -0,0 +1,159 @@
1
+ import { SerovalObjectFlags } from './constants';
2
+
3
+ interface IndexAssignment {
4
+ t: 'index';
5
+ s: string;
6
+ k: undefined;
7
+ v: string;
8
+ }
9
+
10
+ interface SetAssignment {
11
+ t: 'set';
12
+ s: string;
13
+ k: string;
14
+ v: string;
15
+ }
16
+
17
+ interface AddAssignment {
18
+ t: 'add';
19
+ s: string;
20
+ k: undefined;
21
+ v: string;
22
+ }
23
+
24
+ interface AppendAssignment {
25
+ t: 'append';
26
+ s: string;
27
+ k: string;
28
+ v: string;
29
+ }
30
+
31
+ // Array of assignments to be done (used for recursion)
32
+ export type Assignment =
33
+ | IndexAssignment
34
+ | AddAssignment
35
+ | SetAssignment
36
+ | AppendAssignment;
37
+
38
+ export interface FlaggedObject {
39
+ type: SerovalObjectFlags;
40
+ value: string;
41
+ }
42
+
43
+ function getAssignmentExpression(assignment: Assignment): string {
44
+ switch (assignment.t) {
45
+ case 'index':
46
+ return assignment.s + '=' + assignment.v;
47
+ case 'set':
48
+ return assignment.s + '.set(' + assignment.k + ',' + assignment.v + ')';
49
+ case 'add':
50
+ return assignment.s + '.add(' + assignment.v + ')';
51
+ case 'append':
52
+ return assignment.s + '.append(' + assignment.k + ',' + assignment.v + ')';
53
+ default:
54
+ return '';
55
+ }
56
+ }
57
+
58
+ const OBJECT_FLAG_CONSTRUCTOR: Record<SerovalObjectFlags, string | undefined> = {
59
+ [SerovalObjectFlags.Frozen]: 'Object.freeze',
60
+ [SerovalObjectFlags.Sealed]: 'Object.seal',
61
+ [SerovalObjectFlags.NonExtensible]: 'Object.preventExtensions',
62
+ [SerovalObjectFlags.None]: undefined,
63
+ };
64
+
65
+ function mergeAssignments(assignments: Assignment[]): Assignment[] {
66
+ const newAssignments: Assignment[] = [];
67
+ let current = assignments[0];
68
+ let prev = current;
69
+ let item: Assignment;
70
+ for (let i = 1, len = assignments.length; i < len; i++) {
71
+ item = assignments[i];
72
+ if (item.t === prev.t) {
73
+ switch (item.t) {
74
+ case 'index':
75
+ if (item.v === prev.v) {
76
+ // Merge if the right-hand value is the same
77
+ // saves at least 2 chars
78
+ current = {
79
+ t: 'index',
80
+ s: item.s,
81
+ k: undefined,
82
+ v: getAssignmentExpression(current),
83
+ };
84
+ } else {
85
+ // Different assignment, push current
86
+ newAssignments.push(current);
87
+ current = item;
88
+ }
89
+ break;
90
+ case 'set':
91
+ if (item.s === prev.s) {
92
+ // Maps has chaining methods, merge if source is the same
93
+ current = {
94
+ t: 'set',
95
+ s: getAssignmentExpression(current),
96
+ k: item.k,
97
+ v: item.v,
98
+ };
99
+ } else {
100
+ // Different assignment, push current
101
+ newAssignments.push(current);
102
+ current = item;
103
+ }
104
+ break;
105
+ case 'add':
106
+ if (item.s === prev.s) {
107
+ // Sets has chaining methods too
108
+ current = {
109
+ t: 'add',
110
+ s: getAssignmentExpression(current),
111
+ k: undefined,
112
+ v: item.v,
113
+ };
114
+ } else {
115
+ // Different assignment, push current
116
+ newAssignments.push(current);
117
+ current = item;
118
+ }
119
+ break;
120
+ case 'append':
121
+ // Different assignment, push current
122
+ newAssignments.push(current);
123
+ current = item;
124
+ break;
125
+ default:
126
+ break;
127
+ }
128
+ } else {
129
+ newAssignments.push(current);
130
+ current = item;
131
+ }
132
+ prev = item;
133
+ }
134
+
135
+ newAssignments.push(current);
136
+
137
+ return newAssignments;
138
+ }
139
+
140
+ export function resolveAssignments(assignments: Assignment[]): string | undefined {
141
+ if (assignments.length) {
142
+ let result = '';
143
+ const merged = mergeAssignments(assignments);
144
+ for (let i = 0, len = merged.length; i < len; i++) {
145
+ result += getAssignmentExpression(merged[i]) + ',';
146
+ }
147
+ return result;
148
+ }
149
+ return undefined;
150
+ }
151
+
152
+ export function resolveFlags(flags: FlaggedObject[]): string | undefined {
153
+ let result = '';
154
+ for (let i = 0, len = flags.length; i < len; i++) {
155
+ const flag = flags[i];
156
+ result += OBJECT_FLAG_CONSTRUCTOR[flag.type] + '(' + flag.value + '),';
157
+ }
158
+ return result;
159
+ }
@@ -1,38 +1,31 @@
1
- import assert from '../assert';
2
- import { Feature } from '../compat';
3
- import type { ParserContext } from '../context';
4
- import { createIndexedValue } from '../context';
5
- import { serializeString } from '../string';
6
- import type { BigIntTypedArrayValue, TypedArrayValue } from '../types';
7
1
  import UnsupportedTypeError from './UnsupportedTypeError';
2
+ import assert from './assert';
3
+ import { Feature } from './compat';
4
+ import type { WellKnownSymbols } from './constants';
5
+ import { INV_SYMBOL_REF, SerovalNodeType } from './constants';
6
+ import type { BaseParserContext } from './context';
8
7
  import {
9
8
  INFINITY_NODE,
10
9
  NEG_INFINITY_NODE,
11
10
  NAN_NODE,
12
11
  NEG_ZERO_NODE,
13
- } from './constants';
14
- import { getReferenceID, hasReferenceID } from './reference';
15
- import type { WellKnownSymbols } from './symbols';
16
- import { INV_SYMBOL_REF } from './symbols';
12
+ } from './literals';
13
+ import { getReferenceID } from './reference';
14
+ import { serializeString } from './string';
17
15
  import type {
16
+ SerovalArrayBufferNode,
18
17
  SerovalBigIntNode,
19
- SerovalBigIntTypedArrayNode,
18
+ SerovalConstantNode,
20
19
  SerovalDateNode,
21
20
  SerovalIndexedValueNode,
21
+ SerovalNumberNode,
22
+ SerovalReferenceNode,
22
23
  SerovalRegExpNode,
23
24
  SerovalStringNode,
24
- SerovalTypedArrayNode,
25
25
  SerovalWKSymbolNode,
26
- SerovalReferenceNode,
27
- SerovalArrayBufferNode,
28
- SerovalDataViewNode,
29
- SerovalNode,
30
- } from './types';
31
- import {
32
- SerovalNodeType,
33
26
  } from './types';
34
27
 
35
- export function createNumberNode(value: number): SerovalNode {
28
+ export function createNumberNode(value: number): SerovalConstantNode | SerovalNumberNode {
36
29
  switch (value) {
37
30
  case Infinity:
38
31
  return INFINITY_NODE;
@@ -53,7 +46,8 @@ export function createNumberNode(value: number): SerovalNode {
53
46
  l: undefined,
54
47
  c: undefined,
55
48
  m: undefined,
56
- d: undefined,
49
+ p: undefined,
50
+ e: undefined,
57
51
  a: undefined,
58
52
  f: undefined,
59
53
  b: undefined,
@@ -70,7 +64,8 @@ export function createStringNode(value: string): SerovalStringNode {
70
64
  l: undefined,
71
65
  c: undefined,
72
66
  m: undefined,
73
- d: undefined,
67
+ p: undefined,
68
+ e: undefined,
74
69
  a: undefined,
75
70
  f: undefined,
76
71
  b: undefined,
@@ -79,7 +74,7 @@ export function createStringNode(value: string): SerovalStringNode {
79
74
  }
80
75
 
81
76
  export function createBigIntNode(
82
- ctx: ParserContext,
77
+ ctx: BaseParserContext,
83
78
  current: bigint,
84
79
  ): SerovalBigIntNode {
85
80
  assert(ctx.features & Feature.BigInt, new UnsupportedTypeError(current));
@@ -90,7 +85,8 @@ export function createBigIntNode(
90
85
  l: undefined,
91
86
  c: undefined,
92
87
  m: undefined,
93
- d: undefined,
88
+ p: undefined,
89
+ e: undefined,
94
90
  a: undefined,
95
91
  f: undefined,
96
92
  b: undefined,
@@ -106,7 +102,8 @@ export function createIndexedValueNode(id: number): SerovalIndexedValueNode {
106
102
  l: undefined,
107
103
  c: undefined,
108
104
  m: undefined,
109
- d: undefined,
105
+ p: undefined,
106
+ e: undefined,
110
107
  a: undefined,
111
108
  f: undefined,
112
109
  b: undefined,
@@ -122,7 +119,8 @@ export function createDateNode(id: number, current: Date): SerovalDateNode {
122
119
  l: undefined,
123
120
  c: undefined,
124
121
  m: undefined,
125
- d: undefined,
122
+ p: undefined,
123
+ e: undefined,
126
124
  f: undefined,
127
125
  a: undefined,
128
126
  b: undefined,
@@ -138,7 +136,8 @@ export function createRegExpNode(id: number, current: RegExp): SerovalRegExpNode
138
136
  l: undefined,
139
137
  c: current.source,
140
138
  m: current.flags,
141
- d: undefined,
139
+ p: undefined,
140
+ e: undefined,
142
141
  a: undefined,
143
142
  f: undefined,
144
143
  b: undefined,
@@ -163,7 +162,8 @@ export function createArrayBufferNode(
163
162
  l: undefined,
164
163
  c: undefined,
165
164
  m: undefined,
166
- d: undefined,
165
+ p: undefined,
166
+ e: undefined,
167
167
  a: undefined,
168
168
  f: undefined,
169
169
  b: undefined,
@@ -171,66 +171,8 @@ export function createArrayBufferNode(
171
171
  };
172
172
  }
173
173
 
174
- export function serializeArrayBuffer(
175
- ctx: ParserContext,
176
- current: ArrayBuffer,
177
- ): SerovalNode {
178
- const id = createIndexedValue(ctx, current);
179
- if (ctx.markedRefs.has(id)) {
180
- return createIndexedValueNode(id);
181
- }
182
- return createArrayBufferNode(id, current);
183
- }
184
-
185
- export function createTypedArrayNode(
186
- ctx: ParserContext,
187
- id: number,
188
- current: TypedArrayValue,
189
- ): SerovalTypedArrayNode {
190
- assert(ctx.features & Feature.TypedArray, new UnsupportedTypeError(current));
191
- return {
192
- t: SerovalNodeType.TypedArray,
193
- i: id,
194
- s: undefined,
195
- l: current.length,
196
- c: current.constructor.name,
197
- m: undefined,
198
- d: undefined,
199
- a: undefined,
200
- f: serializeArrayBuffer(ctx, current.buffer),
201
- b: current.byteOffset,
202
- o: undefined,
203
- };
204
- }
205
-
206
- const BIGINT_FLAG = Feature.BigIntTypedArray | Feature.BigInt;
207
-
208
- export function createBigIntTypedArrayNode(
209
- ctx: ParserContext,
210
- id: number,
211
- current: BigIntTypedArrayValue,
212
- ): SerovalBigIntTypedArrayNode {
213
- assert(
214
- (ctx.features & BIGINT_FLAG) === BIGINT_FLAG,
215
- new UnsupportedTypeError(current),
216
- );
217
- return {
218
- t: SerovalNodeType.BigIntTypedArray,
219
- i: id,
220
- s: undefined,
221
- l: current.length,
222
- c: current.constructor.name,
223
- m: undefined,
224
- d: undefined,
225
- a: undefined,
226
- f: serializeArrayBuffer(ctx, current.buffer),
227
- b: current.byteOffset,
228
- o: undefined,
229
- };
230
- }
231
-
232
174
  export function createWKSymbolNode(
233
- ctx: ParserContext,
175
+ ctx: BaseParserContext,
234
176
  id: number,
235
177
  current: WellKnownSymbols,
236
178
  ): SerovalWKSymbolNode {
@@ -243,7 +185,8 @@ export function createWKSymbolNode(
243
185
  l: undefined,
244
186
  c: undefined,
245
187
  m: undefined,
246
- d: undefined,
188
+ p: undefined,
189
+ e: undefined,
247
190
  a: undefined,
248
191
  f: undefined,
249
192
  b: undefined,
@@ -262,57 +205,11 @@ export function createReferenceNode<T>(
262
205
  l: undefined,
263
206
  c: undefined,
264
207
  m: undefined,
265
- d: undefined,
208
+ p: undefined,
209
+ e: undefined,
266
210
  a: undefined,
267
211
  f: undefined,
268
212
  b: undefined,
269
213
  o: undefined,
270
214
  };
271
215
  }
272
-
273
- export function createDataViewNode(
274
- ctx: ParserContext,
275
- id: number,
276
- current: DataView,
277
- ): SerovalDataViewNode {
278
- return {
279
- t: SerovalNodeType.DataView,
280
- i: id,
281
- s: undefined,
282
- l: current.byteLength,
283
- c: undefined,
284
- m: undefined,
285
- d: undefined,
286
- a: undefined,
287
- f: serializeArrayBuffer(ctx, current.buffer),
288
- b: current.byteOffset,
289
- o: undefined,
290
- };
291
- }
292
-
293
- export function createSymbolNode(
294
- ctx: ParserContext,
295
- current: symbol,
296
- ): SerovalNode {
297
- const id = createIndexedValue(ctx, current);
298
- if (ctx.markedRefs.has(id)) {
299
- return createIndexedValueNode(id);
300
- }
301
- if (hasReferenceID(current)) {
302
- return createReferenceNode(id, current);
303
- }
304
- return createWKSymbolNode(ctx, id, current as WellKnownSymbols);
305
- }
306
-
307
- export function createFunctionNode(
308
- ctx: ParserContext,
309
- // eslint-disable-next-line @typescript-eslint/ban-types
310
- current: Function,
311
- ): SerovalNode {
312
- assert(hasReferenceID(current), new Error('Cannot serialize function without reference ID.'));
313
- const id = createIndexedValue(ctx, current);
314
- if (ctx.markedRefs.has(id)) {
315
- return createIndexedValueNode(id);
316
- }
317
- return createReferenceNode(id, current);
318
- }