pax_global_header00006660000000000000000000000064123461622410014513gustar00rootroot0000000000000052 comment=40056e932b53c767d42a1d06eefd1fa318360609 date-now-1.0.1/000077500000000000000000000000001234616224100132305ustar00rootroot00000000000000date-now-1.0.1/.gitignore000066400000000000000000000002241234616224100152160ustar00rootroot00000000000000.DS_Store .monitor .*.swp .nodemonignore releases *.log *.err fleet.json public/browserify bin/*.json .bin build compile .lock-wscript node_modules date-now-1.0.1/.npmignore000066400000000000000000000002071234616224100152260ustar00rootroot00000000000000.DS_Store .monitor .*.swp .nodemonignore releases *.log *.err fleet.json public/browserify bin/*.json .bin build compile .lock-wscript date-now-1.0.1/.testem.json000066400000000000000000000004601234616224100155020ustar00rootroot00000000000000{ "launchers": { "node": { "command": "npm test" } }, "src_files": [ "./**/*.js" ], "before_tests": "npm run build", "on_exit": "rm test/static/bundle.js", "test_page": "test/static/index.html", "launch_in_dev": ["node", "phantomjs"] } date-now-1.0.1/.travis.yml000066400000000000000000000000531234616224100153370ustar00rootroot00000000000000language: node_js node_js: - 0.8 - 0.9 date-now-1.0.1/LICENCE000066400000000000000000000020341234616224100142140ustar00rootroot00000000000000Copyright (c) 2012 Colingo. 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. date-now-1.0.1/README.md000066400000000000000000000014651234616224100145150ustar00rootroot00000000000000# date-now [![build status][1]][2] [![browser support][3]][4] A requirable version of Date.now() Use-case is to be able to mock out Date.now() using require interception. ## Example ```js var now = require("date-now") var ts = now() var ts2 = Date.now() assert.equal(ts, ts2) ``` ## example of seed ``` var now = require("date-now/seed")(timeStampFromServer) // ts is in "sync" with the seed value from the server // useful if your users have their local time being a few minutes // out of your server time. var ts = now() ``` ## Installation `npm install date-now` ## Contributors - Raynos ## MIT Licenced [1]: https://secure.travis-ci.org/Raynos/date-now.png [2]: http://travis-ci.org/Raynos/date-now [3]: http://ci.testling.com/Raynos/date-now.png [4]: http://ci.testling.com/Raynos/date-now date-now-1.0.1/component.json000066400000000000000000000004151234616224100161250ustar00rootroot00000000000000{ "name": "date-now", "version": "1.0.0", "repo": "Raynos/date-now", "description": "A requirable version of Date.now()", "keywords": [], "dependencies": {}, "development": {}, "license": "MIT", "main": "index.js", "scripts": [ "index.js" ] } date-now-1.0.1/index.js000066400000000000000000000001251234616224100146730ustar00rootroot00000000000000module.exports = Date.now || now function now() { return new Date().getTime() } date-now-1.0.1/package.json000066400000000000000000000025121234616224100155160ustar00rootroot00000000000000{ "name": "date-now", "version": "1.0.1", "description": "A requirable version of Date.now()", "keywords": [], "author": "Raynos ", "repository": "git://github.com/Raynos/date-now.git", "main": "index", "homepage": "https://github.com/Raynos/date-now", "contributors": [ { "name": "Artem Shoobovych" } ], "bugs": { "url": "https://github.com/Raynos/date-now/issues", "email": "raynos2@gmail.com" }, "dependencies": {}, "devDependencies": { "tape": "~0.2.2", "browserify": "https://github.com/raynos/node-browserify/tarball/master", "testem": "~0.2.52" }, "licenses": [ { "type": "MIT", "url": "http://github.com/Raynos/date-now/raw/master/LICENSE" } ], "scripts": { "test": "node ./test", "build": "browserify test/index.js -o test/static/bundle.js", "testem": "testem" }, "component": { "scripts": { "date-now/index.js": "index.js" } }, "testling": { "files": "test/*.js", "browsers": { "ie": [ "8", "9", "10" ], "firefox": [ "16", "17", "nightly" ], "chrome": [ "22", "23", "canary" ], "opera": [ "12", "next" ], "safari": [ "5.1" ] } } } date-now-1.0.1/seed.js000066400000000000000000000004171234616224100145100ustar00rootroot00000000000000var now = require("./index") module.exports = seeded /* Returns a Date.now() like function that's in sync with the seed value */ function seeded(seed) { var current = now() return time function time() { return seed + (now() - current) } } date-now-1.0.1/test/000077500000000000000000000000001234616224100142075ustar00rootroot00000000000000date-now-1.0.1/test/index.js000066400000000000000000000014511234616224100156550ustar00rootroot00000000000000var test = require("tape") var setTimeout = require("timers").setTimeout var now = require("../index") var seeded = require("../seed") test("date", function (assert) { var before = new Date().getTime() var ts = now() var after = new Date().getTime() assert.ok(before <= ts) assert.ok(after >= ts) assert.end() }) test("seeded", function (assert) { var before = now() var time = seeded(40) var after = now() var bts = now() var ts = time() var ats = now() assert.ok(ts >= bts - before + 40) assert.ok(ts <= ats - after + 40) setTimeout(function () { var bts = now() var ts = time() var ats = now() assert.ok(ts >= bts - before + 40) assert.ok(ts <= ats - after + 40) assert.end() }, 50) }) date-now-1.0.1/test/static/000077500000000000000000000000001234616224100154765ustar00rootroot00000000000000date-now-1.0.1/test/static/index.html000066400000000000000000000002521234616224100174720ustar00rootroot00000000000000 TAPE Example