is-date-object
Advanced tools
Comparing version
{ | ||
"es3": true, | ||
"additionalRules": [], | ||
"requireSemicolons": true, | ||
"disallowMultipleSpaces": true, | ||
"disallowIdentifierNames": [], | ||
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], | ||
@@ -10,2 +18,14 @@ | ||
"disallowSpaceBeforeComma": true, | ||
"disallowSpaceBeforeSemicolon": true, | ||
"disallowNodeTypes": [ | ||
"DebuggerStatement", | ||
"ForInStatement", | ||
"LabeledStatement", | ||
"SwitchCase", | ||
"SwitchStatement", | ||
"WithStatement" | ||
], | ||
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, | ||
@@ -67,4 +87,38 @@ "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, | ||
"mark": "'" | ||
} | ||
}, | ||
"disallowOperatorBeforeLineBreak": [], | ||
"requireSpaceBeforeKeywords": [ | ||
"do", | ||
"for", | ||
"if", | ||
"else", | ||
"switch", | ||
"case", | ||
"try", | ||
"catch", | ||
"finally", | ||
"while", | ||
"with", | ||
"return" | ||
], | ||
"validateAlignedFunctionParameters": { | ||
"lineBreakAfterOpeningBraces": true, | ||
"lineBreakBeforeClosingBraces": true | ||
}, | ||
"requirePaddingNewLinesBeforeExport": true, | ||
"validateNewlineAfterArrayElements": { | ||
"maximum": 1 | ||
}, | ||
"requirePaddingNewLinesAfterUseStrict": true, | ||
"disallowArrowFunctions": true, | ||
"validateOrderInObjectKeys": "asc-insensitive" | ||
} | ||
@@ -0,3 +1,10 @@ | ||
1.0.1 / 2015-09-27 | ||
================= | ||
* [Fix] If `@@toStringTag` is not present, use the old-school `Object#toString` test | ||
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG | ||
* [Dev Deps] update `is`, `eslint`, `@ljharb/eslint-config`, `semver`, `tape`, `jscs`, `nsp`, `covert` | ||
* [Tests] up to `io.js` `v3.3`, `node` `v4.1` | ||
1.0.0 / 2015-01-28 | ||
================= | ||
* Initial release. |
12
index.js
'use strict'; | ||
var getDay = Date.prototype.getDay; | ||
module.exports = function isDateObject(value) { | ||
var tryDateObject = function tryDateObject(value) { | ||
try { | ||
@@ -13,1 +12,10 @@ getDay.call(value); | ||
}; | ||
var toStr = Object.prototype.toString; | ||
var dateClass = '[object Date]'; | ||
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; | ||
module.exports = function isDateObject(value) { | ||
if (typeof value !== 'object' || value === null) { return false; } | ||
return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass; | ||
}; |
{ | ||
"name": "is-date-object", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Jordan Harband", | ||
@@ -15,3 +15,2 @@ "description": "Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", | ||
"eslint": "eslint test.js *.js", | ||
"eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", | ||
"security": "nsp package" | ||
@@ -32,12 +31,12 @@ }, | ||
"devDependencies": { | ||
"foreach": "~2.0.5", | ||
"is": "~2.2.0", | ||
"tape": "~3.4.0", | ||
"indexof": "~0.0.1", | ||
"covert": "1.0.0", | ||
"jscs": "~1.10.0", | ||
"editorconfig-tools": "~0.0.1", | ||
"nsp": "~1.0.0", | ||
"eslint": "~0.12.0", | ||
"semver": "~4.2.0" | ||
"foreach": "^2.0.5", | ||
"is": "^3.1.0", | ||
"tape": "^4.2.0", | ||
"indexof": "^0.0.1", | ||
"covert": "^1.1.0", | ||
"jscs": "^2.1.1", | ||
"nsp": "^1.1.0", | ||
"eslint": "^1.5.1", | ||
"@ljharb/eslint-config": "^1.2.0", | ||
"semver": "^5.0.3" | ||
}, | ||
@@ -44,0 +43,0 @@ "testling": { |
@@ -40,3 +40,3 @@ # is-date-object <sup>[![Version Badge][2]][1]</sup> | ||
[1]: https://npmjs.org/package/is-date-object | ||
[2]: http://vb.teelaun.ch/ljharb/is-date-object.svg | ||
[2]: http://versionbadg.es/ljharb/is-date-object.svg | ||
[3]: https://travis-ci.org/ljharb/is-date-object.svg | ||
@@ -43,0 +43,0 @@ [4]: https://travis-ci.org/ljharb/is-date-object |
@@ -24,4 +24,4 @@ 'use strict'; | ||
var realDate = new Date(); | ||
var fakeDate = { valueOf: function () { return realDate.getTime(); }, toString: function () { return String(realDate); } }; | ||
fakeDate[Symbol.toStringTag] = function () { return 'Date'; }; | ||
var fakeDate = { toString: function () { return String(realDate); }, valueOf: function () { return realDate.getTime(); } }; | ||
fakeDate[Symbol.toStringTag] = 'Date'; | ||
t.notOk(isDate(fakeDate), 'fake Date with @@toStringTag "Date" is not Date'); | ||
@@ -28,0 +28,0 @@ t.end(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
127
58.75%14959
-10.68%