Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

internet-time

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

internet-time - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

2

dist/client.js

@@ -1,1 +0,1 @@

const{CircularQueue}=require("@ganorberg/data-structures-javascript");function avg(b){return b.reduce((a,b)=>a+b)/b.length}module.exports=class{constructor({sendRequest:a,createRequest:b}={}){this.tDelta=null,this.rtt=null,this.timer=null,this.alpha=.01,this.updatePeriod=50,this.sendRequest=a,this.createRequest=b,this.deltaBuf=new CircularQueue(512),this.fHiddenTab=!1;try{this.fHiddenTab=document.hidden,document.addEventListener("visibilitychange",()=>{this.fHiddenTab=document.hidden})}catch(a){}}processResponse(a){const b=this.createRequest(),{tTx:c,tServer:d}=a,e=b-c;return this.tDelta=this.calcNewDelta(d-e/2-c),this.rtt=e,this.tDelta}calcNewDelta(a){return this.deltaBuf.enqueue(a),avg(this.deltaBuf.ring.filter(Boolean))}getDelta(){return this.tDelta}getRtt(){return this.rtt}start(){null!=this.timer&&this.stop(),this.sendAutoRequest(!0),this.timer=setInterval(this.sendAutoRequest.bind(this),this.updatePeriod)}stop(){null==this.timer||(clearInterval(this.timer),this.timer=null)}sendAutoRequest(a){if(!this.fHiddenTab||a){const a=this.createRequest();this.sendRequest(a)}}};
const{CircularQueue}=require("@ganorberg/data-structures-javascript");function avg(b){return b.reduce((a,b)=>a+b)/b.length}module.exports=class{constructor({sendRequest:a,createRequest:b}={}){this.tDelta=null,this.rtt=null,this.timer=null,this.alpha=.01,this.updatePeriod=125,this.sendRequest=a,this.createRequest=b,this.deltaBuf=new CircularQueue(512),this.fHiddenTab=!1;try{this.fHiddenTab=document.hidden,document.addEventListener("visibilitychange",()=>{this.fHiddenTab=document.hidden})}catch(a){}}processResponse(a){const b=this.createRequest(),{tTx:c,tServer:d}=a,e=b-c;return this.tDelta=this.calcNewDelta(d-e/2-c),this.rtt=e,this.tDelta}calcNewDelta(a){return this.deltaBuf.enqueue(a),avg(this.deltaBuf.ring.filter(Boolean))}getDelta(){return this.tDelta}getRtt(){return this.rtt}start(){null!=this.timer&&this.stop(),this.sendAutoRequest(!0),this.timer=setInterval(this.sendAutoRequest.bind(this),this.updatePeriod)}stop(){null==this.timer||(clearInterval(this.timer),this.timer=null)}sendAutoRequest(a){if(!this.fHiddenTab||a){const a=this.createRequest();this.sendRequest(a)}}};
{
"name": "internet-time",
"version": "0.0.12",
"version": "0.0.13",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc