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

storagens

v1.0.5

Published

## 安装

Readme

StorageNS(可以设置命名空间的 Storage)

安装

npm install storagens
# or
yarn add storagens

使用

创建实例

import { LocalStorage, SessionStorage } from "storagens";

const localStorage = new LocalStorage();
const sessionStorage = new SessionStorage();

// 设置命名空间
const userLocalStorage = new LocalStorage("user");
const userSessionStorage = new SessionStorage("user");

保存数据

userLocalStorage.set("name", "Bean"); // => void
// user.name: "{\"value\":\"Bean\",\"updateTime\":1623985976434,\"expireTime\":0}"
// expireTime default:0

保存数据并设置过期时间

userLocalStorage.set(
  "token",
  "A8515509F42D80553AE2495DCDBFE9A7",
  Date.now() + 864e5
); // => void
// user.token: "{\"value\":\"A8515509F42D80553AE2495DCDBFE9A7\",\"updateTime\":1623986348117,\"expireTime\":1624072748116}"

通过数据名称读取包装数据

userLocalStorage.get("name"); // => {value: "Bean", updateTime: 1623986570960, expireTime: 0}

通过数据名称读取原始数据

userLocalStorage.getValue("name"); // => Bean

读取全部包装数据

userLocalStorage.all(); // => {name: {value: "Bean", updateTime: 1623987036202, expireTime: 0}, token: {value: "A8515509F42D80553AE2495DCDBFE9A7", updateTime: 1623987036203, expireTime: 1624073436202}}
userLocalStorage.getAll(); // 也可以使用 getAll()

读取全部原始数据

userLocalStorage.allValues(); // => {name: "Bean", token: "A8515509F42D80553AE2495DCDBFE9A7"}
userLocalStorage.values(); // 也可以使用 values()

通过数据名称检查数据是否存在

userLocalStorage.has("name"); // => true
userLocalStorage.has("age"); // => false

通过数据名称检查数据是否已过期

userLocalStorage.expired("token"); // => boolean

清除全部已过期数据

userLocalStorage.clearExpired(); // => number

通过数据名称删除数据

userLocalStorage.delete("name"); // => void

清空全部数据(只会清空属于该命名空间的数据)

userLocalStorage.clear(); // => void