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

earcons

v0.4.0

Published

Tiny vanilla TypeScript library for playing UI notification sounds via the Web Audio API — no audio files, no dependencies.

Readme

earcons

Tiny vanilla TypeScript library for UI notification sounds — pure Web Audio API, no audio files, zero dependencies.

npm CI bundle size license

▶ Live demo

Why earcon?

| | earcon | Howler.js | Tone.js | ZzFX | |---|:---:|:---:|:---:|:---:| | No audio files | ✅ | ❌ | ✅ | ✅ | | Notification-specific API | ✅ | ❌ | ❌ | ❌ | | TypeScript native | ✅ | via @types | ✅ | ❌ | | Zero dependencies | ✅ | ✅ | ❌ | ✅ | | Bundle size | ~3 KB | 318 KB | 5.4 MB | <1 KB | | Semantic sound names | ✅ | ❌ | ❌ | ❌ | | Customizable | ✅ | ✅ | ✅ | ✅ |

An earcon is an auditory icon — a short, meaningful sound signal used in user interfaces. This library provides a curated set of them, generated entirely in code.


Install

npm install earcons

CDN (no build step)

<!-- jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/earcons/dist/earcon.min.global.js"></script>

<!-- unpkg -->
<script src="https://unpkg.com/earcons/dist/earcon.min.global.js"></script>

All functions are available under the global Earcon object:

<button onclick="Earcon.playSuccess()">✅</button>
<button onclick="Earcon.playError()">❌</button>
<script>
  // or
  Earcon.earcon("notification", { volume: 0.8 });
</script>

Quick start

import { playSuccess, playError, playWarning } from "earcons";

// Defaults — medium variant, volume 0.5
await playSuccess();
await playError();
await playWarning();

API

Named play functions

Each function accepts an optional SoundOptions object.

import {
  playSuccess,
  playError,
  playWarning,
  playNotification,
  playClick,
  playInfo,
} from "earcons";

await playSuccess();
await playError({ variant: "long", volume: 0.8 });
await playWarning({ variant: "short" });
await playNotification({ pitch: 7 }); // +7 semitones
await playClick({ variant: "short" });
await playInfo({ volume: 0.3 });

Generic earcon() — play by name

import { earcon } from "earcons";

await earcon("success");
await earcon("error", { variant: "long" });

Built-in sound names: success · error · warning · notification · click · info

Register a custom sound

import { registerSound, earcon } from "earcons";
import type { SoundPreset } from "earcons";

const chirp: SoundPreset = (_variant, _pitch) => ({
  name: "chirp",
  duration: 0.15,
  notes: [
    { frequency: 1200, duration: 0.07, startAt: 0, waveShape: "sine" },
    { frequency: 1600, duration: 0.08, startAt: 0.07, waveShape: "sine" },
  ],
});

registerSound("chirp", chirp);
await earcon("chirp");

SoundOptions

| Option | Type | Default | Description | |---|---|---|---| | volume | number | 0.5 | Master volume, 0–1 | | variant | "short" \| "medium" \| "long" | "medium" | Duration variant | | pitch | number | 0 | Semitone offset (±) | | audioContext | AudioContext | shared singleton | Bring your own context | | onEnded | () => void | — | Called when the sound finishes |

AudioContext management

import { closeAudioContext, setAudioContext } from "earcons";

// Provide your own AudioContext (useful in frameworks)
const myCtx = new AudioContext();
setAudioContext(myCtx);

// Tear down (e.g. on unmount)
await closeAudioContext();

Sound reference

UI sounds

| Name | Waveform | Character | |---|---|---| | success | sine | Ascending major triad — bright, positive | | error | sawtooth | Descending tritone — harsh, attention-grabbing | | warning | triangle | Flat then descending minor second — cautious | | notification | sine | Soft descending two-tone ding — neutral | | click | sine | Very short transient — tactile UI feedback | | info | sine | Single soft tone — informational, non-intrusive | | toggle | triangle | Short tactile pop — on/off switch | | delete | sawtooth | Rapid descending — destructive action | | message | sine | Soft high ping — incoming chat message | | upload | sine | Ascending sweep — file sent | | download | sine | Descending sweep — file received |

Fun & misc

| Name | Waveform | Character | |---|---|---| | eightBit | square | Chiptune arpeggio — retro 8-bit 🕹️ | | police | sawtooth | Alternating wee-woo siren 🚨 | | coin | square | Classic pickup coin 🪙 | | boing | sine | Comedy spring drop 🎪 |


Browser support

Any browser that supports the Web Audio API (all modern browsers since 2014).

Autoplay policy: earcon automatically calls AudioContext.resume() before playing. Make sure you call a play function in response to a user gesture on first load, or the browser may suppress audio.


License

MIT