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

audio-to-haptics

v0.0.3

Published

Converts audio into haptic (vibration) feedback patterns using the Web Audio API and Vibration API. Analyzes an audio file, detects amplitude spikes and decay tails, and drives `navigator.vibrate()` in sync with a media element.

Readme

audio-to-haptics

Converts audio into haptic (vibration) feedback patterns using the Web Audio API and Vibration API. Analyzes an audio file, detects amplitude spikes and decay tails, and drives navigator.vibrate() in sync with a media element.

Only works on Android Chrome and some mobile browsers — no desktop vibration support.

Docs & demo → https://audio-to-haptics.pages.dev

Want to learn more? Read the full writeup on Dev.to →


Install

npm install audio-to-haptics

Usage

Vanilla JS / any framework:

import { HapticEngine } from 'audio-to-haptics'

const engine = new HapticEngine()
await engine.analyze(url)
engine.attach(audioElement, (time) => updateUI(time))
engine.detach()

React:

import { useHaptics } from 'audio-to-haptics/react'

const audioRef = useRef(null)
const { analyze, ready } = useHaptics(audioRef)

<audio ref={audioRef} controls />
<button onClick={() => analyze(url)}>{ready ? 'Re-analyze' : 'Analyze'}</button>

This Repository

This repo serves two purposes:

  1. The npm library (src/audio/, src/index.ts, src/react.ts) — the actual published package
  2. A dev playground (src/App.tsx, src/WaveformView.tsx, src/SimpleUsage/, src/MediaUsage/) — used during development for testing and tuning the algorithm on real audio. Not deployed anywhere.

Project Structure

src/
  index.ts             — library entry point (vanilla JS / any framework)
  react.ts             — library entry point (React)
  audio/
    HapticEngine.ts    — core class: analysis pipeline + RAF vibration loop
    useHaptics.ts      — React hook wrapping HapticEngine
    analyzeAudio.ts    — pure analysis functions and all exported types
    snapshots.test.ts  — snapshot tests (6 fixtures, 12 tests)
    fixtures.ts        — test fixtures with real audio trends and expected outputs

  App.tsx              — dev playground UI: URL input, play controls, waveform view
  WaveformView.tsx     — canvas waveform visualizer with haptic overlays
  SimpleUsage/         — minimal hook usage demo (audio element)
  MediaUsage/          — hook usage demo with video element

lib/                   — library build output (gitignored, generated by npm run build:lib)
public/                — local audio/video files for dev testing (gitignored)

Commands

npm run dev          # start dev server for the playground
npm run build:lib    # build the library to lib/
npm run test         # run snapshot tests
npm run lint         # run ESLint

Dev Playground

App.tsx is the main testing UI — paste an audio URL, analyze it, and play with haptic feedback on a real Android device. WaveformView.tsx visualizes the waveform with intensity-colored overlays showing exactly which sections will vibrate and how strongly.

SimpleUsage/ and MediaUsage/ are minimal demos built using the useHaptics hook directly, simulating how a library consumer would use it.

Drop local audio files in public/ and reference them as /filename.mp3 in the dev UI.


Build System

Two separate Vite configs:

  • vite.config.ts — dev server only (React plugin, serves public/)
  • vite.lib.config.ts — library build (publicDir: false, lib mode, React externalized)

Four TypeScript configs:

  • tsconfig.json — root, references the others
  • tsconfig.app.json — dev app type checking (src/, noEmit)
  • tsconfig.node.json — Vite config files type checking
  • tsconfig.lib.json — library declaration emit only (lib/, excludes test files)