source: imaps-frontend/node_modules/is-date-object/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 674 bytes
Line 
1'use strict';
2
3var callBound = require('call-bound');
4
5var getDay = callBound('Date.prototype.getDay');
6/** @type {import('.')} */
7var tryDateObject = function tryDateGetDayCall(value) {
8 try {
9 getDay(value);
10 return true;
11 } catch (e) {
12 return false;
13 }
14};
15
16/** @type {(value: unknown) => string} */
17var toStr = callBound('Object.prototype.toString');
18var dateClass = '[object Date]';
19var hasToStringTag = require('has-tostringtag/shams')();
20
21/** @type {import('.')} */
22module.exports = function isDateObject(value) {
23 if (typeof value !== 'object' || value === null) {
24 return false;
25 }
26 return hasToStringTag ? tryDateObject(value) : toStr(value) === dateClass;
27};
Note: See TracBrowser for help on using the repository browser.