Changeset 79a0317 for imaps-frontend/node_modules/is-symbol/index.js
- Timestamp:
- 01/21/25 03:08:24 (3 days ago)
- Branches:
- main
- Parents:
- 0c6b92a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/is-symbol/index.js
r0c6b92a r79a0317 1 1 'use strict'; 2 2 3 var toStr = Object.prototype.toString; 3 var callBound = require('call-bound'); 4 var $toString = callBound('Object.prototype.toString'); 4 5 var hasSymbols = require('has-symbols')(); 6 var safeRegexTest = require('safe-regex-test'); 5 7 6 8 if (hasSymbols) { 7 var symToStr = Symbol.prototype.toString; 8 var symStringRegex = /^Symbol\(.*\)$/; 9 var $symToStr = callBound('Symbol.prototype.toString'); 10 var isSymString = safeRegexTest(/^Symbol\(.*\)$/); 11 12 /** @type {(value: object) => value is Symbol} */ 9 13 var isSymbolObject = function isRealSymbolObject(value) { 10 14 if (typeof value.valueOf() !== 'symbol') { 11 15 return false; 12 16 } 13 return symStringRegex.test(symToStr.call(value));17 return isSymString($symToStr(value)); 14 18 }; 15 19 20 /** @type {import('.')} */ 16 21 module.exports = function isSymbol(value) { 17 22 if (typeof value === 'symbol') { 18 23 return true; 19 24 } 20 if ( toStr.call(value) !== '[object Symbol]') {25 if (!value || typeof value !== 'object' || $toString(value) !== '[object Symbol]') { 21 26 return false; 22 27 } … … 28 33 }; 29 34 } else { 30 35 /** @type {import('.')} */ 31 36 module.exports = function isSymbol(value) { 32 37 // this environment does not support Symbols.
Note:
See TracChangeset
for help on using the changeset viewer.