├── .editorconfig ├── .eslintrc ├── .github ├── FUNDING.yml └── workflows │ ├── node-aught.yml │ ├── node-pretest.yml │ ├── node-tens.yml │ ├── node-twenties.yml │ ├── rebase.yml │ └── require-allow-edits.yml ├── .gitignore ├── .npmrc ├── .nycrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── index.d.ts ├── index.js ├── package.json ├── test-corejs.js ├── test └── index.js └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | max_line_length = 150 11 | 12 | [CHANGELOG.md] 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.json] 17 | max_line_length = off 18 | 19 | [Makefile] 20 | max_line_length = off 21 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | 4 | "extends": "@ljharb", 5 | 6 | "rules": { 7 | //"max-statements": [2, 12] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [ljharb] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: npm/is-date-object 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/workflows/node-aught.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js < 10' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | tests: 7 | uses: ljharb/actions/.github/workflows/node.yml@main 8 | with: 9 | range: '< 10' 10 | type: minors 11 | command: npm run tests-only 12 | 13 | node: 14 | name: 'node < 10' 15 | needs: [tests] 16 | runs-on: ubuntu-latest 17 | steps: 18 | - run: 'echo tests completed' 19 | -------------------------------------------------------------------------------- /.github/workflows/node-pretest.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: pretest/posttest' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | tests: 7 | uses: ljharb/actions/.github/workflows/pretest.yml@main 8 | -------------------------------------------------------------------------------- /.github/workflows/node-tens.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js 10 - 20' 2 | 3 | on: [pull_request, push] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | tests: 10 | uses: ljharb/actions/.github/workflows/node.yml@main 11 | with: 12 | range: '>= 10 < 20' 13 | type: minors 14 | command: npm run tests-only 15 | 16 | node: 17 | name: 'node 10 - 20' 18 | needs: [tests] 19 | runs-on: ubuntu-latest 20 | steps: 21 | - run: true 22 | 23 | -------------------------------------------------------------------------------- /.github/workflows/node-twenties.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js >= 20' 2 | 3 | on: [pull_request, push] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | tests: 10 | uses: ljharb/actions/.github/workflows/node.yml@main 11 | with: 12 | range: '>= 20' 13 | type: minors 14 | command: npm run tests-only 15 | 16 | node: 17 | name: 'node >= 20' 18 | needs: [tests] 19 | runs-on: ubuntu-latest 20 | steps: 21 | - run: true 22 | 23 | -------------------------------------------------------------------------------- /.github/workflows/rebase.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Rebase 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | uses: ljharb/actions/.github/workflows/rebase.yml@main 8 | secrets: 9 | token: ${{ secrets.GITHUB_TOKEN }} 10 | -------------------------------------------------------------------------------- /.github/workflows/require-allow-edits.yml: -------------------------------------------------------------------------------- 1 | name: Require “Allow Edits” 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | name: "Require “Allow Edits”" 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: ljharb/require-allow-edits@main 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | .nyc_output/ 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # Compiled binary addons (http://nodejs.org/api/addons.html) 21 | build/Release 22 | 23 | # Dependency directory 24 | # Commenting this out is preferred by some people, see 25 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 26 | node_modules 27 | 28 | # Users Environment Variables 29 | .lock-wscript 30 | 31 | # Only apps should have lockfiles 32 | npm-shrinkwrap.json 33 | package-lock.json 34 | yarn.lock 35 | 36 | .npmignore 37 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | allow-same-version=true 3 | message=v%s 4 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "all": true, 3 | "check-coverage": false, 4 | "reporter": ["text-summary", "text", "html", "json"], 5 | "exclude": [ 6 | "coverage", 7 | "test", 8 | "test-corejs.js" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [v1.1.0](https://github.com/inspect-js/is-date-object/compare/v1.0.5...v1.1.0) - 2024-12-12 9 | 10 | ### Commits 11 | 12 | - [actions] reuse common workflows [`35c5af0`](https://github.com/inspect-js/is-date-object/commit/35c5af06344e8707b82f0ae24821e0a2a0cfb02d) 13 | - [meta] use `npmignore` to autogenerate an npmignore file [`db6113c`](https://github.com/inspect-js/is-date-object/commit/db6113c3b98c9be87038d9b11a39166554f6c2b0) 14 | - [New] add types [`4f1d9b3`](https://github.com/inspect-js/is-date-object/commit/4f1d9b3d1908d5bfd536128fe8fa49e16fd48761) 15 | - [actions] split out node 10-20, and 20+ [`c9a1e4f`](https://github.com/inspect-js/is-date-object/commit/c9a1e4f1fd50277ef85f04ee293795e433436f8c) 16 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `core-js`, `safe-publish-latest`, `tape` [`35a2864`](https://github.com/inspect-js/is-date-object/commit/35a2864ac5913ae6d14d80398cc5910abf4c528d) 17 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`b670bca`](https://github.com/inspect-js/is-date-object/commit/b670bcafec01141b5f2ba6e3ea22bde4124d0a2e) 18 | - [actions] update rebase action to use reusable workflow [`d6bb341`](https://github.com/inspect-js/is-date-object/commit/d6bb34105613962581bfd7509ee7cc02110b6890) 19 | - [actions] update codecov uploader [`f850678`](https://github.com/inspect-js/is-date-object/commit/f8506786159dc9072c62c77e6609ad7db14551af) 20 | - [Robustness] use `call-bound` [`18ed326`](https://github.com/inspect-js/is-date-object/commit/18ed326470e86ffc66ea3cd3e642f44a7036948e) 21 | - [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `core-js`, `npmignore`, `tape` [`f0e792f`](https://github.com/inspect-js/is-date-object/commit/f0e792f7b13b0f9567fbb607fc90278e52377a0f) 22 | - [meta] add `exports` field [`342351f`](https://github.com/inspect-js/is-date-object/commit/342351f37f3ed823ea7d7da2aa32099e6eb00852) 23 | - [Tests] replace `aud` with `npm audit` [`9b9b9cf`](https://github.com/inspect-js/is-date-object/commit/9b9b9cf665114a211b682402e10486bf2c89bdfa) 24 | - [Deps] update `has-tostringtag` [`1bc37ab`](https://github.com/inspect-js/is-date-object/commit/1bc37ab6e8122aecc2a4283e1b3920c61c8d272e) 25 | - [meta] add `sideEffects` flag [`86d3a16`](https://github.com/inspect-js/is-date-object/commit/86d3a16d65376ac84d98c8aa55ff7b01cfd01ee9) 26 | - [Dev Deps] add missing peer dep [`fee274d`](https://github.com/inspect-js/is-date-object/commit/fee274dc177e09823cb69dbcb805cbd4be7a386e) 27 | 28 | ## [v1.0.5](https://github.com/inspect-js/is-date-object/compare/v1.0.4...v1.0.5) - 2021-08-05 29 | 30 | ### Commits 31 | 32 | - [meta] remove `.jscs.json` [`31c731c`](https://github.com/inspect-js/is-date-object/commit/31c731c5efc5b1b86e6426d904373dc6225b929f) 33 | - [Fix] use `has-tostringtag` to behave correctly in the presence of symbol shams [`17a6df4`](https://github.com/inspect-js/is-date-object/commit/17a6df4a3ab9bcb1395a638ced14f571f9549427) 34 | - [Dev Deps] update `eslint`, `auto-changelog`, `tape` [`79db3af`](https://github.com/inspect-js/is-date-object/commit/79db3af1a745042a0a11e03c7dd7db910b5e0d01) 35 | 36 | ## [v1.0.4](https://github.com/inspect-js/is-date-object/compare/v1.0.3...v1.0.4) - 2021-05-07 37 | 38 | ### Commits 39 | 40 | - [Fix] do not use `Object.prototype.toString` when `Symbol.toStringTag` is shammed [`8943a4a`](https://github.com/inspect-js/is-date-object/commit/8943a4a5035b3f2c8cee9a5edabb55579c16983d) 41 | - [readme] make all URLs https [`1d4d6cd`](https://github.com/inspect-js/is-date-object/commit/1d4d6cd37365c3a36f98e3f82cfe6262227437db) 42 | - [Dev Deps] update `eslint` [`a7abeaa`](https://github.com/inspect-js/is-date-object/commit/a7abeaa2409d3a34fccebcb5b362e0b90d0a8883) 43 | 44 | ## [v1.0.3](https://github.com/inspect-js/is-date-object/compare/v1.0.2...v1.0.3) - 2021-05-05 45 | 46 | ### Commits 47 | 48 | - [Tests] migrate tests to Github Actions [`023504f`](https://github.com/inspect-js/is-date-object/commit/023504f4d48fc8788ff52ee525a1d9ec74fa7df5) 49 | - [readme] add actions and codecov badges [`e63305f`](https://github.com/inspect-js/is-date-object/commit/e63305f2fb9ff3eb0dab7e0716585507a4f95a75) 50 | - [meta] do not publish github action workflow files [`017d906`](https://github.com/inspect-js/is-date-object/commit/017d90679b6b1c16b398c0157904f91f56160219) 51 | - [Tests] run `nyc` on all tests [`0376b6f`](https://github.com/inspect-js/is-date-object/commit/0376b6fb7a0ffcc42107c3c579ba0b3ab635b9e4) 52 | - [readme] fix repo URLs; remove defunct badges [`1c148c6`](https://github.com/inspect-js/is-date-object/commit/1c148c6cb6eb0892b3186e814df3367dabb9732d) 53 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`c7a3f54`](https://github.com/inspect-js/is-date-object/commit/c7a3f54a207a6056ffafaa58178889ea1b1b77f7) 54 | - [actions] add "Allow Edits" workflow [`e79b5b2`](https://github.com/inspect-js/is-date-object/commit/e79b5b25c173c3201e8b42a614d5f12c48b74a86) 55 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`da28980`](https://github.com/inspect-js/is-date-object/commit/da28980c5fe86528585b2a420319ca8fc35f763a) 56 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`5cabae9`](https://github.com/inspect-js/is-date-object/commit/5cabae9f00bf458a470bde68b734540b8ab78c3b) 57 | - [readme] add actions and codecov badges [`33dfb88`](https://github.com/inspect-js/is-date-object/commit/33dfb881b7abf668cd3bf956e2947a1ece552f25) 58 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`745eb04`](https://github.com/inspect-js/is-date-object/commit/745eb0462ef3838df65f41f4a95453cc4f0aa06e) 59 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`466c62b`](https://github.com/inspect-js/is-date-object/commit/466c62b45af5a5a83963f6ef8617da887b0ab272) 60 | - [actions] use checkout v2; remove unneeded env [`ff87a16`](https://github.com/inspect-js/is-date-object/commit/ff87a161e36d76d081d70933bf801a357c3b25fe) 61 | - [Dev Deps] update `auto-changelog`, `tape` [`93188f5`](https://github.com/inspect-js/is-date-object/commit/93188f58e4b2c2b5e978a61a45380101d01f9838) 62 | - [meta] use `prepublishOnly` script for npm 7+ [`1d0e3ea`](https://github.com/inspect-js/is-date-object/commit/1d0e3ea672971f02bb48c88b49079789ab41f574) 63 | - [actions] update workflows [`4d1a235`](https://github.com/inspect-js/is-date-object/commit/4d1a2358de35a9fbe23a1dee10735748ed276301) 64 | - [Dev Deps] update `auto-changelog`; add `aud` [`67be59a`](https://github.com/inspect-js/is-date-object/commit/67be59aa3c0ba44b982aaefb7e42adfb14eb279b) 65 | - [actions] switch Automatic Rebase workflow to `pull_request_target` event [`a6661c2`](https://github.com/inspect-js/is-date-object/commit/a6661c26af701a7782f6e06ad1b34587ce2b09bc) 66 | - [Tests] only audit prod deps [`dd4a47f`](https://github.com/inspect-js/is-date-object/commit/dd4a47f8bcf82c3090826d890a7766f50d6f7af9) 67 | 68 | ## [v1.0.2](https://github.com/inspect-js/is-date-object/compare/v1.0.1...v1.0.2) - 2019-12-18 69 | 70 | ### Commits 71 | 72 | - [Tests] use shared travis-ci configs [`8a378b8`](https://github.com/inspect-js/is-date-object/commit/8a378b8fd6a4202fffc9ec193aca02efe937bc35) 73 | - [Tests] on all node minors; use `nvm install-latest-npm`; fix scripts; improve matrix [`6e97a21`](https://github.com/inspect-js/is-date-object/commit/6e97a21276cf448ce424fb9ea13edd4587f289f1) 74 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `is`, `jscs`, `nsp`, `semver`, `tape` [`8472b90`](https://github.com/inspect-js/is-date-object/commit/8472b90f82e5153c22e7a8a7726a5cc6110e93d7) 75 | - [Tests] up to `node` `v10.0`, `v9.11`, `v8.11`, `v6.14`, `v4.9` [`ae73e38`](https://github.com/inspect-js/is-date-object/commit/ae73e3890df7da0bc4449088e30340cb4df3294d) 76 | - [meta] add `auto-changelog` [`82f8f47`](https://github.com/inspect-js/is-date-object/commit/82f8f473a6ee45e2b66810cb743e0122c18381c5) 77 | - [meta] remove unused Makefile and associated utilities [`788a2cd`](https://github.com/inspect-js/is-date-object/commit/788a2cdfd0bc8f1903967219897f6d00c4c6a26b) 78 | - [Tests] up to `node` `v11.4`, `v10.14`, `v8.14`, `v6.15` [`b9caf7c`](https://github.com/inspect-js/is-date-object/commit/b9caf7c814e5e2549454cb444f8b739f9ce1a388) 79 | - [Tests] up to `node` `v12.4`, `v11.15`, `v10.15`, `v8.15`, `v6.17`; use `nvm install-latest-npm` [`cda0abc`](https://github.com/inspect-js/is-date-object/commit/cda0abc04a21c9b5ec72eabd010155c988032056) 80 | - [Tests] up to `node` `v12.10`, `v10.16`, `v8.16` [`49bc482`](https://github.com/inspect-js/is-date-object/commit/49bc482fd9f71436b663c07144083a8423697299) 81 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver`, `tape`; add `safe-publish-latest` [`f77fec4`](https://github.com/inspect-js/is-date-object/commit/f77fec48057e156b2276b4c14cf303306116b9f6) 82 | - [actions] add automatic rebasing / merge commit blocking [`68605fc`](https://github.com/inspect-js/is-date-object/commit/68605fcb6bc0341ff0aae14a94bf5d18e1bc73be) 83 | - [meta] create FUNDING.yml [`4f82d88`](https://github.com/inspect-js/is-date-object/commit/4f82d88e1e6ac1b97f0ce96aa0aa057ad758a581) 84 | - [Dev Deps] update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`3cbf28a`](https://github.com/inspect-js/is-date-object/commit/3cbf28a185ced940cfce8a09fa8479cc83575876) 85 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config@`, `is`, `semver`, `tape` [`abf9fb0`](https://github.com/inspect-js/is-date-object/commit/abf9fb0d55ef0697e64e888d74f2e5fe53d7cdcb) 86 | - [Tests] switch from `nsp` to `npm audit` [`6543c7d`](https://github.com/inspect-js/is-date-object/commit/6543c7d559d1fb79215b46c8b79e0e3e2a83f5de) 87 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `tape` [`ba5d2d7`](https://github.com/inspect-js/is-date-object/commit/ba5d2d7fc0975d7c03b8f2b7f43a09af93e365ba) 88 | - [Dev Deps] update `eslint`, `nsp`, `semver`, `tape` [`c1e3525`](https://github.com/inspect-js/is-date-object/commit/c1e3525afa76a696f7cf1b58aab7f55d220b2c20) 89 | - [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops [`14e4824`](https://github.com/inspect-js/is-date-object/commit/14e4824188c85207ed3b86627b09e9f64b135db7) 90 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` [`68ead64`](https://github.com/inspect-js/is-date-object/commit/68ead64a07e0de282ea3cd38e12cc8b0e0f6d3cd) 91 | - [Dev Deps] update `eslint`, semver`, `tape`, `semver` [`f55453f`](https://github.com/inspect-js/is-date-object/commit/f55453f200903277465d7e9307a9c49120a4f419) 92 | - Only apps should have lockfiles [`6c848eb`](https://github.com/inspect-js/is-date-object/commit/6c848eba982cc58053d4cca08c01f12a433f3695) 93 | - [Tests] remove `jscs` [`3fd3a62`](https://github.com/inspect-js/is-date-object/commit/3fd3a62121607ad074b7fc977f3fc6575b66f755) 94 | - [Dev Deps] update `eslint`, `tape` [`77d3130`](https://github.com/inspect-js/is-date-object/commit/77d3130a0039e5dae24c17de790dd510c265edc6) 95 | - [meta] add `funding` field [`9ef6d58`](https://github.com/inspect-js/is-date-object/commit/9ef6d5888bf829a5812b3b091dc99839d48c355e) 96 | 97 | ## [v1.0.1](https://github.com/inspect-js/is-date-object/compare/v1.0.0...v1.0.1) - 2015-09-27 98 | 99 | ### Commits 100 | 101 | - Update `tape`, `semver`, `eslint`; use my personal shared `eslint` config. [`731aa13`](https://github.com/inspect-js/is-date-object/commit/731aa134b0b8dc84e302d0b2264a415cb456ccab) 102 | - Update `is`, `tape`, `covert`, `jscs`, `editorconfig-tools`, `nsp`, `eslint`, `semver` [`53e43a6`](https://github.com/inspect-js/is-date-object/commit/53e43a627dd01757cf3d469599f3dffd9d72b150) 103 | - Update `eslint` [`d2fc304`](https://github.com/inspect-js/is-date-object/commit/d2fc3046f087b0026448ffde0cf46b1f741cbd4e) 104 | - Update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`c9568df`](https://github.com/inspect-js/is-date-object/commit/c9568df228fa698dc6fcc9553b5d612e7ee427aa) 105 | - Test on latest `node` and `io.js` versions. [`a21d537`](https://github.com/inspect-js/is-date-object/commit/a21d537562166ebd18bde3a262fd157dd774ae17) 106 | - Update `nsp`, `eslint`, `semver` [`9e1d908`](https://github.com/inspect-js/is-date-object/commit/9e1d9087c0c79c34fcb2abfc701cdfa1efcb327c) 107 | - Update `covert`, `jscs`, `eslint`, `semver` [`f198f6b`](https://github.com/inspect-js/is-date-object/commit/f198f6b997912da10a3d821a089e1581edc730a0) 108 | - [Dev Deps] update `tape`, `jscs`, `eslint` [`ab9bdbb`](https://github.com/inspect-js/is-date-object/commit/ab9bdbbc189cef033346508db47cd1feb04a69d3) 109 | - If `@@toStringTag` is not present, use the old-school `Object#toString` test. [`c03afce`](https://github.com/inspect-js/is-date-object/commit/c03afce001368b29eb929900075749b113a252c8) 110 | - [Dev Deps] update `jscs`, `nsp`, `tape`, `eslint`, `@ljharb/eslint-config` [`9d94ccb`](https://github.com/inspect-js/is-date-object/commit/9d94ccbab4160d2fa649123e37951d86b69a8b15) 111 | - [Dev Deps] update `is`, `eslint`, `@ljharb/eslint-config`, `semver` [`35cbff7`](https://github.com/inspect-js/is-date-object/commit/35cbff7f7c8216fbb79c799f74b2336eaf0d726a) 112 | - Test up to `io.js` `v2.3` [`be5d11e`](https://github.com/inspect-js/is-date-object/commit/be5d11e7ebd9473d7ae554179b3769082485f6f4) 113 | - [Tests] on `io.js` `v3.3`, up to `node` `v4.1` [`20221a3`](https://github.com/inspect-js/is-date-object/commit/20221a34858d2b21e23bdc2c08df23f0bc08d11e) 114 | - [Tests] up to `io.js` `v3.2 ` [`7009b4a`](https://github.com/inspect-js/is-date-object/commit/7009b4a9999e14eacbdf6068afd82f478473f007) 115 | - Test on `io.js` `v2.1` [`68b29b1`](https://github.com/inspect-js/is-date-object/commit/68b29b19a07e6589a7ca37ab764be28f144ac88e) 116 | - Remove `editorconfig-tools` [`8d3972c`](https://github.com/inspect-js/is-date-object/commit/8d3972c1795fdcfd337680e11ab610e4885fb079) 117 | - [Dev Deps] update `tape` [`204945d`](https://github.com/inspect-js/is-date-object/commit/204945d8658a3513ca6315ddf795e4034adb4545) 118 | - Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. [`7bff214`](https://github.com/inspect-js/is-date-object/commit/7bff214dcb2317b96219921476f990814afbb401) 119 | - Test on `io.js` `v2.5` [`92f7bd6`](https://github.com/inspect-js/is-date-object/commit/92f7bd6747e3259b0ddc9c287876f46a9cd4c270) 120 | - Test on `io.js` `v2.4` [`ebb34bf`](https://github.com/inspect-js/is-date-object/commit/ebb34bf1f58949768063f86ac012f1ca5d7cf6d9) 121 | - Fix tests for faked @@toStringTag [`3b9c26c`](https://github.com/inspect-js/is-date-object/commit/3b9c26c15040af6a87f8d77ce6c85a7bef7a4304) 122 | - Test on `io.js` `v3.0` [`5eedf4b`](https://github.com/inspect-js/is-date-object/commit/5eedf4bea76380a08813fd0977469c2480302a82) 123 | 124 | ## v1.0.0 - 2015-01-28 125 | 126 | ### Commits 127 | 128 | - Dotfiles. [`5b6a929`](https://github.com/inspect-js/is-date-object/commit/5b6a9298c6f70882e78e66d64c9c019f85790f52) 129 | - `make release` [`e8d40ce`](https://github.com/inspect-js/is-date-object/commit/e8d40ceca85acd0aa4b2753faa6e41c0c54cf6c3) 130 | - package.json [`a107259`](https://github.com/inspect-js/is-date-object/commit/a1072591ea510a2998298be6cef827b123f4643f) 131 | - Read me [`eb92695`](https://github.com/inspect-js/is-date-object/commit/eb92695664bdee8fc49891cd73aa2f41075f53cb) 132 | - Initial commit [`4fc7755`](https://github.com/inspect-js/is-date-object/commit/4fc7755ff12f1d7a55cf841d486bf6b2350fe5a0) 133 | - Tests. [`b6f432f`](https://github.com/inspect-js/is-date-object/commit/b6f432fb6801c5ff8d89cfec7601d59478e23dd1) 134 | - Implementation. [`dd0fd96`](https://github.com/inspect-js/is-date-object/commit/dd0fd96c4016a66cec7cd59db0fde37c2ef3cdb5) 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jordan Harband 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # is-date-object [![Version Badge][2]][1] 2 | 3 | [![github actions][actions-image]][actions-url] 4 | [![coverage][codecov-image]][codecov-url] 5 | [![dependency status][5]][6] 6 | [![dev dependency status][7]][8] 7 | [![License][license-image]][license-url] 8 | [![Downloads][downloads-image]][downloads-url] 9 | 10 | [![npm badge][11]][1] 11 | 12 | Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag. 13 | 14 | ## Example 15 | 16 | ```js 17 | var isDate = require('is-date-object'); 18 | var assert = require('assert'); 19 | 20 | assert.notOk(isDate(undefined)); 21 | assert.notOk(isDate(null)); 22 | assert.notOk(isDate(false)); 23 | assert.notOk(isDate(true)); 24 | assert.notOk(isDate(42)); 25 | assert.notOk(isDate('foo')); 26 | assert.notOk(isDate(function () {})); 27 | assert.notOk(isDate([])); 28 | assert.notOk(isDate({})); 29 | assert.notOk(isDate(/a/g)); 30 | assert.notOk(isDate(new RegExp('a', 'g'))); 31 | 32 | assert.ok(isDate(new Date())); 33 | ``` 34 | 35 | ## Tests 36 | Simply clone the repo, `npm install`, and run `npm test` 37 | 38 | [1]: https://npmjs.org/package/is-date-object 39 | [2]: https://versionbadg.es/inspect-js/is-date-object.svg 40 | [5]: https://david-dm.org/inspect-js/is-date-object.svg 41 | [6]: https://david-dm.org/inspect-js/is-date-object 42 | [7]: https://david-dm.org/inspect-js/is-date-object/dev-status.svg 43 | [8]: https://david-dm.org/inspect-js/is-date-object#info=devDependencies 44 | [11]: https://nodei.co/npm/is-date-object.png?downloads=true&stars=true 45 | [license-image]: https://img.shields.io/npm/l/is-date-object.svg 46 | [license-url]: LICENSE 47 | [downloads-image]: https://img.shields.io/npm/dm/is-date-object.svg 48 | [downloads-url]: https://npm-stat.com/charts.html?package=is-date-object 49 | [codecov-image]: https://codecov.io/gh/inspect-js/is-date-object/branch/main/graphs/badge.svg 50 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-date-object/ 51 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-date-object 52 | [actions-url]: https://github.com/inspect-js/is-date-object/actions 53 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | declare function isDateObject(value: unknown): value is Date; 2 | 3 | export = isDateObject; 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 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 | }; 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "is-date-object", 3 | "version": "1.1.0", 4 | "author": "Jordan Harband", 5 | "funding": { 6 | "url": "https://github.com/sponsors/ljharb" 7 | }, 8 | "description": "Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", 9 | "license": "MIT", 10 | "main": "index.js", 11 | "exports": { 12 | ".": "./index.js", 13 | "./package.json": "./package.json" 14 | }, 15 | "sideEffects": false, 16 | "scripts": { 17 | "prepack": "npmignore --auto --commentLines=autogenerated", 18 | "prepublishOnly": "safe-publish-latest", 19 | "prepublish": "not-in-publish || npm run prepublishOnly", 20 | "pretest": "npm run lint", 21 | "test": "npm run tests-only && npm run test:corejs", 22 | "tests-only": "nyc tape 'test/**/*.js'", 23 | "test:corejs": "nyc tape test-corejs.js", 24 | "posttest": "npx npm@'>= 10.2' audit --production", 25 | "lint": "eslint --ext=js,mjs .", 26 | "postlint": "tsc && attw -P", 27 | "version": "auto-changelog && git add CHANGELOG.md", 28 | "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" 29 | }, 30 | "repository": { 31 | "type": "git", 32 | "url": "git://github.com/inspect-js/is-date-object.git" 33 | }, 34 | "keywords": [ 35 | "Date", 36 | "ES6", 37 | "toStringTag", 38 | "@@toStringTag", 39 | "Date object" 40 | ], 41 | "dependencies": { 42 | "call-bound": "^1.0.2", 43 | "has-tostringtag": "^1.0.2" 44 | }, 45 | "devDependencies": { 46 | "@arethetypeswrong/cli": "^0.17.1", 47 | "@ljharb/eslint-config": "^21.1.1", 48 | "@ljharb/tsconfig": "^0.2.2", 49 | "@types/core-js": "^2.5.8", 50 | "@types/tape": "^5.6.5", 51 | "auto-changelog": "^2.5.0", 52 | "core-js": "^3.39.0", 53 | "encoding": "^0.1.13", 54 | "eslint": "=8.8.0", 55 | "in-publish": "^2.0.1", 56 | "indexof": "^0.0.1", 57 | "is": "^3.3.0", 58 | "npmignore": "^0.3.1", 59 | "nyc": "^10.3.2", 60 | "safe-publish-latest": "^2.0.0", 61 | "tape": "^5.9.0", 62 | "typescript": "^5.8.0-dev.20241212" 63 | }, 64 | "testling": { 65 | "files": "test/index.js", 66 | "browsers": [ 67 | "iexplore/6.0..latest", 68 | "firefox/3.0..6.0", 69 | "firefox/15.0..latest", 70 | "firefox/nightly", 71 | "chrome/4.0..10.0", 72 | "chrome/20.0..latest", 73 | "chrome/canary", 74 | "opera/10.0..latest", 75 | "opera/next", 76 | "safari/4.0..latest", 77 | "ipad/6.0..latest", 78 | "iphone/6.0..latest", 79 | "android-browser/4.2" 80 | ] 81 | }, 82 | "engines": { 83 | "node": ">= 0.4" 84 | }, 85 | "auto-changelog": { 86 | "output": "CHANGELOG.md", 87 | "template": "keepachangelog", 88 | "unreleased": false, 89 | "commitLimit": false, 90 | "backfillLimit": false, 91 | "hideCredit": true 92 | }, 93 | "publishConfig": { 94 | "ignore": [ 95 | ".github/workflows", 96 | "test-corejs.js" 97 | ] 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /test-corejs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('core-js'); 4 | 5 | require('./test'); 6 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var test = require('tape'); 4 | var isDate = require('../'); 5 | var hasToStringTag = require('has-tostringtag/shams')(); 6 | 7 | test('not Dates', function (t) { 8 | // @ts-expect-error 9 | t.notOk(isDate(), 'undefined is not Date'); 10 | t.notOk(isDate(null), 'null is not Date'); 11 | t.notOk(isDate(false), 'false is not Date'); 12 | t.notOk(isDate(true), 'true is not Date'); 13 | t.notOk(isDate(42), 'number is not Date'); 14 | t.notOk(isDate('foo'), 'string is not Date'); 15 | t.notOk(isDate([]), 'array is not Date'); 16 | t.notOk(isDate({}), 'object is not Date'); 17 | t.notOk(isDate(function () {}), 'function is not Date'); 18 | t.notOk(isDate(/a/g), 'regex literal is not Date'); 19 | t.notOk(isDate(new RegExp('a', 'g')), 'regex object is not Date'); 20 | t.end(); 21 | }); 22 | 23 | test('@@toStringTag', { skip: !hasToStringTag }, function (t) { 24 | var realDate = new Date(); 25 | /** @type {{ toString(): unknown; valueOf(): unknown; [Symbol.toStringTag]?: string; }} */ 26 | var fakeDate = { 27 | toString: function () { return String(realDate); }, 28 | valueOf: function () { return realDate.getTime(); } 29 | }; 30 | fakeDate[Symbol.toStringTag] = 'Date'; 31 | t.notOk(isDate(fakeDate), 'fake Date with @@toStringTag "Date" is not Date'); 32 | t.end(); 33 | }); 34 | 35 | test('Dates', function (t) { 36 | t.ok(isDate(new Date()), 'new Date() is Date'); 37 | t.end(); 38 | }); 39 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@ljharb/tsconfig", 3 | "exclude": [ 4 | "coverage" 5 | ], 6 | } 7 | --------------------------------------------------------------------------------