Skip to content

Commit a314ab8

Browse files
committed
[Robustness] cache RegExp.prototype.test
1 parent 6732a40 commit a314ab8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var booleanValueOf = Boolean.prototype.valueOf;
1616
var objectToString = Object.prototype.toString;
1717
var functionToString = Function.prototype.toString;
1818
var match = String.prototype.match;
19+
var test = RegExp.prototype.test;
1920
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
2021
var gOPS = Object.getOwnPropertySymbols;
2122
var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
@@ -454,7 +455,7 @@ function arrObjKeys(obj, inspect) {
454455
if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
455456
// this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
456457
continue; // eslint-disable-line no-restricted-syntax, no-continue
457-
} else if ((/[^\w$]/).test(key)) {
458+
} else if (test.call(/[^\w$]/, key)) {
458459
xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
459460
} else {
460461
xs.push(key + ': ' + inspect(obj[key], obj));

0 commit comments

Comments
 (0)