You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

4 years ago
  1. # is-date-object <sup>[![Version Badge][2]][1]</sup>
  2. [![Build Status][3]][4]
  3. [![dependency status][5]][6]
  4. [![dev dependency status][7]][8]
  5. [![License][license-image]][license-url]
  6. [![Downloads][downloads-image]][downloads-url]
  7. [![npm badge][11]][1]
  8. [![browser support][9]][10]
  9. Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
  10. ## Example
  11. ```js
  12. var isDate = require('is-date-object');
  13. var assert = require('assert');
  14. assert.notOk(isDate(undefined));
  15. assert.notOk(isDate(null));
  16. assert.notOk(isDate(false));
  17. assert.notOk(isDate(true));
  18. assert.notOk(isDate(42));
  19. assert.notOk(isDate('foo'));
  20. assert.notOk(isDate(function () {}));
  21. assert.notOk(isDate([]));
  22. assert.notOk(isDate({}));
  23. assert.notOk(isDate(/a/g));
  24. assert.notOk(isDate(new RegExp('a', 'g')));
  25. assert.ok(isDate(new Date()));
  26. ```
  27. ## Tests
  28. Simply clone the repo, `npm install`, and run `npm test`
  29. [1]: https://npmjs.org/package/is-date-object
  30. [2]: http://versionbadg.es/ljharb/is-date-object.svg
  31. [3]: https://travis-ci.org/ljharb/is-date-object.svg
  32. [4]: https://travis-ci.org/ljharb/is-date-object
  33. [5]: https://david-dm.org/ljharb/is-date-object.svg
  34. [6]: https://david-dm.org/ljharb/is-date-object
  35. [7]: https://david-dm.org/ljharb/is-date-object/dev-status.svg
  36. [8]: https://david-dm.org/ljharb/is-date-object#info=devDependencies
  37. [9]: https://ci.testling.com/ljharb/is-date-object.png
  38. [10]: https://ci.testling.com/ljharb/is-date-object
  39. [11]: https://nodei.co/npm/is-date-object.png?downloads=true&stars=true
  40. [license-image]: http://img.shields.io/npm/l/is-date-object.svg
  41. [license-url]: LICENSE
  42. [downloads-image]: http://img.shields.io/npm/dm/is-date-object.svg
  43. [downloads-url]: http://npm-stat.com/charts.html?package=is-date-object