Skip to content

Commit

Permalink
Change SerovalAggregateNode to use array of nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Mar 17, 2023
1 parent 3493180 commit 9d686de
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/seroval/src/tree/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ async function generateAggregateErrorNode(
c: undefined,
m: current.message,
d: optionsNode,
a: undefined,
n: await parse(ctx, current.errors),
a: await generateNodeList(ctx, current.errors as AsyncServerValue[]),
n: undefined,
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/seroval/src/tree/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const IDENTIFIER_CHECK = /^([$A-Z_][0-9A-Z_$]*)$/i;

function serializeNodeList(
ctx: SerializationContext,
node: SerovalArrayNode | SerovalIterableNode,
node: SerovalArrayNode | SerovalIterableNode | SerovalAggregateErrorNode,
) {
// This is different than Map and Set
// because we also need to serialize
Expand Down Expand Up @@ -463,7 +463,7 @@ function serializeAggregateError(
) {
// Serialize the required arguments
ctx.stack.push(node.i);
const serialized = 'new AggregateError(' + serializeTree(ctx, node.n) + ',"' + quote(node.m) + '")';
const serialized = 'new AggregateError(' + serializeNodeList(ctx, node) + ',"' + quote(node.m) + '")';
ctx.stack.pop();
// `AggregateError` might've been extended
// either through class or custom properties
Expand Down
4 changes: 2 additions & 2 deletions packages/seroval/src/tree/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ function generateAggregateErrorNode(
c: undefined,
m: current.message,
d: optionsNode,
a: undefined,
n: parse(ctx, current.errors),
a: generateNodeList(ctx, current.errors as ServerValue[]),
n: undefined,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/seroval/src/tree/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export interface SerovalAggregateErrorNode extends SerovalBaseNode {
t: SerovalNodeType.AggregateError;
m: string;
d: SerovalObjectRecordNode | undefined;
n: SerovalNode;
a: SerovalNode[];
i: number;
}

Expand Down

0 comments on commit 9d686de

Please sign in to comment.