jellyfin-web/dashboard-ui/bower_components/emby-apiclient/appstorage-localstorage.js
Luke Pulverenti 8a6884abef minify
2017-01-27 18:07:14 -05:00

1 line
684 B
JavaScript

define([],function(){"use strict";function updateCache(){cache&&cache.put("data",new Response(JSON.stringify(localData)))}var cache,localData,myStore={};myStore.setItem=function(name,value){if(localStorage.setItem(name,value),localData){var changed=localData[name]!==value;changed&&(localData[name]=value,updateCache())}},myStore.getItem=function(name){return localStorage.getItem(name)},myStore.removeItem=function(name){localStorage.removeItem(name),localData&&(localData[name]=null,delete localData[name],updateCache())};try{self.caches&&caches.open("embydata").then(function(result){cache=result,localData={}})}catch(err){console.log("Error opening cache: "+err)}return myStore});