Changeset 79a0317 for imaps-frontend/node_modules/is-string/index.js
- Timestamp:
- 01/21/25 03:08:24 (2 weeks ago)
- Branches:
- main
- Parents:
- 0c6b92a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/is-string/index.js
r0c6b92a r79a0317 1 1 'use strict'; 2 2 3 var strValue = String.prototype.valueOf; 3 var callBound = require('call-bound'); 4 5 /** @type {(receiver: ThisParameterType<typeof String.prototype.valueOf>, ...args: Parameters<typeof String.prototype.valueOf>) => ReturnType<typeof String.prototype.valueOf>} */ 6 var $strValueOf = callBound('String.prototype.valueOf'); 7 8 /** @type {import('.')} */ 4 9 var tryStringObject = function tryStringObject(value) { 5 10 try { 6 strValue.call(value);11 $strValueOf(value); 7 12 return true; 8 13 } catch (e) { … … 10 15 } 11 16 }; 12 var toStr = Object.prototype.toString; 17 /** @type {(receiver: ThisParameterType<typeof Object.prototype.toString>, ...args: Parameters<typeof Object.prototype.toString>) => ReturnType<typeof Object.prototype.toString>} */ 18 var $toString = callBound('Object.prototype.toString'); 13 19 var strClass = '[object String]'; 14 20 var hasToStringTag = require('has-tostringtag/shams')(); 15 21 22 /** @type {import('.')} */ 16 23 module.exports = function isString(value) { 17 24 if (typeof value === 'string') { 18 25 return true; 19 26 } 20 if ( typeof value !== 'object') {27 if (!value || typeof value !== 'object') { 21 28 return false; 22 29 } 23 return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;30 return hasToStringTag ? tryStringObject(value) : $toString(value) === strClass; 24 31 };
Note:
See TracChangeset
for help on using the changeset viewer.