goose-localstorage

    1.0.1 • Public • Published

    Goose localStorage

    Fix your local storage without headaches.

    Usage

    • es6
    var migrations = [
      storage => {
        var langs = ["en_US", "pt_BR", "de"];
        var default_lang = "en_US";
     
        if (storage.lang in langs)
          return storage;
     
        return {
          ...storage,
          lang: default_lang
        };
      }
    ];
     
    var goose = new Goose(localStorage, migrations);
    goose.migrate();
    localStorage = goose.storage();
    • old school
    var migrations = [
      function(storage) {
        var langs = ["en_US", "pt_BR", "de"];
        var default_lang = "en_US";
     
        if (langs.indexOf(storage.lang) != -1)
          return storage;
     
        return Object.assign(storage, {
          lang: default_lang
        }, {});
      }
    ];
     
    var goose = new Goose(localStorage, migrations);
    goose.migrate();
    localStorage = goose.storage();

    Installation

    npm install goose-localstorage --save
    

    Development

    git clone git@github.com:StefanYohansson/goose-localstorage.git
    npm install
    npm test
    

    Install

    npm i goose-localstorage

    DownloadsWeekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • stefanyohansson