UNPKG

unissist

Version:

A persistance library for unistore

3 lines (2 loc) 941 B
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.unissist=e()}(this,function(){return function(n,e){var t;function r(r,o){return(t||(t=new Promise(function(t,r){var o=indexedDB.open(n,e||1);o.onerror=function(){r(o.error)},o.onupgradeneeded=function(){o.result.createObjectStore(n)},o.onsuccess=function(){t(o.result)}})),t).then(function(e){return new Promise(function(t,u){var c=e.transaction(n,r);c.oncomplete=function(){t()},c.onerror=function(){u(c.error)},o(c.objectStore(n))})})}function o(n){}return n=n||"unistorePersist",{getState:function(){var e;return r("readonly",function(t){e=t.get(n)}).then(function(){return e.result}).catch(o)},setState:function(e){return r("readwrite",function(t){t.put(e,n)}).catch(o)},clearState:function(){return r("readwrite",function(n){n.clear()}).catch(o)}}}}); //# sourceMappingURL=indexdbAdapter.umd.js.map