stokado

Weekly Pick

stokado是一个JavaScript库,可以代理任何类storage对象,提供简洁的语法糖操作、类型序列化、监听订阅、设置过期和一次性取值等功能,兼容localStorage、sessionStorage等存储方案。

Check out stokado 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/stokado文章地址: https://juejin.cn/post/7357546247848869926项目介绍: stokado 可以代理任何类 storage 的对象,实现简洁的 getter,setter 等语法糖,序列化,监听订阅,设置过期,一次性取值等功能。#### 1. Syntax sugar通过对象方式直接操作 storage````jsconst storage = createProxyStorage(localStorage)storage.test = 'hello stokado'storage.test // 'hello stokado'delete storage.test```同时也支持 storage 的原生方法和属性:key()getItem()setItem()removeItem()clear()length。#### 2. Serializer保持值类型不变```js// numberstorage.test = 0storage.test === 0// booleanstorage.test = falsestorage.test === false// undefinedstorage.test = undefinedstorage.test === undefined// nullstorage.test = nullstorage.test === null// objectstorage.test = { hello: 'world' }storage.test.hello === 'stokado'// arraystorage.test = ['hello']storage.test.push('stokado')storage.test.length // 2// Datestorage.test = new Date('2000-01-01T00:00:00.000Z')storage.test.getTime() === 946684800000// RegExpstorage.test = /d(b+)d/gstorage.test.test('cdbbdbsbz')// functionstorage.test = function () { return 'hello stokado!'}storage.test() === 'hello stokado!'```#### 3. Subscribe监听储值的变化```jsstorage.on(key, callback)storage.once(key, callback)storage.off([[key], callback])```#### 4. Expired为指定项设置过期时间```jsstorage.setExpires(key, expires)storage.getExpires(key)storage.removeExpires(key)```#### 5. Disposable一次性取值,可用于借助 storage` 进行通信jsstorage.setDisposable(key)

Latest Weekly Picks

make.ink favicon
Weekly Pick

Your AI tattoo generator for pro-grade concepts

Leo Wade
sellfy.com favicon
Weekly Pick

A code-free online store builder to turn views into revenue. Sell digital products, subscriptions, and merch, without fees or hassle.

Maris
www.videotoblog.ai favicon
Weekly Pick

Convert videos into awesome blog posts.

Video To Blog
www.sellerpic.ai favicon
Weekly Pick

SellerPic is the all-in-one AI design platform for e-commerce

SellerPic
fastimage.ai favicon
Weekly Pick

Fast Image AI instantly transforms your photos into stunning styles like Ghibli, Sketch, and Pixar. Effortlessly control image elements and create amazing effects with just one click.

Fast AI Team
linkedinpro.daisy.so favicon
Weekly Pick

AI-powered tool that transforms casual photos into professional LinkedIn headshots instantly. No photographer needed—just upload and download.

Gabriel
crevas.ai favicon
Weekly Pick

Crevas unifies Veo 3, Sora 2, Nano Banana and more into one intuitive canvas — so filmmakers can script, prompt, and generate cinematic stories without switching tools or losing consistency.

Spark Alpha
fotominiatur.com favicon
Weekly Pick

AI Foto Edit - Text to Image & Image Edit

foto miniatur