Comparing version 1.0.2 to 1.0.4
@@ -0,1 +1,9 @@ | ||
1.0.4 / 2015-01-29 | ||
================= | ||
* If @@toStringTag is not present, use the old-school Object#toString test. | ||
1.0.3 / 2015-01-29 | ||
================= | ||
* Refactor to aid optimization of non-try/catch code. | ||
1.0.2 / 2015-01-29 | ||
@@ -2,0 +10,0 @@ ================= |
14
index.js
'use strict'; | ||
var strValue = String.prototype.valueOf; | ||
module.exports = function isString(value) { | ||
if (typeof value === 'string') { return true; } | ||
if (typeof value !== 'object') { return false; } | ||
var tryStringObject = function tryStringObject(value) { | ||
try { | ||
@@ -15,1 +12,10 @@ strValue.call(value); | ||
}; | ||
var toStr = Object.prototype.toString; | ||
var strClass = '[object String]'; | ||
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; | ||
module.exports = function isString(value) { | ||
if (typeof value === 'string') { return true; } | ||
if (typeof value !== 'object') { return false; } | ||
return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; | ||
}; |
{ | ||
"name": "is-string", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"author": "Jordan Harband", | ||
@@ -5,0 +5,0 @@ "description": "Is this value a JS String object or primitive? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17906
91