github-pages-deploy-action/node_modules/is-date-object/index.js

23 lines
558 B
JavaScript
Raw Normal View History

2020-01-28 13:07:56 +08:00
'use strict';
var getDay = Date.prototype.getDay;
2020-03-22 05:13:25 +08:00
var tryDateObject = function tryDateGetDayCall(value) {
2020-01-28 13:07:56 +08:00
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) {
2020-03-22 05:13:25 +08:00
if (typeof value !== 'object' || value === null) {
return false;
}
2020-01-28 13:07:56 +08:00
return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
};