-
Notifications
You must be signed in to change notification settings - Fork 21
/
kizzy.min.js
7 lines (7 loc) · 2.02 KB
/
kizzy.min.js
1
2
3
4
5
6
7
/*!
* Kizzy - a cross-browser LocalStorage API
* Copyright: Dustin Diaz 2012
* https://github.com/ded/kizzy
* License: MIT
*/
!function(a,b){typeof module!="undefined"?module.exports=b():typeof define=="function"&&typeof define.amd=="object"?define(b):this[a]=b()}("kizzy",function(){function a(){}function p(){return+(new Date)}function q(a,b){a._[b]&&a._[b].e&&a._[b].e<p()&&a.remove(b)}function r(a){return typeof a=="number"&&isFinite(a)}function s(a){return localStorage[a]}function t(a,b){return localStorage[a]=b,b}function u(a){delete localStorage[a]}function v(){localStorage.clear()}function w(a){var b=j.childNodes,c,d=null;for(var e=0,f=b.length;e<f;e++){c=b.item(e);if(c.getAttribute("key")==a){d=c;break}}return d}function x(a){var b=w(a),c=null;return b&&(c=b.getAttribute("value")),c}function y(a,b){var c=w(a);return c?c.setAttribute("value",b):(c=i.createNode(1,"item",""),c.setAttribute("key",a),c.setAttribute("value",b),j.appendChild(c)),h.save(d),b}function z(a){w(a)&&j.removeChild(node),h.save(d)}function A(){while(j.firstChild)j.removeChild(j.firstChild);h.save(d)}function B(){this._={}}function C(a){this.ns=a,this._=JSON.parse(m(a)||"{}")}function D(a){return new C(a)}var b,c=document,d=c.domain,e=0,f=function(){return 1};try{b=!!localStorage||!!globalStorage,localStorage||(localStorage=globalStorage[d]),e=1}catch(g){e=0;try{if(c.documentElement.addBehavior){e=0,b=1;var h=c.documentElement;h.addBehavior("#default#userData"),h.load(d);var i=h.xmlDocument,j=i.documentElement}}catch(k){b=!1}}var l=a,m=a,n=a,o=a;return b&&(l=e?t:y,m=e?s:x,n=e?u:z,o=e?v:A,f=function(a){try{var b=JSON.stringify(a._);return b=="{}"?n(a.ns):l(a.ns,b),1}catch(c){return 0}}),B.prototype={set:function(a,b,c){return this._[a]={value:b,e:r(c)?p()+c:0},f(this)||this.remove(a),b},get:function(a){return q(this,a),this._[a]?this._[a].value:undefined},remove:function(a){delete this._[a],f(this)},clear:function(){this._={},f(this)},clearExpireds:function(){for(var a in this._)q(this,a);f(this)}},C.prototype=B.prototype,D.remove=n,D.clear=o,D})