|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
674 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var callBound = require('call-bound');
|
|---|
| 4 |
|
|---|
| 5 | var getDay = callBound('Date.prototype.getDay');
|
|---|
| 6 | /** @type {import('.')} */
|
|---|
| 7 | var 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} */
|
|---|
| 17 | var toStr = callBound('Object.prototype.toString');
|
|---|
| 18 | var dateClass = '[object Date]';
|
|---|
| 19 | var hasToStringTag = require('has-tostringtag/shams')();
|
|---|
| 20 |
|
|---|
| 21 | /** @type {import('.')} */
|
|---|
| 22 | module.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.