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 🙏

© 2025 – Pkg Stats / Ryan Hefner

web-storage-max

v0.0.25

Published

浏览器存储优化工具

Downloads

60

Readme

Web Storage Max

Web Storage Max 是一个强大的 TypeScript 库,旨在提供一个统一的接口来管理不同类型的 Web 存储,包括 localStorage、sessionStorage 和 IndexedDB。它支持多种功能,如命名空间设置、保存时效设置、全数据类型存储、数据加密、存储切换、大数据保存和缓存加速。

特点

1. 支持命名空间设置

通过前缀(prefix)来区分不同的存储区域,避免键名冲突。

2. 支持保存时效设置

可以为存储的数据设置过期时间,支持秒、分钟、小时、天、周、月和年等多种时间单位。

3. 支持全数据类型存储

能够存储和检索各种 JavaScript 数据类型,包括 undefined、null、Infinity、-Infinity、number、boolean、string、Date 和 RegExp。

4. 支持数据加密

提供多种加密选项,包括自动加密、AES 密钥加密和键加密。

5. 支持存储切换

可以在 localStorage、sessionStorage 和 IndexedDB 之间轻松切换存储类型。

6. 支持大数据保存

通过 IndexedDB 支持存储大量数据,适用于需要存储大量数据的应用场景。

7. 支持缓存加速

使用全局缓存来加速数据检索,减少对存储的访问次数。

安装

npm install web-storage-max

使用示例

设置存储

import { setStorage } from 'web-storage-max';

setStorage('myKey', 'myValue', {
  prefix: 'myNamespace',
  countdown: { seconds: 60 },
  aesKey: 'myAESKey',
  enableAutomaticEncryption: true,
  keyEncryption: true,
  storageType: 1,// 0: localStorage, 1: sessionStorage, 2: IndexedDB
});

获取存储

import { getStorage } from 'web-storage-max';

const value = getStorage('myKey', {
  prefix: 'myNamespace',
  aesKey: 'myAESKey',
  enableAutomaticEncryption: true,
  keyEncryption: true,
  storageType: 1,// 0: localStorage, 1: sessionStorage, 2: IndexedDB 暂未开放
});

console.log(value); // 

删除存储

import { removeStorage } from 'web-storage-max';

removeStorage('myKey', {
  prefix:'myNamespace',
  keyEncryption: true,
  storageType: 1,// 0: localStorage, 1: sessionStorage, 2: IndexedDB 暂未开放
});

API 文档

setStorage 设置存储数据。

参数

key (string): 存储的键名。
value (any): 存储的值。
config (WSMConfig): 配置对象,包括前缀、倒计时、过期时间、AES 密钥、自动加密、键加密和存储类型。

返回值

Promise | void: 如果使用 IndexedDB,返回一个 Promise;否则返回 void。

获取存储数据。

参数

key (string): 存储的键名。
config (WSMConfig): 配置对象,包括前缀、AES 密钥、自动加密、键加密和存储类型。

返回值

Promise | any: 如果使用 IndexedDB,返回一个 Promise;否则返回存储的值

贡献

欢迎贡献代码、报告问题或提出建议。请查看 贡献指南 了解更多信息。

许可证

本项目采用 ISC 许可证。