Skip to content

Commit

Permalink
Check hasIgnoredPaths first to skip checking indexOf
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Jan 17, 2020
1 parent 00d11d5 commit ee11ed7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/serializableStateInvariantMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ export function findNonSerializableValue(

const entries = getEntries != null ? getEntries(value) : Object.entries(value)

const hasIgnoredPaths = ignoredPaths.length > 0

for (const [property, nestedValue] of entries) {
const nestedPath = path.concat(property)

if (ignoredPaths.indexOf(nestedPath.join('.')) >= 0) {
if (hasIgnoredPaths && ignoredPaths.indexOf(nestedPath.join('.')) >= 0) {
continue
}

Expand Down

0 comments on commit ee11ed7

Please sign in to comment.