![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/is-string/test/ |
'use strict';
var test = require('tape');
var isString = require('../');
var hasToStringTag = require('has-tostringtag/shams')();
test('not Strings', function (t) {
// @ts-expect-error
t.notOk(isString(), 'undefined is not String');
t.notOk(isString(null), 'null is not String');
t.notOk(isString(false), 'false is not String');
t.notOk(isString(true), 'true is not String');
t.notOk(isString([]), 'array is not String');
t.notOk(isString({}), 'object is not String');
t.notOk(isString(function () {}), 'function is not String');
t.notOk(isString(/a/g), 'regex literal is not String');
t.notOk(isString(new RegExp('a', 'g')), 'regex object is not String');
t.notOk(isString(new Date()), 'new Date() is not String');
t.notOk(isString(42), 'number is not String');
t.notOk(isString(Object(42)), 'number object is not String');
t.notOk(isString(NaN), 'NaN is not String');
t.notOk(isString(Infinity), 'Infinity is not String');
t.end();
});
test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
/** @type {{ toString(): unknown; valueOf(): unknown; [Symbol.toStringTag]?: string; }} */
var fakeString = {
toString: function () { return '7'; },
valueOf: function () { return '42'; }
};
fakeString[Symbol.toStringTag] = 'String';
t.notOk(isString(fakeString), 'fake String with @@toStringTag "String" is not String');
t.end();
});
test('Strings', function (t) {
t.ok(isString('foo'), 'string primitive is String');
t.ok(isString(Object('foo')), 'string object is String');
t.end();
});