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

timepulse

v0.0.1

Published

Handle timers like a pro

Downloads

2

Readme

⏳ Timepulse

Timepulse is a lightweight and flexible library for managing countdown timers with advanced features like event listeners, customizable tick intervals, milestones, and support for chained or simultaneous timers.


🚀 Features

  • Precise countdown timers: Accurate to the millisecond using performance.now().
  • Customizable tick intervals: Set the frequency of tick events (default: 1000ms).
  • Event-driven: Listen to tick, start, pause, resume, complete, and custom milestones.
  • Pause and resume support: Stop the timer at any point and resume from where it left off.
  • Milestones: Trigger events at specific time intervals (e.g., every 5s).
  • Multi-timer management: Manage multiple timers simultaneously.
  • Chained timers: Run multiple timers in sequence.

📦 Installation

Install via npm:

npm install timepulse

Or yarn:

yarn add timepulse

🔧 Usage

Import the library

import { CountdownTimer, MultiTimer, TimerChain } from 'timepulse';

🔹 Basic Countdown Timer

Create a countdown timer and listen to tick and complete events.

const timer = new CountdownTimer(5000); // 5 seconds

timer.on('tick', (remainingTime) => {
  console.log(`Time remaining: ${Math.ceil(remainingTime / 1000)}s`);
});

timer.on('complete', () => {
  console.log('Countdown complete!');
});

timer.start();

Output:

Time remaining: 5s
Time remaining: 4s
Time remaining: 3s
Time remaining: 2s
Time remaining: 1s
Countdown complete!

🔹 Custom Tick Intervals

Customize the frequency of tick events.

const timer = new CountdownTimer(3000, 500); // 3 seconds, tick every 500ms

timer.on('tick', (remainingTime) => {
  console.log(`Time remaining: ${remainingTime.toFixed(0)}ms`);
});

timer.on('complete', () => {
  console.log('Timer complete!');
});

timer.start();

Output:

Time remaining: 2500ms
Time remaining: 2000ms
Time remaining: 1500ms
Time remaining: 1000ms
Time remaining: 500ms
Timer complete!

🔹 Pause and Resume

Pause the timer and resume it later.

const timer = new CountdownTimer(5000);

timer.on('pause', (remainingTime) => console.log(`Paused with ${remainingTime}ms remaining`));
timer.on('resume', (remainingTime) => console.log(`Resumed with ${remainingTime}ms remaining`));

timer.start();

setTimeout(() => timer.pause(), 2000); // Pause after 2s
setTimeout(() => timer.resume(), 4000); // Resume after 4s

Output:

Paused with 3000ms remaining
Resumed with 3000ms remaining

🔹 Milestones

Trigger events when specific time intervals are reached.

const timer = new CountdownTimer(10000); // 10 seconds

timer.setMilestones(8, 5, 2); // At 8s, 5s, and 2s remaining

timer.on('milestone', (remainingTime) => {
  console.log(`Milestone reached: ${Math.ceil(remainingTime / 1000)}s remaining`);
});

timer.on('complete', () => console.log('Countdown complete!'));

timer.start();

Output:

Milestone reached: 8s remaining
Milestone reached: 5s remaining
Milestone reached: 2s remaining
Countdown complete!

🔹 Manage Multiple Timers (MultiTimer)

Create and manage multiple timers simultaneously.

const manager = new MultiTimer();

const timer1 = manager.createTimer(3000);
timer1.on('complete', () => console.log('Timer 1 complete!'));

const timer2 = manager.createTimer(5000);
timer2.on('complete', () => console.log('Timer 2 complete!'));

manager.startAll();

Output:

Timer 1 complete!
Timer 2 complete!

🔹 Chained Timers (TimerChain)

Run timers in sequence.

const chain = new TimerChain();

chain.addTimer(3000); // Timer 1: 3 seconds
chain.addTimer(2000); // Timer 2: 2 seconds

chain.getTimers().forEach((timer, index) => {
  timer.on('complete', () => console.log(`Timer ${index + 1} complete!`));
});

chain.startChain().then(() => console.log('All timers complete!'));

Output:

Timer 1 complete!
Timer 2 complete!
All timers complete!

🛠️ API Reference

CountdownTimer

const timer = new CountdownTimer(duration: number, tickInterval?: number);

| Parameter | Type | Default | Description | |----------------|----------|----------|--------------------------------------------------| | duration | number | Required | Timer duration in milliseconds. | | tickInterval | number | 1000 | Interval for tick events in milliseconds. |

Events

  • tick: Triggered at each tick interval.
  • milestone: Triggered when a milestone is reached.
  • pause: Triggered when the timer is paused.
  • resume: Triggered when the timer is resumed.
  • start: Triggered when the timer starts.
  • complete: Triggered when the timer completes.
  • reset: Triggered when the timer is reset.

Methods

  • start(): Promise<void>: Starts or resumes the timer.
  • pause(): void: Pauses the timer.
  • resume(): void: Resumes the timer.
  • reset(): void: Resets the timer to its initial duration.
  • setMilestones(...seconds: number[]): void: Sets milestones at specific times.
  • getRemainingTime(): number: Returns the remaining time.

MultiTimer

Manage multiple timers.

  • createTimer(duration, tickInterval?): Creates and adds a timer to the manager.
  • startAll(): Starts all timers simultaneously.
  • pauseAll(): Pauses all timers.
  • resetAll(): Resets all timers.

TimerChain

Run timers in sequence.

  • addTimer(duration, tickInterval?): Adds a timer to the chain.
  • startChain(): Runs all timers sequentially.
  • getTimers(): Returns all timers in the chain.

🧪 Tests

Timepulse is fully tested using Jest. To run tests:

npm test

📜 License

MIT


Timepulse: Manage time with precision and ease. 🚀