New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@colyseus/clock

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@colyseus/clock

A simple clock/ticker implementation to track elapsed/delta time.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@colyseus/clock

A simple clock/ticker implementation to track delta/elapsed time.

API

  • new Clock([useInterval=false])
  • clock.start([useInterval=false])
  • clock.stop()
  • clock.tick()
  • clock.elapsedTime
  • clock.deltaTime
  • clock.currentTime

Usage example

There's two ways you can use clock.js: manual or automatic.

Automatic

By initializing Clock with true as the first argument, a interval will be created, in which tick() is called 60 times per second.

import Clock from '@colyseus/clock';
let clock = new Clock(true);

You can also call start(true) to create the interval.

import Clock from '@colyseus/clock';
let clock = new Clock();
clock.start(true);

Manual usage

You call tick() manually in your existing loop.

import Clock from '@colyseus/clock';
var clock = new Clock();

setInterval(function() {
  clock.tick();
  console.log("Delta time: ", clock.deltaTime);
  console.log("Elapsed time: ", clock.elapsedTime);
  console.log("Current time: ", clock.currentTime);
}, 1000 / 60);

License

MIT

Keywords

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

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.

Install

Related posts

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