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 🙏

© 2024 – Pkg Stats / Ryan Hefner

front-end-cache

v1.0.2

Published

支持typescript的前端浏览器缓存管理工具,browser front end cache (支持localstorage, sessionstorage, cookie)

Downloads

5

Readme

FrontEndCache

统一前端浏览器缓存管理,支持 cookielocalStoragesessionStorage

文档

语法:new FrontEndCache<ValueType>(key[, options]);

key

当前缓存对象的 key,可以通过 options.encryKey 对其加密。

options 属性

参数|类型|必填|默认值|说明 :---:|:---:|:---:|:---|:--- type|localStorage | sessionStorage | cookie|❌|localStorage|类型 domain|string|❌|location.hostname|仅仅 type=cookie注意和 原生 cookie 的区分,默认不是当前 path domain|string|❌|/|同 cookiepath 配置 expires|number|❌|-|过期时间,默认单位 seconds 针对 sessionStoragecookie 默认值为当前会话 针对 localStorage 默认值为 永久 expiresUnit|years | months | days | hours | minutes | seconds|❌|seconds|过期时间单位 secure|boolean|❌|false|仅仅 type=cookie serialize|boolean|❌|true|是否序通过 JSON.stringify 列化 value如果为 cookie 还会通过 encodeURIComponent 一次 JSON.stringify 后的数据仅在 value 类型为 string 的时候可以禁用序列化,但同样会调用 encodeURIComponent encryKey|(key: string) => string|❌|-|加密 key 的函数需要注意如果 type = 'cookie', 最终的 key 也会 encodeURIComponent

使用

/** cache.ts */

import FrontEndCache from 'front-end-cache';

export const accessToken = new FrontEndCache<string>('ACCESS_TOKEN', { type: 'cookie', serialize: false });

export const userinfoCache = new FrontEndCache<UserInfoModel>('PROJECTNAME_USERINFO_CACHE');

/** more cache */
import { userinfoCache } from 'utils/cache.ts';

userinfoCache.setItem({ id: 1, name: 'xxx' });

userinfoCache.getItem();