
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A smart algorithm to calculate clock skew from a timeserver.
Use it to synchronize your apps with millisecond accuracy.
See demo of synchronized note playing (open multiple tabs, modern browser required).
# Clone from GIT
git clone git@github.com:markmarijnissen/clockskew.git
node server
# or get from NPM
npm install clockskew
node node_modules/clockskew/server
# Deploy online (for example using modulus.io)
modulus deploy
npm install clockskew
var ClockSkew = require('clockskew/client');
// or just include the file
var clockSkew = new ClockSkew({
// REQUIRED :
getServerTime: ClockSkew.getSocketTime('ws://...'),
// or use HTTP protocol
getServerTime: ClockSkew.getHttpTime.bind(null,'http://'),
// or use Firebase
getServerTime: ClockSkew.getFirebaseTime.bind(null,'https://xxx.firebaseio.com/timestamp')
// OPTIONAL:
getTime: function(){...}, // get local time in ms.
timeout: 10000, // ping timeout
interval: 1000, // ping interval
history: 10,
tolerance: 2, // is standard deviation of last `history` average skew is less then tolerance, wait longer before pinging.
waitInteval: 30000, // wait interval
minSkewValues: 5, // minimum values before averaging
minRttValues: 5 // minimum Round-Trip-Time values before rejecting RTTs that are more than 1 standard deviation slower
setTimeout: ... // custom setTimeout Implementation
clearTimeout: ... // custom clearTimeout implementation
onSkew: function(skew) { // do stuff },
});
clockSkew.start();
clockSkew.stop();
clockSkew.skew;
0.2.1 - Removed accidental console.log on stable clockskew value
0.2.0 - Changed ClockSkew.js
into client.js
Feel free to contribute to this project in any way. The easiest way to support this project is by giving it a star.
© 2015 - Mark Marijnissen
FAQs
Websocket TimeServer and client library to calculate clock skew
The npm package clockskew receives a total of 1 weekly downloads. As such, clockskew popularity was classified as not popular.
We found that clockskew demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.