Skip to content

Commit

Permalink
Move isArray check higher
Browse files Browse the repository at this point in the history
It's much more likely to be an array than Map or TypedArray.
  • Loading branch information
sebmarkbage committed Oct 11, 2023
1 parent 748ab8a commit ff89f2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/react-client/src/ReactFlightReplyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export function processReply(
);
return serializePromiseID(promiseId);
}
if (isArray(value)) {
// $FlowFixMe[incompatible-return]
return value;
}
// TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
if (value instanceof FormData) {
if (formData === null) {
Expand Down Expand Up @@ -266,10 +270,6 @@ export function processReply(
formData.append(formFieldPrefix + setId, partJSON);
return serializeSetID(setId);
}
if (isArray(value)) {
// $FlowFixMe[incompatible-return]
return value;
}
const iteratorFn = getIteratorFn(value);
if (iteratorFn) {
return Array.from((value: any));
Expand Down
10 changes: 5 additions & 5 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,11 @@ function resolveModelToJSON(
return (undefined: any);
}

if (isArray(value)) {
// $FlowFixMe[incompatible-return]
return value;
}

if (value instanceof Map) {
return serializeMap(request, value);
}
Expand Down Expand Up @@ -1110,11 +1115,6 @@ function resolveModelToJSON(
}
}

if (isArray(value)) {
// $FlowFixMe[incompatible-return]
return value;
}

const iteratorFn = getIteratorFn(value);
if (iteratorFn) {
return Array.from((value: any));
Expand Down

0 comments on commit ff89f2b

Please sign in to comment.