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

@axolo/storage

v0.2.0

Published

JavaScript Storage with prefix and codec.

Readme

@axolo/storage

一个支持命名空间前缀和自动编解码的 JavaScript Storage 封装库。

特性

  • 命名空间隔离:通过前缀实现多实例数据隔离,避免 key 冲突
  • 自动编解码:自动 JSON.stringify/JSON.parse,支持任意数据类型
  • 灵活引擎:默认使用 localStorage,可切换为 sessionStorage 或自定义存储引擎
  • 链式调用:setItem、removeItem、clear 等方法支持链式操作
  • TypeScript 支持:完整的类型声明
  • 零依赖:轻量级,不依赖任何第三方库
  • UMD/ESM 双格式:支持浏览器直接引入和模块化引入

安装

npm i @axolo/storage

使用

import ScopedStorage from '@axolo/storage';

// 创建带前缀的存储实例
const store = new ScopedStorage('app:');

// 存储数据
store.setItem('user', { id: 1, name: 'axolo' });
store.setItem('token', 'abc123');
store.setItem('count', 100);

// 读取数据
const user = store.getItem('user'); // { id: 1, name: 'axolo' }
const token = store.getItem('token'); // 'abc123'
const count = store.getItem('count'); // 100

store.has('user'); // true
store.keys(); // ['user', 'token', 'count']
store.removeItem('count');
store.clear();

API

new ScopedStorage(prefix?: string, engine?: Storage)

| 参数 | 类型 | 默认值 | 说明 | | -------- | --------- | -------------- | --------------------------------------- | | prefix | string | | 命名空间前缀,所有 key 会自动拼接此前缀 | | engine | Storage | localStorage | 存储引擎,可选sessionStorage |

setItem(key: string, value: any): this

存储数据,自动 JSON 序列化。

getItem(key: string): any

读取数据,自动 JSON 反序列化。

removeItem(key: string): this

移除指定 key。

keys(): string[]

返回所有带当前前缀的 key 列表(已去除前缀)。

has(key: string): boolean

检查 key 是否存在。

clear(): this

清空当前前缀下的所有数据,不影响其他前缀的数据。

getSize(): number

获取当前前缀下所有存储内容的总字符长度(基于 JSON 序列化后的字符串)。

License

MIT