Skip to content

Commit

Permalink
feat(symbols): Use Reflect.ownKeys for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
gvergnaud committed Aug 11, 2024
1 parent 29f74f9 commit d404e33
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/internals/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,20 @@ export const matchPattern = (
: false;
}

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 Reflect.ownKeys(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 d404e33

Please sign in to comment.