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

@daisy-petal/bx-storage-cache

v1.0.0

Published

Lightweight background data synchronization library for browser extensions with built-in exponential backoff and jitter.

Readme

bx-storage-cache

Lightweight background data synchronization library for browser extensions with built-in exponential backoff and jitter.

Features

  • 🔄 Automated Background Sync: Leverages browser.alarms for periodic updates.
  • 📉 Resilient Retries: Implements Equal Jitter strategy to prevent thundering herd problems during API failures.
  • 🛠 Lifecycle Management: Auto-initializes on extension install or update.

Installation

npm install @daisy-petal/bx-storage-cache
yarn add @daisy-petal/bx-storage-cache
pnpm add @daisy-petal/bx-storage-cache
bun add @daisy-petal/bx-storage-cache

Quick Start

  1. Add permissions to your manifest.json:
{
  "permissions": ["storage", "alarms"]
}
  1. Register your cache in the background script:
import { registerBxStorageCache } from '@daisy-petal/bx-storage-cache'

interface PriceData {
	price: number
	currency: string
}

const priceCache = registerBxStorageCache<PriceData>(
	{ price: 0, currency: 'USD' },
	'price',
	async () => {
		const data = await fetch('https://api.example.com')
		return data.json()
	},
	{
		periodInMin: 30,
		retryDelayInMs: {
			base: 2 * 1000,
			max: 10 * 60 * 1000
		}
	}
);

// To get the value later:
// const { price } = await browser.storage.local.get('price');

How it works

  1. Initialization: On runtime.onInstalled, init() is called to set the default state.
  2. Sync Cycle: The onAlarm handler triggers your getActualValue function.
  3. Error Recovery: If the fetcher throws an error:
    1. It calculates a retry delay using exponential backoff.
    2. Adds "Equal Jitter" to the delay to spread out server load.
    3. Persists the attempt count in storage to survive background page suspensions.
  4. Storage Keys: id: Contains the cached data. @daisy-petal/bx-storage-cache:${id}: Internal metadata for managing retry state.

API Reference

registerBxStorageCache<Value>(initValue, id, getActualValue, options)

The primary entry point. It instantiates the class and attaches necessary listeners to browser.alarms and browser.runtime.

BxStorageCache<Value> Class

  • forceSync(): Clears existing alarms and triggers an immediate update.
  • destroy(): Wipes data from storage and cancels all scheduled alarms.
  • init(value): Resets the cache to a specific value and clears retry metadata.