storages-utils
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.2 • Public • Published

    使用方式

    支持sessionStoragelocalStorage, 默认是sessionStorage,如果要使用localStorage,需要这样new storageUtil('localstorage');

    const session = new storageUtil();
    // 设置
    session.setItem('xxx', 'xxx');
    // 获取
    session.getItem('xxx');
    // 删除
    session.removeItem('xxx');
    
    // 对象类型的设置 支持 覆盖和追加的方式
    // 覆盖
    session.setItem('xxx', { name: 'zhangshan'}, true);
    session.getItem('xxx');
    // 输出
    {
      name: 'zhangshan'
    }
    
    // 追加
    session.setItem('xxx', { age: 18 }, false);
    session.getItem('xxx');
    // 输出
    {
      name: 'zhangshan',
      age: 18,
    }
    
    // 删除对象属性
    session.removeItem('xxx', name);
    // 输出
    {
      age: 18,
    }

    Install

    npm i storages-utils

    DownloadsWeekly Downloads

    0

    Version

    0.0.2

    License

    ISC

    Unpacked Size

    9.99 kB

    Total Files

    7

    Last publish

    Collaborators

    • yangtao00