1 | # is-string <sup>[![Version Badge][2]][1]</sup>
|
---|
2 |
|
---|
3 | [![github actions][actions-image]][actions-url]
|
---|
4 | [![coverage][codecov-image]][codecov-url]
|
---|
5 | [![dependency status][5]][6]
|
---|
6 | [![dev dependency status][7]][8]
|
---|
7 | [![License][license-image]][license-url]
|
---|
8 | [![Downloads][downloads-image]][downloads-url]
|
---|
9 |
|
---|
10 | [![npm badge][11]][1]
|
---|
11 |
|
---|
12 | Is this value a JS String object or primitive? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
|
---|
13 |
|
---|
14 | ## Example
|
---|
15 |
|
---|
16 | ```js
|
---|
17 | var isString = require('is-string');
|
---|
18 | var assert = require('assert');
|
---|
19 |
|
---|
20 | assert.notOk(isString(undefined));
|
---|
21 | assert.notOk(isString(null));
|
---|
22 | assert.notOk(isString(false));
|
---|
23 | assert.notOk(isString(true));
|
---|
24 | assert.notOk(isString(function () {}));
|
---|
25 | assert.notOk(isString([]));
|
---|
26 | assert.notOk(isString({}));
|
---|
27 | assert.notOk(isString(/a/g));
|
---|
28 | assert.notOk(isString(new RegExp('a', 'g')));
|
---|
29 | assert.notOk(isString(new Date()));
|
---|
30 | assert.notOk(isString(42));
|
---|
31 | assert.notOk(isString(NaN));
|
---|
32 | assert.notOk(isString(Infinity));
|
---|
33 | assert.notOk(isString(new Number(42)));
|
---|
34 |
|
---|
35 | assert.ok(isString('foo'));
|
---|
36 | assert.ok(isString(Object('foo')));
|
---|
37 | ```
|
---|
38 |
|
---|
39 | ## Tests
|
---|
40 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
41 |
|
---|
42 | [1]: https://npmjs.org/package/is-string
|
---|
43 | [2]: https://versionbadg.es/inspect-js/is-string.svg
|
---|
44 | [5]: https://david-dm.org/inspect-js/is-string.svg
|
---|
45 | [6]: https://david-dm.org/inspect-js/is-string
|
---|
46 | [7]: https://david-dm.org/inspect-js/is-string/dev-status.svg
|
---|
47 | [8]: https://david-dm.org/inspect-js/is-string#info=devDependencies
|
---|
48 | [11]: https://nodei.co/npm/is-string.png?downloads=true&stars=true
|
---|
49 | [license-image]: https://img.shields.io/npm/l/is-string.svg
|
---|
50 | [license-url]: LICENSE
|
---|
51 | [downloads-image]: https://img.shields.io/npm/dm/is-string.svg
|
---|
52 | [downloads-url]: https://npm-stat.com/charts.html?package=is-string
|
---|
53 | [codecov-image]: https://codecov.io/gh/inspect-js/is-string/branch/main/graphs/badge.svg
|
---|
54 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-string/
|
---|
55 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-string
|
---|
56 | [actions-url]: https://github.com/inspect-js/is-string/actions
|
---|