diff options
Diffstat (limited to 'src/node_modules/is-date-object/index.js')
-rw-r--r-- | src/node_modules/is-date-object/index.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/node_modules/is-date-object/index.js b/src/node_modules/is-date-object/index.js new file mode 100644 index 0000000..285ec4c --- /dev/null +++ b/src/node_modules/is-date-object/index.js @@ -0,0 +1,22 @@ +'use strict'; + +var getDay = Date.prototype.getDay; +var tryDateObject = function tryDateGetDayCall(value) { + try { + getDay.call(value); + return true; + } catch (e) { + return false; + } +}; + +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; +}; |