Skip to content

Commit f3c2074

Browse files
committed
[Robustness] cache Symbol.prototype.toString
1 parent a492bec commit f3c2074

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
@@ -15,6 +15,7 @@ var objectToString = Object.prototype.toString;
1515
var functionToString = Function.prototype.toString;
1616
var match = String.prototype.match;
1717
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
18+
var symToString = typeof Symbol === 'function' ? Symbol.prototype.toString : null;
1819

1920
var inspectCustom = require('./util.inspect').custom;
2021
var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
@@ -106,7 +107,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
106107
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']';
107108
}
108109
if (isSymbol(obj)) {
109-
var symString = Symbol.prototype.toString.call(obj);
110+
var symString = symToString.call(obj);
110111
return typeof obj === 'object' ? markBoxed(symString) : symString;
111112
}
112113
if (isElement(obj)) {

0 commit comments

Comments
 (0)