@ctrlc/storage
TypeScript icon, indicating that this package has built-in type declarations

1.2.6 • Public • Published

@ctrlc/storage

网页Storage封装,支持localStoragesessionStoragecookie 、内存四种存储对象,支持nullundefinedbooleanobjectnumberstringdatemapsetobject多种格式。

Usage

import Storage from "@ctrlc/storage";

const storage = new Storage({ 
 namespace: 'app',
 version: '1.0.0'
});

// set
storage.setItem('test', 'test');
storage.setItem('test', 'test', {
 type: 'local', 
 namespace: 'app'
});

storage.setCookie('test', 'test');

// get
storage.getItem('test');
storage.getItem('test', {
 type: 'local', 
 namespace: 'app'
});

storage.getCookie('test');

// remove
storage.removeItem('test');
storage.removeItem('test', {
 type: 'local', 
 namespace: 'app'
});

storage.removeCookie('test');

// clear
storage.clear();
storage.clear({
 type: 'local'
});

storage.clearCookie();

文档

Dependencies (0)

    Dev Dependencies (20)

    Package Sidebar

    Install

    npm i @ctrlc/storage

    Weekly Downloads

    1

    Version

    1.2.6

    License

    MIT

    Unpacked Size

    12.4 kB

    Total Files

    9

    Last publish

    Collaborators

    • yangzhuqing