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

@minisss/sessionstorage

v1.0.0

Published

A Window sessionstorage Manager Lib

Readme

@minisss/sessionstorage

@minisss/sessionstorage 是一个专为浏览器环境设计的轻量级本地存储库,旨在简化对 sessionstorage 的操作,同时提供丰富的功能和更好的开发体验。

  • ✅ 支持对象存储
  • ✅ 支持过期机制
  • ✅ 自定义前缀
  • ✅ 友好的 TS 类型提示(全局定义 IMSSessionStorageData 定义即可)
  • ✅ 支持 ESM CJS UMD
  • 🤡 支持广泛浏览器

安装方式

# pnpm
pnpm i @minisss/sessionstorage

# yarn
yarn add @minisss/sessionstorage

# npm
npm install @minisss/sessionstorage

# bun
bun install @minisss/sessionstorage

使用方式

ESM

import MLS from "@minisss/sessionstorage";
MLS.set("key", "val");
console.log(MLS.get("key"));

CJS

const MLS = require("@minisss/sessionstorage");
MLS.set("key", "val");
console.log(MLS.get("key"));

UMD xxx.html 普通 script 直接导入 -> 访问全局变量 MLS

// UMD
<script src="https://unpkg.com/@minisss/[email protected]"></script>
<script>
  console.log("MLS 包对象: ", MLS) MLS.set('key', 'val');
  console.log(MLS.get('key')) console.log(MLS.has('key'));
</script>

UMD xxx.html script type module 模块化内部引入方式

<script type="module">
  import MLS from "https://unpkg.com/@minisss/[email protected]/out/index.esm.js";
  console.log("MLS 包对象: ", MLS) MLS.set('key', 'val');
  console.log(MLS.get('key')) console.log(MLS.del('key'));
  console.log(MLS.has('key'));
</script>

API 及实例对象(实例对象无 create 方法)

| 名称 | 描述 | 参数 | 返回值 | | --------- | -------------- | ---------------------------------------- | --------- | | VERSION | 版本信息 | | string | | length | 据项数量 | | number | | isSupport | 是否支持 | | boolean | | key | 获取 key | key(idx:number) | any | | get | 获取 | get(key:string, config?:Config) | any | | set | 设置 | set(key:string, val:any, config?:Config) | undefined | | del | 删除 | del(key:string, config?:Config) | undefined | | clear | 清除本地数据 | clear() | undefined | | has | 判断 | has(key:string, config?:Config) | boolean | | create | 创建实例(推荐) | create(config?:Config) | 实例对象 |

Config

| 名称 | 描述 | 数据类型 | 默认值 | | ------- | ---------------------------- | -------- | --------- | | maxAge | 过期时间,单位为秒 | number | undefined | | expires | 过期时间(maxAge会覆盖此参数) | Date | undefined | | prefix | 自定义 key 前缀 | string | '' |

覆写 IMSSessionStorageData 类型接口y已支持 TS 类型提示(可选)

// 例如: 在 types/xxx.d.ts | global.d.ts 或某个 .d.ts 文件中定义 IMSSessionStorageData 类型接口
interface IMSSessionStorageData {
  name:string
  age:number
}
// 将 types/xxx.d.ts 加入到 tsconfig.json includes 中即可获得自定义类型提示功能