[Pkg-javascript-commits] [node-date-now] 01/04: Import Upstream version 1.0.1
Shirish Togarla
shirish12-guest at moszumanska.debian.org
Tue Feb 7 20:09:52 UTC 2017
This is an automated email from the git hooks/post-receive script.
shirish12-guest pushed a commit to branch master
in repository node-date-now.
commit a7b99881ebf9c49bf08fdade4e9bd5b17a79e428
Author: Shirish Togarla <shirishtogarla533 at gmail.com>
Date: Tue Feb 7 19:49:53 2017 +0000
Import Upstream version 1.0.1
---
.gitignore | 15 +++++++++++
.npmignore | 14 +++++++++++
.testem.json | 14 +++++++++++
.travis.yml | 4 +++
LICENCE | 19 ++++++++++++++
README.md | 46 ++++++++++++++++++++++++++++++++++
component.json | 14 +++++++++++
index.js | 5 ++++
package.json | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++
seed.js | 16 ++++++++++++
test/index.js | 38 ++++++++++++++++++++++++++++
test/static/index.html | 10 ++++++++
12 files changed, 263 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fd31f5e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+.DS_Store
+.monitor
+.*.swp
+.nodemonignore
+releases
+*.log
+*.err
+fleet.json
+public/browserify
+bin/*.json
+.bin
+build
+compile
+.lock-wscript
+node_modules
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..aa3fd4b
--- /dev/null
+++ b/.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/.testem.json b/.testem.json
new file mode 100644
index 0000000..633c2ba
--- /dev/null
+++ b/.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/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..ed178f6
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.8
+ - 0.9
diff --git a/LICENCE b/LICENCE
new file mode 100644
index 0000000..822d880
--- /dev/null
+++ b/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/README.md b/README.md
new file mode 100644
index 0000000..3155a33
--- /dev/null
+++ b/README.md
@@ -0,0 +1,46 @@
+# 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
diff --git a/component.json b/component.json
new file mode 100644
index 0000000..60e2cdf
--- /dev/null
+++ b/component.json
@@ -0,0 +1,14 @@
+{
+ "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"
+ ]
+}
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..4057004
--- /dev/null
+++ b/index.js
@@ -0,0 +1,5 @@
+module.exports = Date.now || now
+
+function now() {
+ return new Date().getTime()
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..20750ce
--- /dev/null
+++ b/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "date-now",
+ "version": "1.0.1",
+ "description": "A requirable version of Date.now()",
+ "keywords": [],
+ "author": "Raynos <raynos2 at gmail.com>",
+ "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 at 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"
+ ]
+ }
+ }
+}
diff --git a/seed.js b/seed.js
new file mode 100644
index 0000000..b9727c5
--- /dev/null
+++ b/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/test/index.js b/test/index.js
new file mode 100644
index 0000000..45a2bd9
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,38 @@
+var 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)
+})
diff --git a/test/static/index.html b/test/static/index.html
new file mode 100644
index 0000000..3d5384d
--- /dev/null
+++ b/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>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-date-now.git
More information about the Pkg-javascript-commits
mailing list