🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@colyseus/clock

Package Overview
Dependencies
Maintainers
1
Versions
2
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.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
2.1K
-43.5%
Maintainers
1
Weekly downloads
 
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

clock

FAQs

Package last updated on 17 Oct 2025

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