npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

minsky-ticker

v1.0.0

Published

Frame-based & native timer based timers managed by 1 class

Readme

Ticker

Frame-based & native timer based timers managed by 1 class

Helps us to normalize the api between requestAnimationFrame(), setTimeout() and setInterval by providing us with 1 api and many options. Start, stop, reset and reuse timers as you want in the simplest of ways. V3 is a ES6 rewrite of V2 keeping most of its api and structure.

Class type: Manager

Dependencies

  • EventDispatcher 1.0.0

Getting started

There are 2 ways to init a ticker and set up a timer. Classes may also extend from Ticker to add an extra layer of complexity.

// set up instance
let timer = new Ticker({
	timeout: 100
});

// start timer
timer.start();

// stop timer
timer.stop();

// reset
timer.reset();


// Quick timer => setTimeout-like, setInterval-like
Ticker.quick(100, (e) => {
	console.log('ticked');
})

Constructor Parameters

Args

Type: Object Default: {}

Settings to set parameters at construction time

objectName

Type: String Default: Ticker

Object name that will be used as recognisable identifier and as prefix in logs


Interface

Options

timeout

Type: Number Default: 0

Waiting time for the instance to trigger a timout/interval vent. 0 = next frame.

isInterval

Type: Boolean Default: false

Turns the ticker instance into an interval timer that will trigger ‘interval’ events every time the timeout is reached. Timeout events are replaced by Interval events.

autoDestroy

Type: Boolean Default: false

Auto-destructs the instance when the timeout callbacks have run.

autoStart

Type: Boolean Default: false

Auto-starts the instance once the constructor is done.

data

Type: Object Default: {}

Data to keep and add to the event.data object when events are dispatched.

useTimeout

Type: Boolean Default: false

Sets the instance to use setTimeout or setInterval instead of requestAnimationFrame.

autoReset

Type: Boolean Default: false

Auto-resets the time property when the timeout callbacks have run. Will be ignored if isInterval = true.

Properties

timeout

Type: Number Default: 0

Waiting time for the instance to trigger a timout/interval vent. 0 = next frame.

isInterval

Type: Boolean Default: false

Turns the ticker instance into an interval timer that will trigger ‘interval’ events every time the timeout is reached. Timeout events are replaced by Interval events.

autoDestroy

Type: Boolean Default: false

Auto-destructs the instance when the timeout callbacks have run.

autoStart

Type: Boolean Default: false

Auto-starts the instance once the constructor is done.

data

Type: Object Default: {}

Data to keep and add to the event.data object when events are dispatched.

useTimeout

Type: Boolean Default: false

Sets the instance to use setTimeout or setInterval instead of requestAnimationFrame.

autoReset

Type: Boolean Default: false

Auto-resets the time property when the timeout callbacks have run. Will be ignored if isInterval = true.

timerId

Type: Number Default: 0

Timer id returned by the native timer methods.

time

Type: Number Default: 0

Time passed since start of the timer. Resets when reset has run or at the end of ta timeout/interval.

lastTick

Type: Number Default: 0

Last time in ms a tick has taken place. Used together with time to know if a timeout limit is reached.

running (read only)

Type: Boolean Default: false

Flag determining if the instance is running a timer or not.

version (static read only)

Type: Boolean Default: ''

Version number of current class definition.

Methods

start

Parameters: reset:boolean Return: undefined

Starts the timer, resets the instance before it starts if true is passed.

stop

Parameters: reset:boolean Return: undefined

Stops the timer, resets the instance if true is passed.

reset

Parameters: stop:boolean Return: undefined

Resets the timer, stops the instance if true is passed.

tick

Parameters: none Return: undefined

Forces to calculate a timeout when called. Is called internally by when a native timer ticks.

destroy

Parameters: none Return: undefined

Destroys the instance.

quick (static)

Parameters: [timeout] [, data] [, isInterval] [, callback] Return: Ticker

Quick way to set up a disposable ticker. It will auto run and auto destruct once its purpose is fullfilled.


To Do

  • Turn timerId, time and last tick into read only parameters + make the real props ‘private’