Skip to content

Commit 7331cba

Browse files
committed
move stuff around
1 parent fb40c62 commit 7331cba

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

packages/kit/src/runtime/server/page/data_serializer.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ export function server_data_serializer(event, event_state, options) {
5555
str = devalue.uneval([, error], replacer);
5656
}
5757

58-
if (max_nodes > -1 && index >= max_nodes) {
59-
return '';
60-
}
61-
62-
return `${global}.resolve(${id}, ${str.includes('app.decode') ? `(app) => ${str}` : `() => ${str}`})`;
58+
return {
59+
index,
60+
str: `${global}.resolve(${id}, ${str.includes('app.decode') ? `(app) => ${str}` : `() => ${str}`})`
61+
};
6362
}
6463
);
6564

@@ -107,13 +106,18 @@ export function server_data_serializer(event, event_state, options) {
107106
const open = `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>`;
108107
const close = `</script>\n`;
109108

110-
if (max_nodes > -1) {
111-
strings.length = max_nodes;
112-
}
113-
114109
return {
115-
data: `[${strings.join(',')}]`,
116-
chunks: promise_id > 1 ? iterator.iterate((str) => open + str + close) : null
110+
data: `[${(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(',')}]`,
111+
chunks:
112+
promise_id > 1
113+
? iterator.iterate(({ index, str }) => {
114+
if (max_nodes > -1 && index >= max_nodes) {
115+
return '';
116+
}
117+
118+
return open + str + close;
119+
})
120+
: null
117121
};
118122
}
119123
};

0 commit comments

Comments
 (0)