package/package.json000644 000765 000024 0000002614 12601765742013032 0ustar00000000 000000 { "name": "is-date-object", "version": "1.0.1", "author": "Jordan Harband", "description": "Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", "license": "MIT", "main": "index.js", "scripts": { "test": "npm run lint && node --harmony --es-staging test.js && npm run security", "coverage": "covert test.js", "coverage-quiet": "covert test.js --quiet", "lint": "npm run jscs && npm run eslint", "jscs": "jscs test.js *.js", "eslint": "eslint test.js *.js", "security": "nsp package" }, "repository": { "type": "git", "url": "git://github.com/ljharb/is-date-object.git" }, "keywords": [ "Date", "ES6", "toStringTag", "@@toStringTag", "Date object" ], "dependencies": {}, "devDependencies": { "foreach": "^2.0.5", "is": "^3.1.0", "tape": "^4.2.0", "indexof": "^0.0.1", "covert": "^1.1.0", "jscs": "^2.1.1", "nsp": "^1.1.0", "eslint": "^1.5.1", "@ljharb/eslint-config": "^1.2.0", "semver": "^5.0.3" }, "testling": { "files": "test.js", "browsers": [ "iexplore/6.0..latest", "firefox/3.0..6.0", "firefox/15.0..latest", "firefox/nightly", "chrome/4.0..10.0", "chrome/20.0..latest", "chrome/canary", "opera/10.0..latest", "opera/next", "safari/4.0..latest", "ipad/6.0..latest", "iphone/6.0..latest", "android-browser/4.2" ] }, "engines": { "node": ">= 0.4" } } package/.npmignore000644 000765 000024 0000001113 12500657612012526 0ustar00000000 000000 # Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules # Users Environment Variables .lock-wscript package/README.md000644 000765 000024 0000003327 12562560142012016 0ustar00000000 000000 # is-date-object [![Version Badge][2]][1] [![Build Status][3]][4] [![dependency status][5]][6] [![dev dependency status][7]][8] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][11]][1] [![browser support][9]][10] Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag. ## Example ```js var isDate = require('is-date-object'); var assert = require('assert'); assert.notOk(isDate(undefined)); assert.notOk(isDate(null)); assert.notOk(isDate(false)); assert.notOk(isDate(true)); assert.notOk(isDate(42)); assert.notOk(isDate('foo')); assert.notOk(isDate(function () {})); assert.notOk(isDate([])); assert.notOk(isDate({})); assert.notOk(isDate(/a/g)); assert.notOk(isDate(new RegExp('a', 'g'))); assert.ok(isDate(new Date())); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [1]: https://npmjs.org/package/is-date-object [2]: http://versionbadg.es/ljharb/is-date-object.svg [3]: https://travis-ci.org/ljharb/is-date-object.svg [4]: https://travis-ci.org/ljharb/is-date-object [5]: https://david-dm.org/ljharb/is-date-object.svg [6]: https://david-dm.org/ljharb/is-date-object [7]: https://david-dm.org/ljharb/is-date-object/dev-status.svg [8]: https://david-dm.org/ljharb/is-date-object#info=devDependencies [9]: https://ci.testling.com/ljharb/is-date-object.png [10]: https://ci.testling.com/ljharb/is-date-object [11]: https://nodei.co/npm/is-date-object.png?downloads=true&stars=true [license-image]: http://img.shields.io/npm/l/is-date-object.svg [license-url]: LICENSE [downloads-image]: http://img.shields.io/npm/dm/is-date-object.svg [downloads-url]: http://npm-stat.com/charts.html?package=is-date-object package/LICENSE000644 000765 000024 0000002072 12500657612011541 0ustar00000000 000000 The MIT License (MIT) Copyright (c) 2015 Jordan Harband Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/index.js000644 000765 000024 0000001047 12601765441012204 0ustar00000000 000000 'use strict'; var getDay = Date.prototype.getDay; var tryDateObject = function tryDateObject(value) { 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) { if (typeof value !== 'object' || value === null) { return false; } return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass; }; package/test.js000644 000765 000024 0000002255 12562560236012057 0ustar00000000 000000 'use strict'; var test = require('tape'); var isDate = require('./'); var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; test('not Dates', function (t) { t.notOk(isDate(), 'undefined is not Date'); t.notOk(isDate(null), 'null is not Date'); t.notOk(isDate(false), 'false is not Date'); t.notOk(isDate(true), 'true is not Date'); t.notOk(isDate(42), 'number is not Date'); t.notOk(isDate('foo'), 'string is not Date'); t.notOk(isDate([]), 'array is not Date'); t.notOk(isDate({}), 'object is not Date'); t.notOk(isDate(function () {}), 'function is not Date'); t.notOk(isDate(/a/g), 'regex literal is not Date'); t.notOk(isDate(new RegExp('a', 'g')), 'regex object is not Date'); t.end(); }); test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) { var realDate = new Date(); var fakeDate = { toString: function () { return String(realDate); }, valueOf: function () { return realDate.getTime(); } }; fakeDate[Symbol.toStringTag] = 'Date'; t.notOk(isDate(fakeDate), 'fake Date with @@toStringTag "Date" is not Date'); t.end(); }); test('Dates', function (t) { t.ok(isDate(new Date()), 'new Date() is Date'); t.end(); }); package/Makefile000644 000765 000024 0000007372 12500657612012204 0ustar00000000 000000 # Since we rely on paths relative to the makefile location, abort if make isn't being run from there. $(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) # The files that need updating when incrementing the version number. VERSIONED_FILES := *.js *.json README* # Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. # Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment # where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") UTILS := semver # Make sure that all required utilities can be located. UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) # Default target (by virtue of being the first non '.'-prefixed in the file). .PHONY: _no-target-specified _no-target-specified: $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) # Lists all targets defined in this makefile. .PHONY: list list: @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort # All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). .PHONY: test test: @npm test .PHONY: _ensure-tag _ensure-tag: ifndef TAG $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) endif CHANGELOG_ERROR = $(error No CHANGELOG specified) .PHONY: _ensure-changelog _ensure-changelog: @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) # Ensures that the git workspace is clean. .PHONY: _ensure-clean _ensure-clean: @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } # Makes a release; invoke with `make TAG= release`. .PHONY: release release: _ensure-tag _ensure-changelog _ensure-clean @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ if printf "$$new_ver" | command grep -q '^[0-9]'; then \ semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ else \ new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ fi; \ printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ git tag -a -m "v$$new_ver" "v$$new_ver" package/CHANGELOG.md000644 000765 000024 0000000645 12601765704012355 0ustar00000000 000000 1.0.1 / 2015-09-27 ================= * [Fix] If `@@toStringTag` is not present, use the old-school `Object#toString` test * [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG * [Dev Deps] update `is`, `eslint`, `@ljharb/eslint-config`, `semver`, `tape`, `jscs`, `nsp`, `covert` * [Tests] up to `io.js` `v3.3`, `node` `v4.1` 1.0.0 / 2015-01-28 ================= * Initial release. package/.travis.yml000644 000765 000024 0000002177 12601764351012654 0ustar00000000 000000 language: node_js node_js: - "4.1" - "4.0" - "iojs-v3.3" - "iojs-v3.2" - "iojs-v3.1" - "iojs-v3.0" - "iojs-v2.5" - "iojs-v2.4" - "iojs-v2.3" - "iojs-v2.2" - "iojs-v2.1" - "iojs-v2.0" - "iojs-v1.8" - "iojs-v1.7" - "iojs-v1.6" - "iojs-v1.5" - "iojs-v1.4" - "iojs-v1.3" - "iojs-v1.2" - "iojs-v1.1" - "iojs-v1.0" - "0.12" - "0.11" - "0.10" - "0.9" - "0.8" - "0.6" - "0.4" before_install: - '[ "${TRAVIS_NODE_VERSION}" = "0.6" ] || npm install -g npm@1.4.28 && npm install -g npm' sudo: false matrix: fast_finish: true allow_failures: - node_js: "4.0" - node_js: "iojs-v3.2" - node_js: "iojs-v3.1" - node_js: "iojs-v3.0" - node_js: "iojs-v2.4" - node_js: "iojs-v2.3" - node_js: "iojs-v2.2" - node_js: "iojs-v2.1" - node_js: "iojs-v2.0" - node_js: "iojs-v1.7" - node_js: "iojs-v1.6" - node_js: "iojs-v1.5" - node_js: "iojs-v1.4" - node_js: "iojs-v1.3" - node_js: "iojs-v1.2" - node_js: "iojs-v1.1" - node_js: "iojs-v1.0" - node_js: "0.11" - node_js: "0.9" - node_js: "0.8" - node_js: "0.6" - node_js: "0.4" package/.jscs.json000644 000765 000024 0000005476 12601764364012467 0ustar00000000 000000 { "es3": true, "additionalRules": [], "requireSemicolons": true, "disallowMultipleSpaces": true, "disallowIdentifierNames": [], "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], "disallowSpaceAfterKeywords": [], "disallowSpaceBeforeComma": true, "disallowSpaceBeforeSemicolon": true, "disallowNodeTypes": [ "DebuggerStatement", "ForInStatement", "LabeledStatement", "SwitchCase", "SwitchStatement", "WithStatement" ], "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, "requireSpaceBetweenArguments": true, "disallowSpacesInsideParentheses": true, "disallowSpacesInsideArrayBrackets": true, "disallowQuotedKeysInObjects": "allButReserved", "disallowSpaceAfterObjectKeys": true, "requireCommaBeforeLineBreak": true, "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], "requireSpaceAfterPrefixUnaryOperators": [], "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], "requireSpaceBeforePostfixUnaryOperators": [], "disallowSpaceBeforeBinaryOperators": [], "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "disallowSpaceAfterBinaryOperators": [], "disallowImplicitTypeConversion": ["binary", "string"], "disallowKeywords": ["with", "eval"], "requireKeywordsOnNewLine": [], "disallowKeywordsOnNewLine": ["else"], "requireLineFeedAtFileEnd": true, "disallowTrailingWhitespace": true, "disallowTrailingComma": true, "excludeFiles": ["node_modules/**", "vendor/**"], "disallowMultipleLineStrings": true, "requireDotNotation": true, "requireParenthesesAroundIIFE": true, "validateLineBreaks": "LF", "validateQuoteMarks": { "escape": true, "mark": "'" }, "disallowOperatorBeforeLineBreak": [], "requireSpaceBeforeKeywords": [ "do", "for", "if", "else", "switch", "case", "try", "catch", "finally", "while", "with", "return" ], "validateAlignedFunctionParameters": { "lineBreakAfterOpeningBraces": true, "lineBreakBeforeClosingBraces": true }, "requirePaddingNewLinesBeforeExport": true, "validateNewlineAfterArrayElements": { "maximum": 1 }, "requirePaddingNewLinesAfterUseStrict": true, "disallowArrowFunctions": true, "validateOrderInObjectKeys": "asc-insensitive" } package/.eslintrc000644 000765 000024 0000000127 12601764364012364 0ustar00000000 000000 { "root": true, "extends": "@ljharb", "rules": { "max-statements": [2, 12] } }