is-string
Is this value a JS String object or primitive? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
Last updated 7 months ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install is-string 
SYNC missed versions from official npm registry.

is-string Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

Is this value a JS String object or primitive? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

Example

var isString = require('is-string');
var assert = require('assert');

assert.notOk(isString(undefined));
assert.notOk(isString(null));
assert.notOk(isString(false));
assert.notOk(isString(true));
assert.notOk(isString(function () {}));
assert.notOk(isString([]));
assert.notOk(isString({}));
assert.notOk(isString(/a/g));
assert.notOk(isString(new RegExp('a', 'g')));
assert.notOk(isString(new Date()));
assert.notOk(isString(42));
assert.notOk(isString(NaN));
assert.notOk(isString(Infinity));
assert.notOk(isString(new Number(42)));

assert.ok(isString('foo'));
assert.ok(isString(Object('foo')));

Tests

Simply clone the repo, npm install, and run npm test

Current Tags

  • 1.0.5                                ...           latest (7 months ago)

5 Versions

  • 1.0.5                                ...           7 months ago
  • 1.0.4                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 662
This Week 18,729
This Month 80,913
Last Day 18,067
Last Week 96,885
Last Month 408,722
Dependencies (0)
None
Dev Dependencies (10)
Dependents (192)

Copyright 2014 - 2017 © taobao.org |