Socket
Socket
Sign inDemoInstall

is-string

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-string - npm Package Compare versions

Comparing version 1.0.2 to 1.0.4

8

CHANGELOG.md

@@ -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.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc