| !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.clocktick=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
| 'use strict' | ||
| var dateNow = require('date-now') | ||
| module.exports = clocktick | ||
| function clocktick (callback) { | ||
| var self, args, now, nowRounded, nextTick | ||
| self = this | ||
| args = Array.prototype.slice.call(arguments, 1) | ||
| now = dateNow() | ||
| nowRounded = (now / 1000 | 0) * 1000 | ||
| nextTick = 1000 - (now - nowRounded) | ||
| return setTimeout(function () { | ||
| callback && callback.apply(self, args) | ||
| }, nextTick) | ||
| } | ||
| },{"date-now":2}],2:[function(require,module,exports){ | ||
| module.exports = Date.now || now | ||
| function now() { | ||
| return new Date().getTime() | ||
| } | ||
| },{}]},{},[1])(1) | ||
| }); |
+3
-1
| { | ||
| "name": "clocktick", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "Clock-accurate timeout for Node.js and browser", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "build": "mkdir -p dist/ && browserify index.js --standalone clocktick -o dist/clocktick.js", | ||
| "test": "node test | tap-spec" | ||
@@ -23,2 +24,3 @@ }, | ||
| "devDependencies": { | ||
| "browserify": "^5.10.1", | ||
| "tap-spec": "^0.2.1", | ||
@@ -25,0 +27,0 @@ "tape": "^2.14.0" |
+15
-6
| # clocktick | ||
| Clock-accurate timeout for Node.js and browser. | ||
| Basically it is identical to setTimeout, but it triggers callback function precisely on every second. | ||
| Basically it is identical to setTimeout, but it triggers callback function precisely on the next second. | ||
| ## example | ||
| See an example [here](http://pakastin.github.io/clocktick) | ||
| ## accuracy | ||
@@ -12,7 +15,2 @@ Accuracy should be around 1–2ms. | ||
| ## testing | ||
| npm install clocktick --dev | ||
| npm test clocktick | ||
| ## usage | ||
@@ -42,1 +40,12 @@ Usage is similar to setTimeout, but without delay parameter: | ||
| clearTimeout(timeout) | ||
| ## testing | ||
| Clone to desktop and then run following commands at clocktick folder: | ||
| npm install | ||
| npm test | ||
| ## building | ||
| npm install | ||
| npm run build |
4714
55.07%6
20%83
40.68%50
21.95%3
50%