|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var callBound = require('call-bound');
|
|---|
| 4 |
|
|---|
| 5 | /** @type {(receiver: ThisParameterType<typeof String.prototype.valueOf>, ...args: Parameters<typeof String.prototype.valueOf>) => ReturnType<typeof String.prototype.valueOf>} */
|
|---|
| 6 | var $strValueOf = callBound('String.prototype.valueOf');
|
|---|
| 7 |
|
|---|
| 8 | /** @type {import('.')} */
|
|---|
| 9 | var tryStringObject = function tryStringObject(value) {
|
|---|
| 10 | try {
|
|---|
| 11 | $strValueOf(value);
|
|---|
| 12 | return true;
|
|---|
| 13 | } catch (e) {
|
|---|
| 14 | return false;
|
|---|
| 15 | }
|
|---|
| 16 | };
|
|---|
| 17 | /** @type {(receiver: ThisParameterType<typeof Object.prototype.toString>, ...args: Parameters<typeof Object.prototype.toString>) => ReturnType<typeof Object.prototype.toString>} */
|
|---|
| 18 | var $toString = callBound('Object.prototype.toString');
|
|---|
| 19 | var strClass = '[object String]';
|
|---|
| 20 | var hasToStringTag = require('has-tostringtag/shams')();
|
|---|
| 21 |
|
|---|
| 22 | /** @type {import('.')} */
|
|---|
| 23 | module.exports = function isString(value) {
|
|---|
| 24 | if (typeof value === 'string') {
|
|---|
| 25 | return true;
|
|---|
| 26 | }
|
|---|
| 27 | if (!value || typeof value !== 'object') {
|
|---|
| 28 | return false;
|
|---|
| 29 | }
|
|---|
| 30 | return hasToStringTag ? tryStringObject(value) : $toString(value) === strClass;
|
|---|
| 31 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.