You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
636 B
JavaScript

'use strict';
/* Derived from `is-string 1.0.7`, under MIT license, (c) 2015 Jordan Harband.
This version removes the try/catch for performance reasons, and replaces it with a test that unfortunately does not work on cross-realm values, pending an upstream fix. */
var toStr = Object.prototype.toString;
var strClass = '[object String]';
var hasToStringTag = require('has-tostringtag/shams')();
module.exports = function isString(value) {
if (typeof value === 'string') {
return true;
}
if (typeof value !== 'object') {
return false;
}
return hasToStringTag ? value instanceof String : toStr.call(value) === strClass;
};