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

super-localstorage

v2.1.0

Published

super-localstorage 是 利用window.localStorage进行储存的插件可以加密储存【^运算符操作加密,可自定义密匙】,且可存取【Array ,Object, Boolean, Number, String】等类型的数据无需做JSON.stringify()或JSON.parse()处理。

Downloads

37

Readme

super-localstorage

介绍

super-localstorage 是利用window.localStorage进行直接存储或获取ArrayObjectBooleanNumberString类型数据的插件其功能主要有:

  1. 支持接存储 ArrayObject,Boolean等类型数据。无需做JSON.parse()等处理,获取 ArrayObject,Boolean等数据时也不用做 JSON.stringify() 等处理处理
  2. 支持分组管理(可设置分组,可配合用户角色删除某个角色下的所有localstorage
  3. 支持设置过期日期(仅支持时间戳或 Date 实例类型的过期时间)
  4. 支持加密存储 (使用^运算符操作加密,可自定义密匙,无依赖,高效率)
  5. 支持删除某条由本插件创建的localstorage
  6. 支持按分组删除所有该分组下的localstorage
  7. 支持删除全部由本插件创建的localstorage
  8. 支持删除所有的 localstorage 即不管是不是本插件创建的localstorage都删除
  9. 无依赖,高效率,超轻量,压缩后仅 3kb 左右

遵循 MIT 开源协议。开源地址:https://gitee.com/mxp131011/super-localstorage.git

问题反馈和功能建议

  1. 在 gitee 中提交 issues
  2. 邮箱:[email protected]
  3. 微信:mxp131011

安装

npm install super-localstorage

引入 super-localstorage

import SuperLocalstorage from 'super-localstorage';

创建实例

/**
 * 第一个参数是自定义分组的组名,不传默认为:'_MXP_GROUP_'
 * 第二个参数加密的密匙,不传默认为:'_MXP_ENCRYPT_'
 */
const storage = new SuperLocalstorage();
const storage2 = new SuperLocalstorage('admin', 'my_secret_Key');

存储数据 【非加密】

仅支持存储 Array,Object,Number,Boolean, String 类型对象 (无需做 JSON.stringify()等类似处理)

// 永久有效
storage.set('aa', { foo: 100 });
// 设置过期时间 (支持Date实例或时间戳)
storage.set('bb', true, new Date());
storage.set('cc', [true, 0, '2', { a: 1 }], new Date().getTime());

获取数据【非加密】

得到存储的数据 (如未设置或者已过期则返回 null)

storage.get('aa');
storage.get('bb');
storage.get('cc');

存储数据 【加密】

仅支持存储 Array,Object,Number,Boolean, String 类型对象 (无需做 JSON.stringify()等类似处理)

// 永久有效
storage.setEncrypt('aa', { foo: 100 });
// 设置过期时间 (支持Date实例或时间戳)
storage.setEncrypt('bb', true, new Date());
storage.setEncrypt('cc', [true, 0, '2', { a: 1 }], new Date().getTime());

获取数据【加密】

得到存储的数据 (如未设置或者已过期则返回 null)

storage.getEncrypt('aa');
storage.getEncrypt('bb');
storage.getEncrypt('cc');

设置或修改组名

storage.setGroupName('user');

设置或修改加密的密匙

storage.setSecretKey('_user_encrypt_');

删除某个由本插件创建的 localStorage

storage.del('aa');

删除某个分组下的所有 localStorage

// 删除默认分组下的所有 localStorage
storage.delGroup();
// 删除指定分组下的所有 localStorage
storage.delGroup('user');

删除本插件创建的所有 localStorage

storage.delMyAll();

删除全部的 localStorage

/**
 * 删除全部的localStorage 包括非本插件创建的localStorage
 */
storage.delAll();