source: imaps-frontend/node_modules/is-string/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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