Skip to content

Commit

Permalink
fix: avoid unnecessary exception on flattenReducer
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjoDiaz committed Nov 7, 2022
1 parent 04867ae commit 8b7dd1e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/plainjs/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getProp(obj, path, defaultValue) {
export function flattenReducer(acc, arr) {
try {
// This is faster but susceptible to `RangeError: Maximum call stack size exceeded`
acc.push(...arr);
Array.isArray(arr) ? acc.push(...arr) : acc.push(arr);
return acc;
} catch (err) {
// Fallback to a slower but safer option
Expand Down
2 changes: 1 addition & 1 deletion packages/transforms/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function unsetProp(obj, path) {
export function flattenReducer(acc, arr) {
try {
// This is faster but susceptible to `RangeError: Maximum call stack size exceeded`
acc.push(...arr);
Array.isArray(arr) ? acc.push(...arr) : acc.push(arr);
return acc;
} catch (err) {
// Fallback to a slower but safer option
Expand Down

0 comments on commit 8b7dd1e

Please sign in to comment.