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

kychentest

v0.3.0

Published

web storage

Readme

cat-web-storage

cat-web-storage 是一个轻量级的 Web 存储工具库,它对 web storage API 进行了封装,简化了所需额外编码处理存储数据的操作。 未来将会支持加密存储和可接受自定义加密函数,以及对 IndexedDB 的支持。

版本说明 | 下载 js 版本

引入后使用出现红色警告波浪线或者未能通过 “.” 的方式来获取代码提示 请看这里

install

npm i cat-web-storage -S

main

import webstorage from 'cat-web-storage';
Vue.use(webstorage);

Usage

interface

  • WebStorage

function

// 实现 WebStorage
class LocalStorage implements WebStorage { ... }
class SessionStorage implements WebStorage { ... }
class CookieStorage implements WebStorage { ... }

// 类型定义
declare module {
  interface Vue {
    $localStorage: LocalStorage
    $sessionStorage: SessionStorage
    $cookieStorage: CookieStorage
  }
} 

See also

set (key: string, value: any, opts?: Options): void

// Vue
this.$localStorage.set('number', 10086);

this.$localStorage.set('string', '从前有座山……');

this.$localStorage.set('object', {'移动客服': 10086});

this.$localStorage.set('array', [10086, 10000, 10001, '小灵通?']);

// window
window.$localStorage.set('array', [10086, 10000, 10001, '小灵通?']);

get (key: string): object | string

获取 web storage 时会尝试将存储时的数据类型还原,如果还原失败会返回字符串undefined

// Vue
this.$localStorage.get('number');

this.$localStorage.get('string');

this.$localStorage.get('object');

this.$localStorage.get('array');

// window
window.$localStorage.get('array');

remove (key: string): object | string

将指定 key 的存储项从列表中移除。

// Vue
this.$localStorage.remove('array');

// window
window.$localStorage.remove('array');

key (index: number): string

通过下标的方式获取存储列表中的项。但是,存储列表的顺序并非以存储时的顺序作为排序,所以使用此函数时可能不会返回期望的数据。

// Vue
this.$localStorage.key(1);

this.$localStorage.key(4);

// window
window.$localStorage.key(1);

clear (): void

此函数会将存储列表全部清除。请谨慎使用。

// Vue
this.$localStorage.clear();

// window
window.$localStorage.clear();

修复警告/无法通过“.”提示代码

在模块描述文件内添加如下内容,例如:shims.d.ts 文件。

import Vue from 'vue';
import {
  LocalStorage,
  SessionStorage,
  CookieStorage
} from 'cat-web-storage';

declare module 'vue/types/vue' {
  interface Vue {
    $localStorage: LocalStorage
    $sessionStorage: SessionStorage
    $cookieStorage: CookieStorage
  }
}