Skip to content

Commit 17a6df4

Browse files
committed
[Fix] use has-tostringtag to behave correctly in the presence of symbol shams
See #22
1 parent 31c731c commit 17a6df4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var tryDateObject = function tryDateGetDayCall(value) {
1212

1313
var toStr = Object.prototype.toString;
1414
var dateClass = '[object Date]';
15-
var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag;
15+
var hasToStringTag = require('has-tostringtag/shams')();
1616

1717
module.exports = function isDateObject(value) {
1818
if (typeof value !== 'object' || value === null) {

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"@@toStringTag",
3232
"Date object"
3333
],
34+
"dependencies": {
35+
"has-tostringtag": "^1.0.0"
36+
},
3437
"devDependencies": {
3538
"@ljharb/eslint-config": "^17.6.0",
3639
"aud": "^1.1.5",

test/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var test = require('tape');
44
var isDate = require('../');
5-
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator !== 'undefined';
5+
var hasToStringTag = require('has-tostringtag/shams')();
66

77
test('not Dates', function (t) {
88
t.notOk(isDate(), 'undefined is not Date');
@@ -19,7 +19,7 @@ test('not Dates', function (t) {
1919
t.end();
2020
});
2121

22-
test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) {
22+
test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
2323
var realDate = new Date();
2424
var fakeDate = {
2525
toString: function () { return String(realDate); },

0 commit comments

Comments
 (0)