-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.min.js
1 lines (1 loc) · 2.42 KB
/
index.min.js
1
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return b()}):"undefined"!=typeof exports?exports=module.exports=b():b()}(this,function(){var a={};return a.ucfirst=function(a){return a.substr(0,1).toUpperCase()+a.substr(1)},a.getType=function(a){return Object.prototype.toString.call(a).match(/^\[object\s+(\w+)\]$/)[1].toLowerCase()},a.toArraySliced=function(b,c,d){return c=c||0,a.isA("undefined",d)?Array.prototype.slice.call(b,c):Array.prototype.slice.call(b,c,d)},a.isA=function(b,c){return a.getType(c)===b},a.shallowCopy=function(b){var c={};switch(a.getType(b)){case"array":return a.toArraySliced(b);case"object":for(var d in b)a.isA("array",b[d])||a.isA("object",b[d])?c[d]=a.shallowCopy(b[d]):c[d]=b[d];break;default:throw new Exception("Wrong Type.")}return c},a.forEach=function(a,b,c){if(null===a)throw new Error("no object to iterate on !");"undefined"==typeof c&&(c=this);for(var d in a)({}).hasOwnProperty.call(a,d)&&b.call(c,a[d],d,a);return a},a.merge=function(b,c){var d=a.shallowCopy(b);if(a.isA("undefined",c))return d;for(var e=a.toArraySliced(arguments,1),f=0;f<e.length;f++){var g=e[f];for(var h in d)if(d.hasOwnProperty(h)&&!a.isA("function",d[h])&&a.getType(d[h])===a.getType(g[h]))switch(a.getType(d[h])){case"object":d[h]=a.merge(d[h],g[h]);break;default:d[h]=g[h]}}return d},a.deepAccess=function(b,c){if(a.isA("undefined",b))throw new Error("no object to navigate inside !");return a.isA("string",c)&&(c=c.replace(/\[/g,".").replace(/\]/g,"").split(".")),1===c.length?b[c.shift()]:a.deepAccess(b[c.shift()],c)},a.inherit=function(a,b){for(var c in b)({}).hasOwnProperty.call(b,c)&&(a[c]=b[c]);var d=function(){this.constructor=a};return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a},a.x=function(b,c,d){if(a.isA("undefined",b))throw new Error("classname is missing !");a.toArraySliced(arguments,1);a.isA("undefined",d)&&(d=function(){});var e=this[b]=c||a.x.minimalConstructor();return function(c){return function(d){a.inherit(e,d);for(var f in c)c.hasOwnProperty(f)&&(e.prototype[f]=c[f]);e.prototype.__type__=b;var g=function(b){return!a.isA("undefined",e.__super__)&&a.isA("undefined",e.__super__[b])?e.__super__[b]:void 0};for(var h in d)d.hasOwnProperty(h)&&(e.prototype[h]=g(h));return e}(d)}},a.x.minimalConstructor=function(){return function(b){return this.defaultOptions?this.options=a.merge(this.defaultOptions,b):this.options=b,this.init&&this.init(),this.listen&&this.listen(),this}},a});