Skip to content

Commit 2af6447

Browse files
committed
allow set for stringMatchesSomePattern
1 parent 811742c commit 2af6447

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/core/src/instrument/console.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ function instrumentConsole(): void {
6868
const firstArg = args[0];
6969
const log = originalConsoleMethods[level];
7070

71-
const isFiltered =
72-
_filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, Array.from(_filter));
71+
const isFiltered = _filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, _filter);
7372

7473
// Only trigger handlers for non-filtered messages
7574
if (!isFiltered) {

packages/core/src/utils/string.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,15 @@ export function isMatchingPattern(
136136
*/
137137
export function stringMatchesSomePattern(
138138
testString: string,
139-
patterns: Array<string | RegExp | ((value: string) => boolean)> = [],
139+
patterns:
140+
| Array<string | RegExp | ((value: string) => boolean)>
141+
| Set<string | RegExp | ((value: string) => boolean)> = [],
140142
requireExactStringMatch: boolean = false,
141143
): boolean {
142-
return patterns.some(pattern => isMatchingPattern(testString, pattern, requireExactStringMatch));
144+
for (const pattern of patterns) {
145+
if (isMatchingPattern(testString, pattern, requireExactStringMatch)) {
146+
return true;
147+
}
148+
}
149+
return false;
143150
}

0 commit comments

Comments
 (0)