diff options
Diffstat (limited to 'node_modules/date-now')
-rw-r--r-- | node_modules/date-now/.npmignore | 14 | ||||
-rw-r--r-- | node_modules/date-now/.testem.json | 14 | ||||
-rw-r--r-- | node_modules/date-now/.travis.yml | 4 | ||||
-rw-r--r-- | node_modules/date-now/LICENCE | 19 | ||||
-rw-r--r-- | node_modules/date-now/README.md | 45 | ||||
-rw-r--r-- | node_modules/date-now/index.js | 5 | ||||
-rw-r--r-- | node_modules/date-now/package.json | 63 | ||||
-rw-r--r-- | node_modules/date-now/seed.js | 16 | ||||
-rw-r--r-- | node_modules/date-now/test/index.js | 28 | ||||
-rw-r--r-- | node_modules/date-now/test/static/index.html | 10 |
10 files changed, 218 insertions, 0 deletions
diff --git a/node_modules/date-now/.npmignore b/node_modules/date-now/.npmignore new file mode 100644 index 000000000..aa3fd4b85 --- /dev/null +++ b/node_modules/date-now/.npmignore @@ -0,0 +1,14 @@ +.DS_Store +.monitor +.*.swp +.nodemonignore +releases +*.log +*.err +fleet.json +public/browserify +bin/*.json +.bin +build +compile +.lock-wscript diff --git a/node_modules/date-now/.testem.json b/node_modules/date-now/.testem.json new file mode 100644 index 000000000..633c2ba84 --- /dev/null +++ b/node_modules/date-now/.testem.json @@ -0,0 +1,14 @@ +{ + "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"] +} diff --git a/node_modules/date-now/.travis.yml b/node_modules/date-now/.travis.yml new file mode 100644 index 000000000..ed178f635 --- /dev/null +++ b/node_modules/date-now/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.8 + - 0.9 diff --git a/node_modules/date-now/LICENCE b/node_modules/date-now/LICENCE new file mode 100644 index 000000000..822d880b9 --- /dev/null +++ b/node_modules/date-now/LICENCE @@ -0,0 +1,19 @@ +Copyright (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. diff --git a/node_modules/date-now/README.md b/node_modules/date-now/README.md new file mode 100644 index 000000000..22d267536 --- /dev/null +++ b/node_modules/date-now/README.md @@ -0,0 +1,45 @@ +# 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/Colingo/date-now.png + [2]: http://travis-ci.org/Colingo/date-now + [3]: http://ci.testling.com/Colingo/date-now.png + [4]: http://ci.testling.com/Colingo/date-now diff --git a/node_modules/date-now/index.js b/node_modules/date-now/index.js new file mode 100644 index 000000000..d5f143a84 --- /dev/null +++ b/node_modules/date-now/index.js @@ -0,0 +1,5 @@ +module.exports = now + +function now() { + return new Date().getTime() +} diff --git a/node_modules/date-now/package.json b/node_modules/date-now/package.json new file mode 100644 index 000000000..832f0eedc --- /dev/null +++ b/node_modules/date-now/package.json @@ -0,0 +1,63 @@ +{ + "name": "date-now", + "version": "0.1.4", + "description": "A requirable version of Date.now()", + "keywords": [], + "author": "Raynos <raynos2@gmail.com>", + "repository": "git://github.com/Colingo/date-now.git", + "main": "index", + "homepage": "https://github.com/Colingo/date-now", + "contributors": [ + { + "name": "Artem Shoobovych" + } + ], + "bugs": { + "url": "https://github.com/Colingo/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/Colingo/date-now/raw/master/LICENSE" + } + ], + "scripts": { + "test": "node ./test", + "build": "browserify test/index.js -o test/static/bundle.js", + "testem": "testem" + }, + "testling": { + "files": "test/*.js", + "browsers": { + "ie": [ + "8", + "9", + "10" + ], + "firefox": [ + "16", + "17", + "nightly" + ], + "chrome": [ + "22", + "23", + "canary" + ], + "opera": [ + "12", + "next" + ], + "safari": [ + "5.1" + ] + } + } +} diff --git a/node_modules/date-now/seed.js b/node_modules/date-now/seed.js new file mode 100644 index 000000000..b9727c5a3 --- /dev/null +++ b/node_modules/date-now/seed.js @@ -0,0 +1,16 @@ +var 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) + } +} diff --git a/node_modules/date-now/test/index.js b/node_modules/date-now/test/index.js new file mode 100644 index 000000000..270584cab --- /dev/null +++ b/node_modules/date-now/test/index.js @@ -0,0 +1,28 @@ +var test = require("tape") +var setTimeout = require("timers").setTimeout + +var now = require("../index") +var seeded = require("../seed") + +test("date", function (assert) { + var ts = now() + var ts2 = Date.now() + assert.equal(ts, ts2) + assert.end() +}) + +test("seeded", function (assert) { + var time = seeded(40) + var ts = time() + + within(assert, time(), 40, 5) + setTimeout(function () { + within(assert, time(), 90, 10) + assert.end() + }, 50) +}) + +function within(assert, a, b, offset) { + assert.ok(a + offset > b) + assert.ok(a - offset < b) +} diff --git a/node_modules/date-now/test/static/index.html b/node_modules/date-now/test/static/index.html new file mode 100644 index 000000000..3d5384da8 --- /dev/null +++ b/node_modules/date-now/test/static/index.html @@ -0,0 +1,10 @@ +<!doctype html> +<html> +<head> + <title>TAPE Example</title> + <script src="/testem.js"></script> + <script src="bundle.js"></script> +</head> +<body> +</body> +</html> |