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

@aegisjsproject/tempo

v1.0.1

Published

Tempo provides advanced debouncing and throttling utilities for fine-grained execution control.

Readme

@aegisjsproject/tempo

Tempo provides advanced debouncing and throttling utilities for fine-grained execution control.

CodeQL Node CI Lint Code Base

GitHub license GitHub last commit GitHub release GitHub Sponsors

npm node-current npm bundle size gzipped npm

GitHub followers GitHub forks GitHub stars Twitter Follow

Donate using Liberapay


@aegisjsproject/tempo

A lightweight JavaScript library for debouncing and throttling functions using modern, native web APIs.


Overview

@aegisjsproject/tempo provides robust debouncing and throttling utilities by leveraging the browser's latest scheduling and locking APIs. Using methods like scheduler.postTask and navigator.locks.request, the library offers precise task scheduling with native priority support, efficient cancellation via AbortSignals, and streamlined resource management.


Features

  • Debounce Function
    Debounces a callback function by scheduling it with scheduler.postTask. It supports custom delays, task priorities (user-blocking, user-visible, background), and cancellation through AbortSignals.

  • Throttle Function
    Throttles a callback by combining scheduler.postTask with navigator.locks.request for controlled, queued execution. It provides options for lock naming, immediate failure or lock stealing, and built-in delay management.


Advantages of Modern Methods

  • Native Integration:
    Leverages browser-native APIs for task scheduling and lock management, reducing dependency overhead and resulting in smaller bundle sizes.

  • Improved Performance:
    Native scheduling with scheduler.postTask allows tasks to be queued based on system and user priorities, leading to smoother and more responsive applications.

  • Enhanced Control:
    With built-in support for AbortSignals and fine-grained control over task priorities, developers can efficiently manage resource-intensive operations.

  • Optimized Concurrency:
    The use of navigator.locks.request ensures that throttled tasks handle concurrent execution gracefully without resorting to heavy third-party libraries.


Installation

Install the package via npm:

npm install @aegisjsproject/tempo

Usage

Import the desired functions into your project:

import { debounce, throttle } from '@aegisjsproject/tempo';

Usage with a CDN and <script type="importmap">

<script type="importmap">
  {
    "imports": {
      "@aegisjsproject/tempo": "https://unpkg.com/@aegisjsproject[:version]/tempo.js"
    }
  }
</script>

Debounce Example

const debouncedAction = debounce(() => {
  // Your callback code here.
}, {
  delay: 300,
  priority: 'user-visible',
  signal: myAbortSignal, // Optional: provide an AbortSignal for cancellation.
});

Throttle Example

const throttledAction = throttle(() => {
  // Your callback code here.
}, {
  lockName: 'uniqueLockName', // Optional: defaults to a random UUID.
  delay: 200,
  priority: 'background',
  ifAvailable: true, // Immediately fail if the lock is unavailable.
  signal: myAbortSignal, // Optional: provide an AbortSignal for cancellation.
});

API Documentation

debounce(callback, options)

  • Parameters:

    • callback (Function): The function to debounce.
    • options (Object, optional):
      • delay (number): The debounce delay in milliseconds.
      • priority ("user-blocking" | "user-visible" | "background"): The task priority.
      • signal (AbortSignal): Signal to cancel the debounced call.
      • thisArg (any, default: null): The this context for the callback.
  • Returns:
    A debounced version of the input function.

  • Throws:

    • TypeError if the callback is not a function.
    • Error if the provided AbortSignal is already aborted.

throttle(callback, options)

  • Parameters:

    • callback (Function): The function to throttle.
    • options (Object, optional):
      • lockName (string, default: crypto.randomUUID()): Name for the lock.
      • delay (number): Delay in milliseconds after task execution.
      • priority ("user-blocking" | "user-visible" | "background"): The task priority.
      • ifAvailable (boolean, default: true): Fail immediately if the lock is not available.
      • steal (boolean, default: false): Allow stealing of the lock.
      • mode ("shared" | "exclusive", default: "exclusive"): The lock mode (only 'exclusive' is supported).
      • thisArg (any, default: null): The this context for the callback.
      • signal (AbortSignal): Signal to cancel the throttled call.
  • Returns:
    A throttled version of the input function.

  • Throws:

    • TypeError if the callback is not a function or if both steal and ifAvailable are set to true.
    • Error if the provided AbortSignal is already aborted.