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

@semibold/browser-storage

v1.2.0

Published

Use the Browser-Storage API to store, retrieve user data from localStorage/sessionStorage

Downloads

16

Readme

Browser-Storage

Changelog

Use the Browser-Storage API to store, retrieve user data from localStorage/sessionStorage.

Install

Source code is written by TypeScript.

$ npm i @semibold/browser-storage

Usage

// Global
// <script src="./dist/release/browser-storage.js"></script>

// NodeJS Module
const { BrowserStorage } = require("@semibold/browser-storage");

// ES-next Module
import { BrowserStorage } from "@semibold/browser-storage";

Support

More Information: Can I Use localStorage/sessionStorage?

Instance & API

/**
 * @param {"localStorage"|"sessionStorage"} areaName
 * @param {Object} [options]
 * @param {string} [options.prefix = ""] - The prefix of storage keys. Using the
 *        Browser-Storage API to store, retrieve user data from
 *        localStorage/sessionStorage will be limited to a certain area.
 *   e.g: `bs.clear()` will only clear keys prefixed with `media_` which your
 *        previous set in `options.prefix`.
 * @param {Function} [options.parse = (text: string): any => JSON.parse(text)]
 *        Use this function to parse text before the text returns.
 * @param {Function} [options.stringify = (vaule: any): string => JSON.stringify(value)]
 *        Use this function to stringify value before setting the value.
 */
const bs = new BrowserStorage(areaName, options);

/**
 * @typedef {Object} Metadata
 * @property {string} name
 * @property {string} version
 * @property {string} revision
 * @property {boolean} production
 * @property {string} lastCompiled
 * @return {Metadata}
 */
BrowserStorage.metadata;

/**
 * @readonly
 * @return {Storage} - localStorage/sessionStorage
 */
bs.storage;

/**
 * @desc To be able to use storage, we should first verify that
 *       it is supported and available in the current browsing session
 * @return {boolean}
 */
bs.available();

/**
 * @desc Gets one or more items from storage.
 * @desc A single key to get, list of keys to get, or a dictionary specifying default
 *       values. An empty list or object will return an empty result object. Pass in
 *       null to get the entire contents of storage.
 *
 * @param {null|string|string[]|Object} keys
 * @return {Object}
 */
bs.get(keys);

/**
 * @desc Gets the amount of space (in bytes) being used by one or more items.
 * @desc A single key or list of keys to get the total usage for. An empty list will
 *       return 0. Pass in null to get the total usage of all of storage.
 *
 * @param {null|string|string[]} keys
 * @return {number} - approximate value
 */
bs.getBytesInUse(keys);

/**
 * @desc Sets multiple items.
 * @desc An object which gives each key/value pair to update storage with. Any other
 *       key/value pairs in storage will not be affected.
 * @desc The `set()` may throw an exception if the storage is full.
 *
 * @param {Object} items
 */
bs.set(items);

/**
 * @desc Removes one or more items from storage.
 * @desc A single key or a list of keys for items to remove.
 *
 * @param {string|string[]} keys
 */
bs.remove(keys);

/**
 * @desc Removes all items from storage.
 */
bs.clear();

Example

const bs1 = new BrowserStorage("localStorage");
const bs2 = new BrowserStorage("localStorage", { prefix: "test." });
if (bs1.available()) {
    bs2.set({ abc: 12358 });

    const abc1 = bs1.get("test.abc")["test.abc"];
    const abc2 = bs2.get(["abc"])["abc"];

    console.log(abc1 === abc2); // true
    console.log(abc1 === 12358); // true

    const value = "should be return this statement";
    const __inexistent_value__ = bs1.get({ __inexistent_key__: value }).__inexistent_key__;

    console.log(value === __inexistent_value__); // true
}

Reference