main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
560 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var strValue = String.prototype.valueOf;
|
---|
4 | var tryStringObject = function tryStringObject(value) {
|
---|
5 | try {
|
---|
6 | strValue.call(value);
|
---|
7 | return true;
|
---|
8 | } catch (e) {
|
---|
9 | return false;
|
---|
10 | }
|
---|
11 | };
|
---|
12 | var toStr = Object.prototype.toString;
|
---|
13 | var strClass = '[object String]';
|
---|
14 | var hasToStringTag = require('has-tostringtag/shams')();
|
---|
15 |
|
---|
16 | module.exports = function isString(value) {
|
---|
17 | if (typeof value === 'string') {
|
---|
18 | return true;
|
---|
19 | }
|
---|
20 | if (typeof value !== 'object') {
|
---|
21 | return false;
|
---|
22 | }
|
---|
23 | return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;
|
---|
24 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.