Skip to content

Commit

Permalink
Add support for ArrayBuffer
Browse files Browse the repository at this point in the history
- Fix serialization issues for TypedArrays
- Fix buffer reference issues for TypedArrays
- Fix BigIntTypedArray flag disabled by default
  • Loading branch information
lxsmnsyc committed Apr 8, 2023
1 parent 17d69f8 commit cdd0ed8
Show file tree
Hide file tree
Showing 26 changed files with 275 additions and 122 deletions.
2 changes: 1 addition & 1 deletion packages/seroval/src/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export const enum Feature {
WebAPI = 0x2000,
}

export const ALL_ENABLED = 0x2FFF;
export const ALL_ENABLED = 0x3FFF;
3 changes: 3 additions & 0 deletions packages/seroval/src/tree/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
TRUE_NODE,
UNDEFINED_NODE,
createReferenceNode,
createArrayBufferNode,
} from './primitives';
import { hasReferenceID } from './reference';
import {
Expand Down Expand Up @@ -384,6 +385,8 @@ async function parse<T>(
return createRegExpNode(id, current as unknown as RegExp);
case Promise:
return generatePromiseNode(ctx, id, current as unknown as Promise<unknown>);
case ArrayBuffer:
return createArrayBufferNode(id, current as unknown as ArrayBuffer);
case Int8Array:
case Int16Array:
case Int32Array:
Expand Down
21 changes: 14 additions & 7 deletions packages/seroval/src/tree/deserialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getErrorConstructor, getTypedArrayConstructor } from './shared';
import { SYMBOL_REF } from './symbols';
import {
SerovalAggregateErrorNode,
SerovalArrayBufferNode,
SerovalArrayNode,
SerovalBigIntTypedArrayNode,
SerovalErrorNode,
Expand Down Expand Up @@ -204,21 +205,25 @@ function deserializePromise(
return result;
}

function deserializeArrayBuffer(
ctx: SerializationContext,
node: SerovalArrayBufferNode,
) {
const bytes = new Uint8Array(node.s);
const result = assignIndexedValue(ctx, node.i, bytes.buffer);
return result;
}

function deserializeTypedArray(
ctx: SerializationContext,
node: SerovalTypedArrayNode | SerovalBigIntTypedArrayNode,
) {
const TypedArray = getTypedArrayConstructor(node.c);
const dummy = new TypedArray();
const source = deserializeTree(ctx, node.f) as ArrayBuffer;
const result = assignIndexedValue(ctx, node.i, new TypedArray(
dummy.buffer,
source,
node.l,
));
for (let i = 0, len = node.s.length; i < len; i++) {
result[i] = node.t === SerovalNodeType.BigIntTypedArray
? BigInt(node.s[i])
: Number(node.s[i]);
}
return result;
}

Expand Down Expand Up @@ -274,6 +279,8 @@ export default function deserializeTree(
return deserializeSet(ctx, node);
case SerovalNodeType.Map:
return deserializeMap(ctx, node);
case SerovalNodeType.ArrayBuffer:
return deserializeArrayBuffer(ctx, node);
case SerovalNodeType.BigIntTypedArray:
case SerovalNodeType.TypedArray:
return deserializeTypedArray(ctx, node);
Expand Down
56 changes: 41 additions & 15 deletions packages/seroval/src/tree/primitives.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from '../assert';
import { Feature } from '../compat';
import { ParserContext } from '../context';
import { ParserContext, createIndexedValue } from '../context';
import { serializeString } from '../string';
import { BigIntTypedArrayValue, TypedArrayValue } from '../types';
import { getReferenceID } from './reference';
Expand All @@ -24,6 +24,7 @@ import {
SerovalUndefinedNode,
SerovalWKSymbolNode,
SerovalReferenceNode,
SerovalArrayBufferNode,
} from './types';

export const TRUE_NODE: SerovalBooleanNode = {
Expand Down Expand Up @@ -203,28 +204,57 @@ export function createRegExpNode(id: number, current: RegExp): SerovalRegExpNode
};
}

export function createArrayBufferNode(
id: number,
current: ArrayBuffer,
): SerovalArrayBufferNode {
const bytes = new Uint8Array(current);
const len = bytes.length;
const values = new Array<number>(len);
for (let i = 0; i < len; i++) {
values[i] = bytes[i];
}
return {
t: SerovalNodeType.ArrayBuffer,
i: id,
s: values,
l: undefined,
c: undefined,
m: undefined,
d: undefined,
a: undefined,
f: undefined,
};
}

function serializeArrayBuffer(
ctx: ParserContext,
current: ArrayBuffer,
) {
const id = createIndexedValue(ctx, current);
if (ctx.markedRefs.has(id)) {
return createIndexedValueNode(id);
}
return createArrayBufferNode(id, current);
}

export function createTypedArrayNode(
ctx: ParserContext,
id: number,
current: TypedArrayValue,
): SerovalTypedArrayNode {
const constructor = current.constructor.name;
assert(ctx.features & Feature.TypedArray, `Unsupported value type "${constructor}"`);
const len = current.length;
const values = new Array<string>(len);
for (let i = 0; i < len; i++) {
values[i] = '' + current[i];
}
return {
t: SerovalNodeType.TypedArray,
i: id,
s: values,
s: undefined,
l: current.byteOffset,
c: constructor,
m: undefined,
d: undefined,
a: undefined,
f: undefined,
f: serializeArrayBuffer(ctx, current.buffer),
};
}

Expand All @@ -236,25 +266,21 @@ export function createBigIntTypedArrayNode(
current: BigIntTypedArrayValue,
): SerovalBigIntTypedArrayNode {
const constructor = current.constructor.name;
console.log(ctx.features.toString(2), BIGINT_FLAG.toString(2), (ctx.features & BIGINT_FLAG).toString(2));
assert(
(ctx.features & BIGINT_FLAG) === BIGINT_FLAG,
`Unsupported value type "${constructor}"`,
);
const len = current.length;
const values = new Array<string>(len);
for (let i = 0; i < len; i++) {
values[i] = '' + current[i];
}
return {
t: SerovalNodeType.BigIntTypedArray,
i: id,
s: values,
s: undefined,
l: current.byteOffset,
c: constructor,
m: undefined,
d: undefined,
a: undefined,
f: undefined,
f: serializeArrayBuffer(ctx, current.buffer),
};
}

Expand Down
25 changes: 19 additions & 6 deletions packages/seroval/src/tree/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
SerovalIndexedValueNode,
SerovalSetNode,
SerovalTypedArrayNode,
SerovalArrayBufferNode,
} from './types';

function getAssignmentExpression(assignment: Assignment): string {
Expand Down Expand Up @@ -522,16 +523,26 @@ function serializePromise(
return assignIndexedValue(ctx, node.i, serialized);
}

function serializeArrayBuffer(
ctx: SerializationContext,
node: SerovalArrayBufferNode,
) {
let result = 'new Uint8Array(';
if (node.s.length) {
result += '[';
for (let i = 0, len = node.s.length; i < len; i++) {
result += ((i > 0) ? ',' : '') + node.s[i];
}
result += ']';
}
return assignIndexedValue(ctx, node.i, result + ').buffer');
}

function serializeTypedArray(
ctx: SerializationContext,
node: SerovalTypedArrayNode | SerovalBigIntTypedArrayNode,
) {
let result = '';
const isBigInt = node.t === SerovalNodeType.BigIntTypedArray;
for (let i = 0, len = node.s.length; i < len; i++) {
result += (i !== 0 ? ',' : '') + node.s[i] + (isBigInt ? 'n' : '');
}
const args = '[' + result + ']' + (node.l !== 0 ? (',' + node.l) : '');
const args = serializeTree(ctx, node.f) + (node.l !== 0 ? (',' + node.l) : '');
return assignIndexedValue(ctx, node.i, 'new ' + node.c + '(' + args + ')');
}

Expand Down Expand Up @@ -600,6 +611,8 @@ export default function serializeTree(
return serializeSet(ctx, node);
case SerovalNodeType.Map:
return serializeMap(ctx, node);
case SerovalNodeType.ArrayBuffer:
return serializeArrayBuffer(ctx, node);
case SerovalNodeType.BigIntTypedArray:
case SerovalNodeType.TypedArray:
return serializeTypedArray(ctx, node);
Expand Down
3 changes: 3 additions & 0 deletions packages/seroval/src/tree/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TRUE_NODE,
UNDEFINED_NODE,
createReferenceNode,
createArrayBufferNode,
} from './primitives';
import {
hasReferenceID,
Expand Down Expand Up @@ -344,6 +345,8 @@ function parse<T>(
return createDateNode(id, current as unknown as Date);
case RegExp:
return createRegExpNode(id, current as unknown as RegExp);
case ArrayBuffer:
return createArrayBufferNode(id, current as unknown as ArrayBuffer);
case Int8Array:
case Int16Array:
case Int32Array:
Expand Down
14 changes: 11 additions & 3 deletions packages/seroval/src/tree/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const enum SerovalNodeType {
URL,
URLSearchParams,
Reference,
ArrayBuffer,
}

export interface SerovalBaseNode {
Expand Down Expand Up @@ -143,20 +144,26 @@ export interface SerovalRegExpNode extends SerovalBaseNode {
m: string;
}

export interface SerovalArrayBufferNode extends SerovalBaseNode {
t: SerovalNodeType.ArrayBuffer;
i: number;
s: number[];
}

export interface SerovalTypedArrayNode extends SerovalBaseNode {
t: SerovalNodeType.TypedArray;
i: number;
s: string[];
l: number;
c: string;
f: SerovalNode;
}

export interface SerovalBigIntTypedArrayNode extends SerovalBaseNode {
t: SerovalNodeType.BigIntTypedArray;
i: number;
s: string[];
l: number;
c: string;
f: SerovalNode;
}

export type SerovalSemiPrimitiveNode =
Expand Down Expand Up @@ -268,4 +275,5 @@ export type SerovalNode =
| SerovalWKSymbolNode
| SerovalURLNode
| SerovalURLSearchParamsNode
| SerovalReferenceNode;
| SerovalReferenceNode
| SerovalArrayBufferNode;
12 changes: 6 additions & 6 deletions packages/seroval/test/__snapshots__/array.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ exports[`array holes > serialize > supports array holes 1`] = `"[,,,,,,,,,,]"`;

exports[`array holes > serializeAsync > supports array holes 1`] = `"Promise.resolve([,,,,,,,,,,])"`;

exports[`array holes > toJSON > supports array holes 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":10,\\"a\\":[null,null,null,null,null,null,null,null,null,null]},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`array holes > toJSON > supports array holes 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":10,\\"a\\":[null,null,null,null,null,null,null,null,null,null]},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`array holes > toJSONAsync > supports array holes 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":15,\\"i\\":1,\\"l\\":10,\\"a\\":[null,null,null,null,null,null,null,null,null,null]}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`array holes > toJSONAsync > supports array holes 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":15,\\"i\\":1,\\"l\\":10,\\"a\\":[null,null,null,null,null,null,null,null,null,null]}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`arrays > serialize > supports Arrays 1`] = `"[1,2,3]"`;

Expand All @@ -16,10 +16,10 @@ exports[`arrays > serializeAsync > supports Arrays 1`] = `"Promise.resolve([1,2,

exports[`arrays > serializeAsync > supports self recursion 1`] = `"(h=>(h=[Promise.resolve().then(()=>h),Promise.resolve().then(()=>h)]))()"`;

exports[`arrays > toJSON > supports Arrays 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":3,\\"a\\":[{\\"t\\":0,\\"s\\":1},{\\"t\\":0,\\"s\\":2},{\\"t\\":0,\\"s\\":3}]},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`arrays > toJSON > supports Arrays 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":3,\\"a\\":[{\\"t\\":0,\\"s\\":1},{\\"t\\":0,\\"s\\":2},{\\"t\\":0,\\"s\\":3}]},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`arrays > toJSON > supports self recursion 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":2,\\"a\\":[{\\"t\\":10,\\"i\\":0},{\\"t\\":10,\\"i\\":0}]},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[0]}"`;
exports[`arrays > toJSON > supports self recursion 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":2,\\"a\\":[{\\"t\\":10,\\"i\\":0},{\\"t\\":10,\\"i\\":0}]},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[0]}"`;

exports[`arrays > toJSONAsync > supports Arrays 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":15,\\"i\\":1,\\"l\\":3,\\"a\\":[{\\"t\\":0,\\"s\\":1},{\\"t\\":0,\\"s\\":2},{\\"t\\":0,\\"s\\":3}]}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`arrays > toJSONAsync > supports Arrays 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":15,\\"i\\":1,\\"l\\":3,\\"a\\":[{\\"t\\":0,\\"s\\":1},{\\"t\\":0,\\"s\\":2},{\\"t\\":0,\\"s\\":3}]}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`arrays > toJSONAsync > supports self recursion 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":2,\\"a\\":[{\\"t\\":18,\\"i\\":1,\\"f\\":{\\"t\\":10,\\"i\\":0}},{\\"t\\":18,\\"i\\":2,\\"f\\":{\\"t\\":10,\\"i\\":0}}]},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[0]}"`;
exports[`arrays > toJSONAsync > supports self recursion 1`] = `"{\\"t\\":{\\"t\\":15,\\"i\\":0,\\"l\\":2,\\"a\\":[{\\"t\\":18,\\"i\\":1,\\"f\\":{\\"t\\":10,\\"i\\":0}},{\\"t\\":18,\\"i\\":2,\\"f\\":{\\"t\\":10,\\"i\\":0}}]},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[0]}"`;
4 changes: 2 additions & 2 deletions packages/seroval/test/__snapshots__/bigint.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ exports[`bigint > serialize > supports bigint 1`] = `"9007199254740991n"`;

exports[`bigint > serializeAsync > supports bigint 1`] = `"Promise.resolve(9007199254740991n)"`;

exports[`bigint > toJSON > supports bigint 1`] = `"{\\"t\\":{\\"t\\":9,\\"s\\":\\"9007199254740991\\"},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`bigint > toJSON > supports bigint 1`] = `"{\\"t\\":{\\"t\\":9,\\"s\\":\\"9007199254740991\\"},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`bigint > toJSONAsync > supports bigint 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":9,\\"s\\":\\"9007199254740991\\"}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`bigint > toJSONAsync > supports bigint 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":9,\\"s\\":\\"9007199254740991\\"}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;
4 changes: 2 additions & 2 deletions packages/seroval/test/__snapshots__/date.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ exports[`Date > serialize > supports Date 1`] = `"new Date(\\"2023-03-14T11:16:2

exports[`Date > serializeAsync > supports Date 1`] = `"Promise.resolve(new Date(\\"2023-03-14T11:16:24.879Z\\"))"`;

exports[`Date > toJSON > supports Date 1`] = `"{\\"t\\":{\\"t\\":11,\\"i\\":0,\\"s\\":\\"2023-03-14T11:16:24.879Z\\"},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Date > toJSON > supports Date 1`] = `"{\\"t\\":{\\"t\\":11,\\"i\\":0,\\"s\\":\\"2023-03-14T11:16:24.879Z\\"},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`Date > toJSONAsync > supports Date 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":11,\\"i\\":1,\\"s\\":\\"2023-03-14T11:16:24.879Z\\"}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Date > toJSONAsync > supports Date 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":11,\\"i\\":1,\\"s\\":\\"2023-03-14T11:16:24.879Z\\"}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;
12 changes: 6 additions & 6 deletions packages/seroval/test/__snapshots__/error.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ exports[`Error > serializeAsync > supports Error.prototype.name 1`] = `"Promise.

exports[`Error > serializeAsync > supports other Error classes 1`] = `"Promise.resolve(Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"}))"`;

exports[`Error > toJSON > supports Error.prototype.cause 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"Error\\",\\"m\\":\\"B\\",\\"d\\":{\\"k\\":[\\"stack\\",\\"cause\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"},{\\"t\\":19,\\"i\\":1,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}}],\\"s\\":2}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Error > toJSON > supports Error.prototype.cause 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"Error\\",\\"m\\":\\"B\\",\\"d\\":{\\"k\\":[\\"stack\\",\\"cause\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"},{\\"t\\":19,\\"i\\":1,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}}],\\"s\\":2}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`Error > toJSON > supports Error.prototype.name 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"name\\",\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"ExampleError\\"},{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":2}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Error > toJSON > supports Error.prototype.name 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"name\\",\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"ExampleError\\"},{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":2}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`Error > toJSON > supports other Error classes 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"ReferenceError\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Error > toJSON > supports other Error classes 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"ReferenceError\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`Error > toJSONAsync > supports Error.prototype.cause 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"Error\\",\\"m\\":\\"B\\",\\"d\\":{\\"k\\":[\\"stack\\",\\"cause\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"},{\\"t\\":18,\\"i\\":1,\\"f\\":{\\"t\\":19,\\"i\\":2,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}}}],\\"s\\":2}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Error > toJSONAsync > supports Error.prototype.cause 1`] = `"{\\"t\\":{\\"t\\":19,\\"i\\":0,\\"c\\":\\"Error\\",\\"m\\":\\"B\\",\\"d\\":{\\"k\\":[\\"stack\\",\\"cause\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"},{\\"t\\":18,\\"i\\":1,\\"f\\":{\\"t\\":19,\\"i\\":2,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}}}],\\"s\\":2}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`Error > toJSONAsync > supports Error.prototype.name 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":19,\\"i\\":1,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"name\\",\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"ExampleError\\"},{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":2}}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Error > toJSONAsync > supports Error.prototype.name 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":19,\\"i\\":1,\\"c\\":\\"Error\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"name\\",\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"ExampleError\\"},{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":2}}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;

exports[`Error > toJSONAsync > supports other Error classes 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":19,\\"i\\":1,\\"c\\":\\"ReferenceError\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}}},\\"r\\":0,\\"i\\":false,\\"f\\":12287,\\"m\\":[]}"`;
exports[`Error > toJSONAsync > supports other Error classes 1`] = `"{\\"t\\":{\\"t\\":18,\\"i\\":0,\\"f\\":{\\"t\\":19,\\"i\\":1,\\"c\\":\\"ReferenceError\\",\\"m\\":\\"A\\",\\"d\\":{\\"k\\":[\\"stack\\"],\\"v\\":[{\\"t\\":1,\\"s\\":\\"\\"}],\\"s\\":1}}},\\"r\\":0,\\"i\\":false,\\"f\\":16383,\\"m\\":[]}"`;
Loading

0 comments on commit cdd0ed8

Please sign in to comment.