-
Notifications
You must be signed in to change notification settings - Fork 14
/
rhaboo.rocks.min.js
1 lines (1 loc) · 5.41 KB
/
rhaboo.rocks.min.js
1
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){var d=a("./core"),e=e||{pop:Array.prototype.pop,push:Array.prototype.push,shift:Array.prototype.shift,unshift:Array.prototype.unshift,splice:Array.prototype.splice,reverse:Array.prototype.reverse,sort:Array.prototype.sort,fill:Array.prototype.fill};Array.prototype.sort=function(){var a=e.sort.apply(this,arguments);return this._rhaboo&&this.save(),a},Array.prototype.reverse=function(){var a=e.reverse.apply(this,arguments);return this._rhaboo&&this.save(),a},Array.prototype.pop=function(){var a=e.pop.apply(this,arguments);return this._rhaboo&&("object"===d.typeOf(a)&&d.release(a),this.save()),a},Array.prototype.shift=function(){var a=e.shift.apply(this,arguments);return this._rhaboo&&("object"===d.typeOf(a)&&d.release(a),this.save()),a},Array.prototype.push=function(){if(this._rhaboo)for(var a=0;a<arguments.length;a++)"object"===d.typeOf(arguments[a])&&d.addRef(arguments[a],this._rhaboo.storage);var b=e.push.apply(this,arguments);return this._rhaboo&&this.save(),b},Array.prototype.unshift=function(){if(this._rhaboo)for(var a=0;a<arguments.length;a++)"object"===d.typeOf(arguments[a])&&d.addRef(arguments[a],this._rhaboo.storage);var b=e.unshift.apply(this,arguments);return this._rhaboo&&this.save(),b},Array.prototype.splice=function(){var a;if(this._rhaboo)for(a=2;a<arguments.length;a++)"object"===d.typeOf(arguments[a])&&d.addRef(arguments[a],this._rhaboo.storage);var b=e.splice.apply(this,arguments);if(this._rhaboo){for(a=0;a<b.length;a++)"object"===d.typeOf(b[a])&&d.release(b[a]);this.save()}return b},Array.prototype.fill=function(){var a=void 0===arguments[1]?0:arguments[1]<0?Math.max(this.length+arguments[1]):Math.min(this.length,arguments[1]),b=void 0===arguments[2]?this.length:arguments[2]<0?Math.max(this.length+arguments[2]):Math.min(this.length,arguments[2]);for("object"===d.typeOf(arguments[0])&&b>a&&(d.addRef(arguments[0],this._rhaboo.storage),arguments[0]._rhaboo.refs+=b-a-1);b>a;a++)this._rhaboo&&"object"===d.typeOf(this[a])&&d.release(this[a]),this[k]=arguments[0];return this._rhaboo&&this.save(),this},b.exports={persistent:d.persistent,perishable:d.perishable,construct:d.construct,algorithm:"rocks"}},{"./core":2}],2:[function(a,b,c){"use strict";function d(a){return null===a?"null":typeof a}function e(a){return g(localStorage,a)}function f(a){return g(sessionStorage,a)}function g(a,b){var c=h(q+b,a);return r={},c}function h(a,b,c){if(r[a])return r[a]._rhaboo.refs++,r[a];var d=b[a];if(d){var e=d.substring(0,1);if("^"===e)f=new Date(d.substring(1)),r[a]=f,f._rhaboo={storage:b,refs:1,slot:a};else{var f=JSON.parse(d);r[a]=f,f._rhaboo={storage:b,refs:1,slot:a};var g=JSON.parse(b["-"+a]);for(var i in g)f[i]=h(g[i],b)}return f}var f={_rhaboo:{storage:b,refs:1,slot:a}};return f.save(),r[a]=f,f}function i(a,b){if(void 0===a._rhaboo){a._rhaboo={storage:b,refs:1,slot:p(b)};for(var c in a)a.hasOwnProperty(c)&&"object"===d(a[c])&&"_rhaboo"!==c&&i(a[c],b);a.save()}else a._rhaboo.refs++}function j(a){if(a._rhaboo.refs--,0===a._rhaboo.refs){delete a._rhaboo.storage[a._rhaboo.slot],delete a._rhaboo.storage["-"+a._rhaboo.slot];for(var b in a)a.hasOwnProperty(b)&&"object"===d(a[b])&&"_rhaboo"!==b&&j(a[b])}}function k(a,b,c){return"object"===d(a[b])&&j(a[b]),"object"===d(c)&&i(c,a._rhaboo.storage),a[b]=c,a.save(),a}function l(a,b){return"object"===d(a[b])&&j(a[b]),delete a[b],a.save(),a}function m(a,b){return function(b,c){var e=d(c);return"number"===e||"string"===e||"boolean"===e?c:""===b?c:"_rhaboo"===b?void 0:null===c?c:"object"===e?void(a[b]=c._rhaboo.slot):c}}function n(a){var b=Date.prototype.toJSON;delete Date.prototype.toJSON;var c={};return a._rhaboo.storage[a._rhaboo.slot]=JSON.stringify(a,m(c,a._rhaboo.storage)),a._rhaboo.storage["-"+a._rhaboo.slot]=JSON.stringify(c),Date.prototype.toJSON=b,a._rhaboo.slot}function o(a){return a._rhaboo.storage[a._rhaboo.slot]="^"+a.toString(),a._rhaboo.slot}function p(a){var b=a===localStorage?0:1,c=t[b];return t[b]++,a.setItem(s,t[b]),q+c}void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){var a=/function\s([^(]{1,})\(/,b=a.exec(this.toString());return b&&b.length>1?b[1].trim():""},set:function(a){}});var q="_rhaboo_",r={};Date.prototype.toJSON=function(){return this},Object.defineProperty(Object.prototype,"save",{value:function(){return n(this)}}),Object.defineProperty(Date.prototype,"save",{value:function(){return o(this)}}),Object.defineProperty(Object.prototype,"write",{value:function(a,b){return k(this,a,b)}}),Object.defineProperty(Object.prototype,"erase",{value:function(a){l(this,a)}});for(var s="_RHABOO_NEXT_SLOT",t=[0,0],u=0;2>u;u++)t[u]=localStorage.getItem(s)||0,t[u]=Number(t[u]);var v=Object.prototype.hasOwnProperty;Object.prototype.hasOwnProperty=function(a){return"_rhaboo"!=a&&v.call(this,a)},b.exports={persistent:e,perishable:f,construct:g,addRef:i,release:j,typeOf:d}},{}],3:[function(a,b,c){(function(b){b.Rhaboo=a("./arr")}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./arr":1}]},{},[3]);