Skip to main content

CurateClick

github.com favicon

proxy-web-storage

一个基于Proxy封装的JavaScript库,扩展了localStorage和sessionStorage的功能,支持直接操作Object、Array等复杂数据类型,提供数据变化监听和过期时间设置功能。

Check out proxy-web-storage on CurateClick

• Copy the embed code to showcase this product on your website

• Share on X to spread the word about this amazing tool

项目地址: https://github.com/KID-joker/proxy-web-storage文章地址: https://juejin.cn/post/7144142689594769415项目介绍: 借助proxy,扩展了web storage的功能,使用起来,更加方便快捷,也更加强大。主要功能为保持值类型不变,可直接操控Object、Array,支持监听数据变化和设置过期时间。## Features### BaseGet what you set and change array and object directly.jsimport { local, session } from 'proxy-web-storage';local.test = 'Hello proxy-web-storage'; // worksdelete local.test; // works// numberlocal.test = 0;local.test === 0; // true// booleanlocal.test = false;local.test === false; // true// undefinedlocal.test = undefined;local.test === undefined; // true// nulllocal.test = null;local.test === null; // true// objectlocal.test = { hello: 'world' };local.test.hello = 'proxy-web-storage'; // works// arraylocal.test = ['hello'];local.test.push('proxy-web-storage'); // workslocal.test.length // 2// Datelocal.test = new Date('2000-01-01T00:00:00.000Z');local.test.getTime() === 946684800000; // true// RegExplocal.test = /d(b+)d/g;local.test.test("cdbbdbsbz"); // true// functionlocal.test = function() { return 'Hello proxy-web-storage!';};local.test() === 'Hello proxy-web-storage!'; // true### Subscribelisten for changes.jsimport { local } from 'proxy-web-storage';local.on('test', function(newVal, oldVal) { console.log('test', newVal, oldVal);});local.on('test.a', function(newVal, oldVal) { console.log('test.a', newVal, oldVal);});local.test = {};// test {} undefinedlocal.test.a = 1;// test.a 1 undefined### Expiredset expires for items.jsimport { local } from 'proxy-web-storage';local.test = 'hello proxy-web-storage';local.setExpires('test', Date.now() + 10000);// after 10'slocal.test // undefined

Latest Weekly Picks

promptbuilder.cc favicon
Weekly Pick

Generate, optimize, test, and manage AI prompts in one place. Turn an idea into a ready-to-use prompt in seconds.

Prompt Builder
freqz.net favicon
Weekly Pick

Your Personal K-Style Vibe Photo Studio

Freqz
webleadr.com favicon
Weekly Pick

Find and contact web design leads and businesses without websites, like local dentists, effortlessly from any location in just a few clicks.

Webleadr

the art of having something to say

pretty-scale.com favicon
Weekly Pick

How Pretty Are You? Let AI Decide.

Pretty Scale
c2story.com favicon
Weekly Pick

Create Illustrated Stories with AI

C2story

Impromptu Speech Topics & Timer

Seedance 2.0: Multimodal AI video creator. Precisely direct characters and cameras to create production-ready, multi-shot cinematic stories in one click.