Skip to content

Commit

Permalink
chore: use .concat for better perfs (1 less creation of arrays)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayc0 committed Aug 8, 2024
1 parent 423b75b commit 7f2aaf3
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/internals/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,22 @@ export const matchPattern = (
: false;
}

return [
...Object.getOwnPropertySymbols(pattern),
...Object.keys(pattern),
].every((k: string | symbol): boolean => {
// @ts-ignore
const subPattern = pattern[k];

return (
(k in value || isOptionalPattern(subPattern)) &&
matchPattern(
subPattern,
// @ts-ignore
value[k],
select
)
);
});
return (Object.keys(pattern) as Array<string | symbol>)
.concat(Object.getOwnPropertySymbols(pattern))
.every((k: string | symbol): boolean => {
// @ts-ignore
const subPattern = pattern[k];

return (
(k in value || isOptionalPattern(subPattern)) &&
matchPattern(
subPattern,
// @ts-ignore
value[k],
select
)
);
});
}

return Object.is(value, pattern);
Expand Down

0 comments on commit 7f2aaf3

Please sign in to comment.