美文网首页
StorageFormat,格式化Storage使用方式,简化复

StorageFormat,格式化Storage使用方式,简化复

作者: Armin0202 | 来源:发表于2017-03-08 12:02 被阅读4次

    github: https://github.com/harrydengchao/StorageFormat

    Explain

    • [x] storage: Format the settings and get the plugins for Storage

    Storage

    • This is mainly for the convenience of their own use, but also inspired by mongodb.
    • Greatly simplifies the operation of the Web for data caching
    npm install --save storage-format
    

    Use

    // import storage-format
    import Storage from 'storage-format'
    
    /**
     * There are two APIs that use the method exactly the same
     * Storage.Local <= window.localStorage
     * Storage.Session <= window.sessionStorage
     */
    
    // save data
    Storage.Local.set('name', 'Jack');  // => { "name": "Jack" }
    
    // save data
    Storage.Local.set('user.info.age', 26);  // => { "user": { "info": { "age": 26 } } }
    
    // get data
    Storage.Local.get('name');  // => Jack
    Storage.Local.get('user.info.age'); // => 26
    
    // remove data
    Storage.Local.remove('name');
    Storage.Local.remove('user.info.age');
    
    

    相关文章

      网友评论

          本文标题:StorageFormat,格式化Storage使用方式,简化复

          本文链接:https://www.haomeiwen.com/subject/jwrbgttx.html