associativearray
Version:
1 lines • 9.3 kB
JavaScript
var aa=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}return r.m=t,r.c=e,r.p="",r(0)}([function(t,e,r){function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}n(r(1)),n(r(18)),n(r(17))},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0});var i=r(2),s=r(6),a=r(17),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.stringify=function(t){void 0===t&&(t="");var e="";for(var r in this.names)e+=t+"["+this.names[r]+"] ",i.isObject(this.values[r])?a.isAssociativeArray(this.values[r])?e+="\n"+this.values[r].stringify(t+"__ "):e+=JSON.stringify(this.values[r])+"\n":i.isArray(this.values[r])?e+=JSON.stringify(this.values[r])+"\n":i.isString(this.values[r])?e+='"'+this.values[r]+'"\n':e+=this.values[r]+"\n";return e},e.prototype.object=function(){var t={};for(var e in this.names)t[this.names[e]]=this.values[e];return t},e.prototype.fromObject=function(t){for(var e in t)this.add(e,t[e])},e.prototype.exportArray=function(){var t=[];for(var e in this.names){if(a.isAssociativeArray(this.values[e]))var r=this.values[e].exportArray(),n="AssociativeArray";else r=this.values[e],n="Object";t.push({name:this.names[e],value:r,type:n})}return t},e.prototype.importArray=function(t){for(var r=0,n=t;r<n.length;r++){var o=n[r];if(!i.exist(o.name)||!i.exist(o.value)||!i.exist(o.type))throw"Invalid Array";if("AssociativeArray"===o.type){var s=new e;s.importArray(o.value),this.add(o.name,s)}else this.add(o.name,o.value)}},e}(s.Pattern);e.AssociativeArray=u},function(t,e,r){function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}n(r(3)),n(r(4)),n(r(5))},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNumber=function(t){return"[object Number]"===Object.prototype.toString.call(t)},e.isString=function(t){return"[object String]"===Object.prototype.toString.call(t)},e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isFunction=function(t){return"[object Function]"===Object.prototype.toString.call(t)},e.isBoolean=function(t){return"[object Boolean]"===Object.prototype.toString.call(t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3);e.exist=function(t){return!(void 0===t||null===t||n.isNumber(t)&&isNaN(t))}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(4);e.or=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,o=t;r<o.length;r++){var i=o[r];if(n.exist(i))return i}return null}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),o=r(7),i=function(){function t(){this.length=0,this.names=[],this.values=[],this.id=0,this.keys={}}return t.prototype.updateKeys=function(){var t={};for(var e in this.names)t[this.names[e]]=e;this.keys=t},t.prototype.add=function(t,e){n.exist(this.keys[t])?this.change(t,e):(this.names.push(t),this.values.push(e),this.length=this.names.length,this.keys[t]=this.length-1)},t.prototype.value=function(t){return this.values[this.keys[t]]},t.prototype.push=function(t){var e="id"+o.randstr(5)+this.id++;return this.add(e,t),e},t.prototype.change=function(t,e){n.exist(this.keys[t])&&(this.values[this.keys[t]]=e)},t.prototype.remove=function(t){n.exist(this.keys[t])&&(1===this.length?(this.names=[],this.values=[]):(this.names.splice(this.keys[t],1),this.values.splice(this.keys[t],1)),this.length=this.names.length,delete this.keys[t])},t.prototype.search=function(t){var e=this.values.indexOf(t);if(-1!==e)return this.names[e]},t.prototype.forEach=function(t){for(var e in this.names){if("break"===t(this.values[e],this.names[e]))break}},t.prototype.toString=function(){var t="";for(var e in this.names)t+="["+this.names[e]+"] "+this.values[e]+"\n";return t},t.prototype.rename=function(t,e){this.add(e,this.value(t)),this.remove(t)},t.prototype.reverse=function(){this.values.reverse(),this.names.reverse()},t.prototype.copy=function(t){this.values=t.values.slice(),this.names=t.names.slice(),this.length=t.length,this.id=Math.max(this.id,t.id),this.updateKeys()},t.prototype.share=function(t,e){for(var r=0,n=e;r<n.length;r++){var o=n[r];t.add(o,this.values[this.keys[o]])}t.id=Math.max(t.id,this.id)},t.prototype.array=function(){var t=[];for(var e in this.names)t.push({name:this.names[e],value:this.values[e]});return t},t.prototype.fromArray=function(t){for(var e=0,r=t;e<r.length;e++){var n=r[e];this.push(n)}},t.prototype.sort=function(t){var e=this.array();for(var r in e.sort(t),e)this.names[r]=e[r].name,this.values[r]=e[r].value;this.updateKeys()},t.prototype.shuffle=function(){for(var t,e=this.array(),r=e.length;r;r--){var n=Math.floor(Math.random()*r);t=[e[n],e[r-1]],e[r-1]=t[0],e[n]=t[1]}for(var r in e)this.names[r]=e[r].name,this.values[r]=e[r].value;this.updateKeys()},t.prototype.concat=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,n=t;r<n.length;r++){var o=n[r];this.names=this.names.concat(o.names),this.values=this.values.concat(o.values),this.id=Math.max(this.id,o.id)}this.length=this.names.length,this.updateKeys()},t}();e.Pattern=i},function(t,e,r){function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}n(r(8)),n(r(9)),n(r(11)),n(r(12)),n(r(16)),n(r(15)),n(r(14)),n(r(13))},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.rand=function(t,e){var r,n;return(r=e-t)<0?-1:(n=Math.random()*r,n=Math.round(n),n+=t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(10);e.randcolor=function(){return"#"+n.generateRandSymbols(16,6)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(8);e.generateRandSymbols=function(t,e){t<2&&(t=2),t>36&&(t=36);for(var r="",o=0;o<e;o++)r+=n.rand(0,t-1).toString(t);return r}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(10);e.randstr=function(t){return n.generateRandSymbols(36,t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(13),o=r(14);e.randstr64=function(t){return o.randCustomString(n.dict64,t)}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];e.alphabet=r;var n=["0","1","2","3","4","5","6","7","8","9"];e.numerals=n;e.dict16=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];var o=[];e.Alphabet=o;for(var i=0,s=r;i<s.length;i++){var a=s[i];o.push(a.toUpperCase())}var u=r.concat(n);e.dict36=u;var c=u.concat(["-","_"]).concat(o);e.dict64=c},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(15);e.randCustomString=function(t,e){for(var r="",o=0;o<e;o++)r+=n.randvalue(t);return r}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(8);e.randvalue=function(t){return t[n.rand(0,t.length-1)]}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(13),o=r(14);e.randtext=function(t){return o.randCustomString(n.alphabet,t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),o=r(1),i=r(18);e.isAssociativeArray=function(t){return!!n.exist(t)&&t instanceof o.AssociativeArray},e.isDictionary=function(t){return!!n.exist(t)&&t instanceof i.Dictionary}},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.add=function(e,r){t.prototype.add.call(this,e,r)},e.prototype.value=function(t){return this.values[this.keys[t]]},e.prototype.push=function(e){return t.prototype.push.call(this,e)},e.prototype.change=function(e,r){t.prototype.change.call(this,e,r)},e.prototype.search=function(e){return t.prototype.search.call(this,e)},e.prototype.copy=function(e){t.prototype.copy.call(this,e)},e.prototype.share=function(e,r){t.prototype.share.call(this,e,r)},e.prototype.concat=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];t.prototype.concat.apply(this,e)},e.prototype.array=function(){var t=[];for(var e in this.names)t.push({name:this.names[e],value:this.values[e]});return t},e.prototype.fromArray=function(e){t.prototype.fromArray.call(this,e)},e.prototype.forEach=function(e){t.prototype.forEach.call(this,e)},e.prototype.sort=function(e){t.prototype.sort.call(this,e)},e}(r(6).Pattern);e.Dictionary=i}]);