New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clazz-js

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clazz-js - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

docs/3.properties.md

2

bower.json
{
"name": "ClazzJS",
"version": "0.3.2",
"version": "0.3.3",
"ignore": [

@@ -5,0 +5,0 @@ "node_modules",

@@ -1,2 +0,2 @@

!function(a,b,c,d){if("function"==typeof define&&define.amd)define(b,c,d);else if("object"==typeof exports&&exports){for(var e=0,f=c.length;f>e;++e){var g=c[e];"string"==typeof g&&(g=g.replace(/([A-Z]+)/g,function(a){return"-"+a.toLowerCase()}).replace(/^-/,""),c[e]=require(g))}var h=d.apply(a,c);for(var i in h)exports[i]=h[i]}else{for(var e=0,f=c.length;f>e;++e){var g=c[e];if("string"==typeof g){if(!(g in a))throw new Error('"'+b+'" dependent on non exited module "'+g+'"!');c[e]=a[g]}}a[b]=d.apply(a,c)}}(new Function("return this")(),"ClazzJS",[],function(a){var b=function(){var a={},b=Object.prototype.toString,c=Array.prototype.slice;a.isUndefined=function(a){return void 0===a},a.isObject=function(a){return a===Object(a)},a.isNull=function(a){return null===a};for(var d=["Function","String","Number","Date","RegExp","Array"],e=0,f=d.length;f>e;++e)!function(c){a["is"+c]=function(a){return b.call(a)==="[object "+c+"]"}}(d[e]);return a.toArray=function(a){return c.call(a)},a.extend=function(a){for(var b=c.call(arguments,1),d=0,e=b.length;e>d;++d){var f=b[d];if(f)for(var g in f)a[g]=f[g]}return a},a.last=function(a){return a[a.length-1]},a.construct=function(a,b){var c=function(){return a.apply(this,b)};return c.prototype=a.prototype,new c},a}(),c=function(){var a=function(c,d){var e=function(a){var c=e.getScope().getNamespace(e.adjustPath(a));return arguments.length>1&&c.space.apply(c,b.toArray(arguments).slice(1)),c};return b.extend(e,a.prototype),e._scope=c,e._path=d,e._spaces=[],e._objects={},e};b.extend(a.prototype,{getPath:function(){return this._path},getScope:function(){return this._scope},adjustPath:function(a){return this._scope.isAbsolutePath(a)?this._scope.adjustPath(a):this._scope.concatPaths(this.getPath(),a)},get:function(a){return a in this._objects||(this._objects[a]=this._scope.get(a).call(this)),this._objects[a]},has:function(a){return this._scope.has(a)},space:function(){var a=this,c=b.toArray(arguments).slice(0,-1),d=b.last(arguments),e=[];c.length||(c=this._scope.getDefaultInjects());for(var f=0,g=c.length;g>f;++f)e[f]=this.get(c[f]);return this._spaces.push(function(){d.apply(a,e)}),this},executeSpace:function(){return this._spaces.length?(this._spaces.pop()(),!0):!1}});var c=function(a){a=a||{},this._innerDelimiter=a.innerDelimiter||"/",this._delimiters=a.delimiters||["\\","/","."],this._defaultInjects=a.defaultInjects||[],this._namespaces={},this._factories={},this._search=[]};return b.extend(c.prototype,{getInnerDelimiter:function(){return this._innerDelimiter},setInnerDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not supported!');return this._innerDelimiter=a,this},getDelimiters:function(){return this._delimiters},addDelimiter:function(a){if(this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" is already exists!');return this},removeDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not exists!')},hasDelimiter:function(a){return-1!==this._delimiters.indexOf(a)},getNamespace:function(b){return b=this.adjustPath(b),b in this._namespaces||(this._namespaces[b]=a(this,b)),this._namespaces[b]},getRootNamespace:function(){return this.getNamespace(this.getRootPath())},getRootPath:function(){return this._innerDelimiter},adjustPath:function(a){var b=this.getInnerDelimiter(),c=this.getDelimiters();return a.replace(new RegExp("[\\"+c.join("\\")+"]","g"),b).replace(new RegExp(b+"+","g"),b).replace(new RegExp("(.+)"+b+"$"),function(a){return a})},isAbsolutePath:function(a){return 0===a.indexOf(this.getRootNamespace().getPath())},concatPaths:function(){return this.adjustPath(b.toArray(arguments).join(this.getInnerDelimiter()))},set:function(a,b){if(a in this._factories)throw new Error('Factory for object "'+a+'" is already exists!');return this._factories[a]=b,this},get:function(a){if(!(a in this._factories))throw new Error('Factory for object "'+a+'" does not exists!');return this._factories[a]},has:function(a){return a in this._factories},remove:function(a){return delete this._factories[a],this},getInSearchError:function(a){var b=new Error('Path "'+a+'" is in search state!');return b.inSearch=!0,b.path=a,b},isInSearchError:function(a){return a.inSearch},search:function(a,c){a=this.adjustPath(a);var d=c(a);if(!b.isUndefined(d))return d;for(var e=this.getInnerDelimiter(),f=a.split(e),g=f.pop();f.length;){var h=f.join(e);if(h in this._namespaces)for(var i=this._namespaces[h];i.executeSpace();)if(d=c(h+e+g),!b.isUndefined(d))return d;g=f.pop()}},getDefaultInjects:function(){return this._defaultInjects},addDefaultInject:function(a){if(-1!==this._defaultInjects.indexOf(a))throw new Error('Default inject "'+a+'" is already exists!');return this._defaultInjects.push(a),this},removeDefaultInject:function(a){var b=this._defaultInjects.indexOf(a);if(-1===b)throw new Error('Default inject "'+a+'" does not exists!');return this._defaultInjects.splice(b,1),this}}),{Namespace:a,Scope:c}}(),d=function(){var a=function(){this._processors={}};b.extend(a.prototype,{getProcessor:function(a){return this.checkProcessor(a),this._processors[a]},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,c){return b.isFunction(c)&&(c={process:c}),"__name"in c||(c.__name=a),this._processors[a]=c,this},removeProcessor:function(a){this.checkProcessor(a);var b=this._processors[a];return delete this._processors[a],b},getProcessors:function(){return this._processors},setProcessors:function(a){for(var b in a)this.setProcessor(b,a[b]);return this},checkProcessor:function(a){if(!this.hasProcessor(a))throw new Error('Meta processor "'+a+'" does not exists!')}});var c=function(a,d){var e=function(a,c){return b.isUndefined(c)?e.get(a):e.set(a,c)};return b.extend(e,c.prototype),e._manager=a,e._namespace=d,e};return b.extend(c.prototype,{getManager:function(){return this._manager},getNamespace:function(){return this._namespace},get:function(a){var b=this.getManager(),c=this.resolveProcessorName(a);if(!c)throw new Error('Meta processor "'+a+'" does not exist!');return b.getProcessor(c)},set:function(a,b){var c=this.getNamespace(),d=this.getManager();return d.setProcessor(c.adjustPath(a),b),this},resolveProcessorName:function(a){var b=this.getManager(),c=this.getNamespace();return c.getScope().search(c.adjustPath(a),function(a){return b.hasProcessor(a)?a:void 0})}}),{Meta:c,Manager:a}}(),e=function(){var c=function(a,d,e){var f=function(a,c,d){var e=b.last(arguments);return b.isFunction(e)&&!e.prototype.__clazz||"[object Object]"===Object.prototype.toString.call(e)?(f.set(a,c,d),void 0):f.get(a,c,d)};return b.extend(f,c.prototype),f._manager=a,f._factory=d,f._namespace=e,f};b.extend(c.prototype,{getManager:function(){return this._manager},getFactory:function(){return this._factory},getNamespace:function(){return this._namespace},has:function(a){return!!this.resolveName(a)},get:function(c,d,e){b.isUndefined(e)&&b.isArray(d)&&(e=d,d=a);var f=this.resolvePath(c);if(!f)throw new Error('Clazz "'+c+'" does not exists!');e=e||[];var g=this.getManager();if(!g.hasClazz(f,d,e)){var h=this.getFactory(),i=g.getClazzData(f);g.setClazz(f,h.create({name:i.name,parent:d,metaParent:i.parent,meta:i.meta,dependencies:e,clazz:i.clazz}),d,e)}return g.getClazz(f,d,e)},set:function(c,d,e){b.isUndefined(e)&&(e=d,d=a);var f=this.getNamespace(),g=this.getManager();return b.isUndefined(e)&&(e=d,d=null),c=f.adjustPath(c),b.isString(d)&&(d=f.adjustPath(d)),g.setClazzData(c,{name:c,parent:d,meta:e,clazz:this}),this},resolvePath:function(a){var b=this.getNamespace(),c=this.getManager();return b.getScope().search(b.adjustPath(a),function(a){return c.hasClazzData(a)?a:void 0})}});var d=function(a){a=a||{},this._clazzUID=0,this._metaProcessor=a.metaProcessor||null,this._baseClazz=a.baseClazz||null};b.extend(d.prototype,{CLAZZ_NAME:"Clazz{uid}",getBaseClazz:function(){return this._baseClazz},setBaseClazz:function(a){if(!b.isFunction(a))throw new Error("Base clazz must be a function!");return this._baseClazz=a,this},getMetaProcessor:function(){return this._metaProcessor},setMetaProcessor:function(a){if(!b.isFunction(a.process))throw new Error('Meta processor must have "process" method!');return this._metaProcessor=a,this},create:function(a){var c=a.name||this.generateName(),d=a.parent,e=a.metaParent,f=a.meta||{},g=a.dependencies||[],h=a.clazz,i=this.createClazz();return i.__name=c,i.__clazz=h,b.isFunction(f)&&(f=f.apply(i,[i].concat(g))||{}),!f.parent&&e&&(f.parent=e),d=d||f.parent,b.isString(d)&&(d=[d]),b.isArray(d)&&(d=h.get.apply(h,d)),this.applyParent(i,d),i.prototype.__clazz=i,i.prototype.__proto=i.prototype,this.applyMeta(i,f),i},createClazz:function(){return function a(){var c;return this instanceof a?(b.isFunction(this.__construct)?c=this.__construct.apply(this,b.toArray(arguments)):a.__parent&&(c=a.__parent.apply(this,b.toArray(arguments))),b.isUndefined(c)?void 0:c):b.construct(a,b.toArray(arguments))}},applyParent:function(c,d){if(d=d||this.getBaseClazz())for(var e in d)e in c||(b.isFunction(d[e])?c[e]=d[e]:"_"===e[0]&&(c[e]=a));return c.prototype=b.extend(Object.create(d?d.prototype:{}),c.prototype),c.__parent=d||null,c.prototype.constructor=c,c.prototype.__parent=d?d.prototype:null,c},applyMeta:function(a,b){return this.getMetaProcessor().process(a,b),a},generateName:function(){return this.CLAZZ_NAME.replace("{uid}",++this._clazzUID)}});var e=function(){this._clazz={},this._clazzData={}};return b.extend(e.prototype,{setClazzData:function(a,b){return this._clazzData[a]=b,this},hasClazzData:function(a){return a in this._clazzData},getClazzData:function(a){if(!this.hasClazzData(a))throw new Error('Data does not exists for clazz "'+a+'"!');return this._clazzData[a]},getClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return d[e][0]}throw new Error('Clazz "'+a+'" does not exists!')},hasClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return!0}return!1},setClazz:function(a,c,d,e){if(!b.isFunction(c))throw new Error("Clazz must be a function!");return a in this._clazz||(this._clazz[a]=[]),this._clazz[a].push([c,d,e||[]]),this}}),{Clazz:c,Factory:d,Manager:e}}(),f=new c.Scope({defaultInjects:["clazz","namespace"]}),g=f.getRootNamespace(),h=new d.Manager,i=new d.Meta(h,g),j=new e.Manager,k=new e.Factory,l=new e.Clazz(j,k,g);return f.set("namespace",function(){return this}),f.set("meta",function(){return new d.Meta(h,this)}),f.set("clazz",function(){return new e.Clazz(j,k,this)}),g("ClazzJS","clazz","meta","namespace",function(c,d,e){d("Base",{_objectTypes:{clazz:function(a){return a},proto:function(a){return a.prototype}},_processors:{clazz:{},proto:{}},_optionProcessors:{clazz:{constants:"Constants",clazz_properties:"Properties",clazz_methods:"Methods",clazz_events:"Events"},proto:{properties:"Properties",methods:"Methods",events:"Events"}},process:function(a,c){a.__isClazz||b.extend(a,this.clazz_interface);var e=c.parent;if(e&&!a.__isSubclazzOf(e))throw new Error('Clazz "'+a.__name+'" must be subclazz of "'+e.__isClazz?e.__name:e+'"!');for(var f in this._objectTypes){var g=this._objectTypes[f](a);g.__interfaces||(g.__interfaces=["common"],b.extend(g,this.common_interface))}for(var f in this._processors){var g=this._objectTypes[f](a),h=this._processors[f];for(var i in h){var j=h[i];b.isString(j)&&(j=d(j)),j.interface&&!g.__isInterfaceImplemented(j.__name)&&g.__implementInterface(j.__name,j.interface),j.process(g,c)}}for(var f in this._optionProcessors){var g=this._objectTypes[f](a),h=this._optionProcessors[f];for(var k in h){var j=h[k];b.isString(j)&&(j=d(j)),j.interface&&!g.__isInterfaceImplemented(j.__name)&&g.__implementInterface(j.__name,j.interface),j.process(g,c[k]||{},k)}}},addObjectType:function(a,b){return a in this._processors||(this._processors[a]=[]),a in this._optionProcessors||(this._optionProcessors[a]={}),this._objectTypes[a]=b,this},removeObjectType:function(a){return a in this._processors&&delete this._processors,a in this._optionProcessors&&delete this._optionProcessors[a],delete this._objectTypes[a],this},hasProcessor:function(a,b){return b in this._processors[a]},addProcessor:function(a,b){if(b.__name in this._processors[a])throw new Error('Processor "'+b.__name+'" is already exists for object type "'+a+'"!');return this._processors[a][b.__name]=b,this},removeProcessor:function(a,b){if(!(b in this._processors[a]))throw new Error('Processor "'+b+'" does not exists for object type "'+a+'"!');return delete this._processors[a][b],this},hasOptionProcessor:function(a,b){return b in this._optionProcessors[a][b]},addOptionProcessor:function(a,b,c){return this._optionProcessors[a][b]=c,this},removeOptionProcessor:function(a,b){return delete this._optionProcessors[a][b],this},clazz_interface:{__isClazz:!0,__isSubclazzOf:function(a){for(var b=this;b;){if(b===a||b.__name===a)return!0;b=b.__parent}return!1}},common_interface:{__isInterfaceImplemented:function(a){return-1!==this.__interfaces.indexOf(a)},__implementInterface:function(a,c){if(-1!==this.__interfaces.indexOf(a))throw new Error('Interface "'+a+'" is already implemented!');return this.__interfaces.push(a),b.extend(this,c),this},__collectAllPropertyValues:function(a,c){function d(a,b,c,e){e=[].concat(e);for(var f in b)e[0]&&f!==e[0]||(c>1&&"[object Object]"===Object.prototype.toString.call(b[f])?(f in a||(a[f]={}),d(a[f],b[f],c-1,e.slice(1))):f in a||(a[f]=b[f]))}var e=[];this.hasOwnProperty(a)&&e.push(this[a]),this.__proto&&this.__proto.hasOwnProperty(a)&&e.push(this.__proto[a]);for(var f=this.__parent;f;)f.hasOwnProperty(a)&&e.push(f[a]),f=f.__parent;for(var g=b.toArray(arguments).slice(2),h={},i=0,j=e.length;j>i;++i)d(h,e[i],c||1,g);return h}}}),d("Constants",{process:function(a,b){a.__constants={};for(var c in b)a.__constants[c]=b[c]},"interface":{__initConstants:function(){this.__constants={}},__getConstants:function(){return this.__collectAllPropertyValues("__constants",99)},__getConstant:function(){for(var a=b.toArray(arguments),c=this.__collectAllPropertyValues.apply(this,["__constants",99].concat(a)),d=0,e=a.length;e>d;++d){if(!(a[d]in c))throw new Error('Constant "'+a.splice(0,d).join(".")+'" does not exists!');c=a[d]}return c},__executeConstant:function(a,c){var d=this;if(b.isUndefined(c)&&(c=d.__getConstants()),!b.isUndefined(a)){if(!(a in c))throw new Error('Constant "'+a+'" does not defined!');if(c=c[a],"[object Object]"===Object.prototype.toString.call(c))return function(a){return d.__executeConstant(a,c)}}return c}}}),d("Events",{process:function(a,b){a.__events={};for(var c in b)for(var d in b[c])a.__addEventListener(c,d,b[c][d])},"interface":{__initEventsCallbacks:function(){this.__events={}},__emitEvent:function(a){var c=this.__getEventListeners(a);for(var d in c)c[d].apply(this,b.toArray(arguments).slice(1));return this},__addEventListener:function(a,b,c){if(this.__hasEventListener(a,b))throw new Error('Event listener for event "'+a+'" with name "'+b+'" is already exists!');return a in this.__events||(this.__events[a]={}),this.__events[a][b]=c,this},__removeEventListener:function(b,c){if(!this.hasEventCallback(b,c))throw new Error('There is no "'+b+(c?'"::"'+c:"")+'" event callback!');return this.__events[b][c]=a,this},__hasEventListener:function(a,b){return b in this.__getEventListeners(a)},__getEventListener:function(a,b){var c=this.__getEventListeners(a);if(!(b in c))throw new Error('Event listener for event "'+a+'" with name "'+b+'" does not exists!');return c[a][b]},__getEventListeners:function(a){return this.__collectAllPropertyValues.apply(this,["__events",2].concat(a||[]))}}}),d("Methods",{process:function(a,c){for(var d in c){if(!b.isFunction(c[d]))throw new Error('Method "'+d+'" must be a function!');a[d]=c[d]}}}),d("Properties",{_propertyMetaProcessor:"Property",process:function(a,b){a.__properties={},a.__setters={},a.__getters={};var c=this.getPropertyMetaProcessor();for(var d in b)c.process(a,b[d],d)},getPropertyMetaProcessor:function(){return b.isString(this._propertyMetaProcessor)&&(this._propertyMetaProcessor=d(this._propertyMetaProcessor)),this._propertyMetaProcessor},setPropertyMetaProcessor:function(a){return this._propertyMetaProcessor=a,this},"interface":{__initProperties:function(){this.__properties={},this.__setters={},this.__getters={};var a=this.__getPropertiesParam();for(var c in a)if("default"in a[c]){var d=a[c].default;b.isFunction(d)&&(d=d.ca),this["_"+c]=a[c]["default"]}},__setPropertiesParam:function(a){for(var b in a)this.__setPropertyParam(b,a[b]);return this},__getPropertiesParam:function(){return this.__collectAllPropertyValues("__properties",2)},__setPropertyParam:function(a,c,d){var e={};return b.isUndefined(d)?b.isObject(c)&&b.extend(e,c):e[c]=d,a=this.__adjustPropertyName(a),a in this.__properties||(this.__properties[a]={}),b.extend(this.__properties[a],e),this},__getPropertyParam:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__properties",2,a].concat(b||[]));return b?c[b]:c},__hasProperty:function(a){return a=this.__adjustPropertyName(a),"_"+a in this},__adjustPropertyName:function(a){return a.replace(/(?:_)\w/,function(a){return a[1].toUpperCase()})},__getPropertyValue:function(a){a=this.__adjustPropertyName(a);var c=b.toArray(arguments).slice(1);if(!("_"+a in this))throw new Error('Property "'+a+'" does not exists!');var d=this["_"+a],e=this.__getGetters(a);for(var f in e)d=e[f].call(this,d);for(var g=0,h=c.length;h>g;++g){if(!c[g]in d)throw new Error('Property "'+[a].concat(c.slice(0,g)).join(".")+'" does not exists!');d=d[c[g]]}return d},__hasPropertyValue:function(a){a=this.__adjustPropertyName(a);for(var c=b.toArray(arguments).slice(1),d=this.__getPropertyValue(a),e=0,f=c.length;f>e;++e)if(!(c[e]in d))return!1;return!b.isUndefined(d)&&!b.isNull(d)},__isPropertyValue:function(c){var d=b.toArray(arguments).slice(1,-1),e=arguments.length>1?b.last(arguments):a,f=this.__getPropertyValue.apply(this,[c].concat(d));return b.isUndefined(e)?!!f:f===e},__clearPropertyValue:function(c){c=this.__adjustPropertyName(c);var d=b.toArray(arguments).slice(1),e=d.length?this.__getPropertyValue.apply(this,[c].concat(d.slice(0,-1))):this,f=d.length?b.last(d):"_"+c;if(!(f in e))throw new Error('Property "'+[c].concat(d)+'" does not exists!');var g=e[f],h=a;if(g.constructor==={}.constructor?h={}:b.isArray(g)&&(h=[]),e[f]=h,b.isFunction(this.__emitEvent)){if(g.constructor==={}.constructor)for(var i in g)this.__emitEvent("property."+[c].concat(d).join(".")+".item_removed",i,g[i]),this.__emitEvent("property."+[c].concat(d,i).join(".")+".removed",g[i]);else if(b.isArray(g))for(var j=0,k=g.length;k>j;++j)this.__emitEvent("property."+[c].concat(d).join(".")+".item_removed",j,g[j]),this.__emitEvent("property."+[c].concat(d,j).join(".")+".removed",g[j]);this.__emitEvent("property.cleared",d.length?[c].concat(d):c,g),this.__emitEvent("property."+[c].concat(d).join(".")+".cleared",g)}return this},__removePropertyValue:function(a){a=this.__adjustPropertyName(a);var c=b.toArray(arguments).slice(1),d=c.length?this.__getPropertyValue.apply(this,[a].concat(c.slice(0,-1))):this,e=c.length?b.last(c):"_"+a;if(!(e in d))throw new Error('Property "'+[a].concat(c)+'" does not exists!');var f=d[e];return delete d[e],b.isFunction(this.__emitEvent)&&(this.__emitEvent("property.removed",c.length?[a].concat(c):a,f),this.__emitEvent("property."+[a].concat(c).join(".")+".removed",f)),this},__setPropertyValue:function(a){if(a=this.__adjustPropertyName(a),!this.__hasProperty(a))throw new Error('Property "'+a+'" does not exists!');var c=b.toArray(arguments).slice(1,-1),d=b.last(arguments),e;if(c.length){var f=this;c.unshift("_"+a);for(var g=c.pop(),h=0,i=c.length;i>h;++h)b.isUndefined(f[c[h]])&&(f[c[h]]={}),f=f[c[h]];e=f[g],f[g]=d}else{var j=this.__getSetters(a);for(var k in j)d=j[k].call(this,d);e=this["_"+a],this["_"+a]=d}return b.isFunction(this.__emitEvent)&&(a=[a].concat(c).join("."),this.__emitEvent("property.changed",a,d,e),this.__emitEvent("property."+a+".changed",d,e)),this},__addSetter:function(a,c,d){if(!b.isFunction(d))throw new Error("Setter callback must be a function!");return a in this.__setters||(this.__setters[a]={}),this.__setters[a][c]=d,this},__getSetters:function(a){var b=this.__collectAllPropertyValues.apply(this,["__setters",1].concat(a||[]));return a?b[a]||{}:b},__addGetter:function(a,c){if(!b.isFunction(c))throw new Error("Getter callback must be a function!");return a in this.__getters||(this.__getters[a]=[]),this.__getters[a].push([weight,c]),this},__getGetters:function(a){var b=this.__collectAllPropertyValues.apply(this,["__getters",1].concat(a||[]));return a?b[a]||{}:b},__setData:function(a){for(var b in a)this.__hasProperty(b)&&this.__setPropertyValue(b,a[b]);return this},__getData:function(){var a={},c=this.__getPropertiesMeta();for(var d in c){var e=this.__getPropertyValue(d);if(b.isArray(e))for(var f=0,g=e.length;g>f;++f)b.isFunction(e[f].__getData)&&(e[f]=e[f].__getData());else if(e.constructor==={}.constructor)for(var h in e)b.isFunction(e[h].__getData)&&(e[h]=e[h].__getData());else b.isFunction(e.__getData)&&(e=e.__getData());a[d]=e}return a}}}),d("Property",{process:function(c,e,f){c["_"+f]=a,b.isArray(e)?e=3===e.length?{type:[e[0],e[2]],"default":e[1]}:{type:e}:b.isObject(e)||(e={"default":e}),"methods"in e||(e.methods=["get","set","has","is","clear","remove"]);for(var g in e)if(g in this._options){var h=this._options[g];b.isString(h)&&(h=d(h)),h.process(c,e[g],f)}},addOption:function(a,b){if(a in this._options)throw new Error('Option "'+a+'" is already exists!');return this._options[a]=b,this},hasOption:function(a){return a in this._options},removeOption:function(a){if(!(a in this._options))throw new Error('Option "'+a+'" does not exists!');return delete this._options[a],this},_options:{type:"Property/Type","default":"Property/Default",alias:"Property/Alias",methods:"Property/Methods",constraints:"Property/Constraints",converters:"Property/Converters",getters:"Property/Getters",setters:"Property/Setters"}}),e("Property","meta",function(a){a("Alias",{process:function(a,b,c){b&&a.__setPropertyParam(c,"aliases",[].concat(b))}}),a("Constraints",{SETTER_NAME:"__constraints__",process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,function(a){return d.apply(a,b,c,this)})},apply:function(a,b,c,d){for(var e in b)if(!b[e].call(d,a,c))throw new Error('Constraint "'+e+'" was failed!');return a}}),a("Converters",{SETTER_NAME:"__converters__",process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,function(a){return d.apply(a,b,c,this)})},apply:function(a,b,c,d){for(var e in b)a=b[e].call(d,a,c);return a}}),a("Default",{process:function(a,c,d){b.isUndefined(c)||a.__setPropertyParam(d,"default",c)}}),a("Getters",{process:function(a,b,c){for(var d in b)a.__addGetter(c,d,b[d])}}),a("Methods",{process:function(a,b,c,d){for(var e=0,f=b.length;f>e;++e)this.addMethodToObject(b[e],a,c);for(var d=a.__getPropertyParam(c,"aliases")||[],g=0,h=d.length;h>g;++g)for(var e=0,f=b.length;f>e;++e)this.addMethodToObject(b[e],a,c,d[g])},addMethodToObject:function(a,b,c,d){var e=this.createMethod(a,c,d);b[e.name]=e.body},createMethod:function(a,c,d){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');var e=this._methods[a](c,d);if(b.isFunction(e)){var f="undefined"!=typeof d?d:c;e={name:a+f[0].toUpperCase()+f.slice(1),body:e}}return e},addMethod:function(a,b){if(a in this._methods)throw new Error('Method "'+a+'" is already exists!');return this._methods[a]=b,this},hasMethod:function(a){return a in this._methods},removeMethod:function(a){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');return delete this._methods[a],this},_methods:{get:function(a){return function(){return this.__getPropertyValue.apply(this,[a].concat(b.toArray(arguments)))}},set:function(a){return function(){return this.__setPropertyValue.apply(this,[a].concat(b.toArray(arguments)))}},is:function(a,c){var d=b.isUndefined(c)?a:c;return{name:0!==d.indexOf("is")?"is"+d[0].toUpperCase()+d.slice(1):d,body:function(){return this.__isPropertyValue.apply(this,[a].concat(b.toArray(arguments)))}}},has:function(a){return function(){return this.__hasPropertyValue.apply(this,[a].concat(b.toArray(arguments)))}},clear:function(a){return function(){return this.__clearPropertyValue.apply(this,[a].concat(b.toArray(arguments)))}},remove:function(a){return function(){return this.__removePropertyValue.apply(this,[a].concat(b.toArray(arguments)))}}}}),a("Setters",{process:function(a,b,c){for(var d in b)a.__addSetter(c,d,b[d])}}),a("Type",{SETTER_NAME:"__type__",process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,function(e){return d.apply(e,b,c,a)})},apply:function(a,c,d,e){if(b.isUndefined(a)||b.isNull(a))return a;var f={};if(b.isArray(c)&&(f=c[1]||{},c=c[0]),!(c in this._types))throw new Error('Property type "'+c+'" does not exists!');return this._types[c].call(this,a,f,d,e)},addType:function(a,b){if(a in this._types)throw new Error('Property type "'+a+'" is already exists!');return this._types[a]=b,this},hasType:function(a){return a in this._types},removeType:function(a){if(!(a in this._types))throw new Error('Property type "'+a+'" does not exists!');return delete this._types[a],this},setDefaultArrayDelimiter:function(a){if(!b.isString(a)&&!b.isRegExp(a))throw new Error("Delimiter must be a string or a regular expression!");return this._defaultArrayDelimiter=a,this},getDefaultArrayDelimiter:function(){return this._defaultArrayDelimiter},_defaultArrayDelimiter:/\s*,\s*/g,_types:{"boolean":function(a){return Boolean(a)},number:function(a,b,c){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" of property "'+c+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" of property "'+c+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b,c){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" of property "'+c+'" does not match pattern "'+b.pattern+'"!');if("variants"in b&&-1===b.variants.indexOf(a))throw new Error('Value "'+a+'" of property "'+c+'" must be one of "'+b.variants.join(", ")+'"!');return a},datetime:function(a,c,d){if(b.isNumber(a)&&!isNaN(a)?a=new Date(a):b.isString(a)&&(a=new Date(Date.parse(a))),!(a instanceof Date))throw new Error('Value of property "'+d+'" must have datetime type!');return a},array:function(a,c,d){var e,f,g;if(b.isString(a)&&(a=a.split(c.delimiter||this._defaultArrayDelimiter)),"element"in c)for(g=[].concat(c.element),e=0,f=a.length;f>e;++e)a[e]=this.apply.call(this,a[e],g,d+"."+e);return a},hash:function(a,c,d){var e,f;if(!b.isObject(a))throw new Error('Value of property "'+d+'" must have object type!');if("keys"in c)for(e in a)if(!(e in c.keys))throw new Error('Unsupported hash key "'+e+'" for property "'+d+'"!');if("element"in c){f=[].concat(c.element);for(e in a)a[e]=this.apply.call(this,a[e],f,d+"."+e)}return a},object:function(a,c,d,e){if(!b.isObject(a))throw new Error('Value of property "'+d+'" must have an object type!');if("instanceOf"in c){var f=c.instanceOf,g=e.__isClazz?e.__clazz:e.__clazz.__clazz;if(b.isString(f)&&(f=g.getNamespace().adjustPath(f),a.__clazz||(f=g(f))),a.__clazz?!a.__clazz.__isSubclazzOf(f):!(a instanceof f)){var h=f.__isClazz?f.__name:b.isString(f)?f:"another";throw new Error('Value of property "'+d+'" must be instance of '+h+" clazz!")}}return a},"function":function(a,c,d){if(!b.isFunction(a))throw new Error('Value of property "'+d+'" must have function type');return a}}})}),c("Base",function(){var a=0;return{clazz_methods:{create:function(){var a=b.construct(this,b.toArray(arguments));return this.emit("object.create",a),a},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},"const":function(){return this.__executeConstant.apply(this,b.toArray(arguments))}},methods:{__construct:function(){this.__uid=++a;for(var c in this)0===c.indexOf("__init")&&b.isFunction(this[c])&&this[c]();b.isFunction(this.init)&&this.init.apply(this,b.toArray(arguments))},getUID:function(){return this.__uid},init:function(a){return this.__setData(a)},parent:function(a){var c=this;if(!c.__parent)throw new Error('Parent clazz does not exists for "'+this.__clazz.__name+'" clazz!');if(!b.isFunction(c.__parent[a]))throw new Error('Method "'+a+'" does not exists in clazz "'+this.__clazz.__name+'"!');return a=c.__parent[a],function(){return a.apply(this,b.toArray(arguments))}},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},"const":function(){return this.__clazz.__executeConstant.apply(this.__clazz,b.toArray(arguments))}}}})}),l.getFactory().setMetaProcessor(i("/ClazzJS/Base")).setBaseClazz(l("/ClazzJS/Base")),{Namespace:c,Clazz:e,Meta:d,namespace:g,clazz:l,meta:i,_:b}});
!function(a,b,c,d){if("function"==typeof define&&define.amd)define(b,c,d);else if("object"==typeof exports&&exports){for(var e=0,f=c.length;f>e;++e){var g=c[e];"string"==typeof g&&(g=g.replace(/([A-Z]+)/g,function(a){return"-"+a.toLowerCase()}).replace(/^-/,""),c[e]=require(g))}var h=d.apply(a,c);for(var i in h)exports[i]=h[i]}else{for(var e=0,f=c.length;f>e;++e){var g=c[e];if("string"==typeof g){if(!(g in a))throw new Error('"'+b+'" dependent on non exited module "'+g+'"!');c[e]=a[g]}}a[b]=d.apply(a,c)}}(new Function("return this")(),"ClazzJS",[],function(a){var b=function(){var a={},b=Object.prototype.toString,c=Array.prototype.slice;a.isUndefined=function(a){return void 0===a},a.isObject=function(a){return a===Object(a)},a.isSimpleObject=function(a){return"[object Object]"===b.call(a)},a.isNull=function(a){return null===a};for(var d=["Function","String","Number","Date","RegExp","Array"],e=0,f=d.length;f>e;++e)!function(c){a["is"+c]=function(a){return b.call(a)==="[object "+c+"]"}}(d[e]);return a.toArray=function(a){return c.call(a)},a.extend=function(a){for(var b=c.call(arguments,1),d=0,e=b.length;e>d;++d){var f=b[d];if(f)for(var g in f)a[g]=f[g]}return a},a.last=function(a){return a[a.length-1]},a.construct=function(a,b){var c=function(){return a.apply(this,b)};return c.prototype=a.prototype,new c},a}(),c=function(){var a=function(c,d){var e=function(a){var c=e.getScope().getNamespace(e.adjustPath(a));return arguments.length>1&&c.space.apply(c,b.toArray(arguments).slice(1)),c};return b.extend(e,a.prototype),e._scope=c,e._path=d,e._spaces=[],e._objects={},e};b.extend(a.prototype,{getPath:function(){return this._path},getScope:function(){return this._scope},adjustPath:function(a){return this._scope.isAbsolutePath(a)?this._scope.adjustPath(a):this._scope.concatPaths(this.getPath(),a)},get:function(a){return a in this._objects||(this._objects[a]=this._scope.get(a).call(this)),this._objects[a]},has:function(a){return this._scope.has(a)},space:function(){var a=this,c=b.toArray(arguments).slice(0,-1),d=b.last(arguments),e=[];c.length||(c=this._scope.getDefaultInjects());for(var f=0,g=c.length;g>f;++f)e[f]=this.get(c[f]);return this._spaces.push(function(){d.apply(a,e)}),this},executeSpace:function(){return this._spaces.length?(this._spaces.pop()(),!0):!1}});var c=function(a){a=a||{},this._innerDelimiter=a.innerDelimiter||"/",this._delimiters=a.delimiters||["\\","/","."],this._defaultInjects=a.defaultInjects||[],this._namespaces={},this._factories={},this._search=[]};return b.extend(c.prototype,{getInnerDelimiter:function(){return this._innerDelimiter},setInnerDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not supported!');return this._innerDelimiter=a,this},getDelimiters:function(){return this._delimiters},addDelimiter:function(a){if(this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" is already exists!');return this},removeDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not exists!')},hasDelimiter:function(a){return-1!==this._delimiters.indexOf(a)},getNamespace:function(b){return b=this.adjustPath(b),b in this._namespaces||(this._namespaces[b]=a(this,b)),this._namespaces[b]},getRootNamespace:function(){return this.getNamespace(this.getRootPath())},getRootPath:function(){return this._innerDelimiter},adjustPath:function(a){var b=this.getInnerDelimiter(),c=this.getDelimiters();return a.replace(new RegExp("[\\"+c.join("\\")+"]","g"),b).replace(new RegExp(b+"+","g"),b).replace(new RegExp("(.+)"+b+"$"),function(a){return a})},isAbsolutePath:function(a){return 0===a.indexOf(this.getRootNamespace().getPath())},concatPaths:function(){return this.adjustPath(b.toArray(arguments).join(this.getInnerDelimiter()))},set:function(a,b){if(a in this._factories)throw new Error('Factory for object "'+a+'" is already exists!');return this._factories[a]=b,this},get:function(a){if(!(a in this._factories))throw new Error('Factory for object "'+a+'" does not exists!');return this._factories[a]},has:function(a){return a in this._factories},remove:function(a){return delete this._factories[a],this},getInSearchError:function(a){var b=new Error('Path "'+a+'" is in search state!');return b.inSearch=!0,b.path=a,b},isInSearchError:function(a){return a.inSearch},search:function(a,c){a=this.adjustPath(a);var d=c(a);if(!b.isUndefined(d))return d;for(var e=this.getInnerDelimiter(),f=a.split(e),g=f.pop();f.length;){var h=f.join(e);if(h in this._namespaces)for(var i=this._namespaces[h];i.executeSpace();)if(d=c(h+e+g),!b.isUndefined(d))return d;g=f.pop()}},getDefaultInjects:function(){return this._defaultInjects},addDefaultInject:function(a){if(-1!==this._defaultInjects.indexOf(a))throw new Error('Default inject "'+a+'" is already exists!');return this._defaultInjects.push(a),this},removeDefaultInject:function(a){var b=this._defaultInjects.indexOf(a);if(-1===b)throw new Error('Default inject "'+a+'" does not exists!');return this._defaultInjects.splice(b,1),this}}),{Namespace:a,Scope:c}}(),d=function(){var a=function(){this._processors={}};b.extend(a.prototype,{getProcessor:function(a){return this.checkProcessor(a),this._processors[a]},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,c){return b.isFunction(c)&&(c={process:c}),this._processors[a]=c,this},removeProcessor:function(a){this.checkProcessor(a);var b=this._processors[a];return delete this._processors[a],b},getProcessors:function(){return this._processors},setProcessors:function(a){for(var b in a)this.setProcessor(b,a[b]);return this},checkProcessor:function(a){if(!this.hasProcessor(a))throw new Error('Meta processor "'+a+'" does not exists!')}});var c=function(a,d){var e=function(a,c){return b.isUndefined(c)?e.get(a):e.set(a,c)};return b.extend(e,c.prototype),e._manager=a,e._namespace=d,e};return b.extend(c.prototype,{getManager:function(){return this._manager},getNamespace:function(){return this._namespace},get:function(a){var b=this.getManager(),c=this.resolveProcessorName(a);if(!c)throw new Error('Meta processor "'+a+'" does not exist!');return b.getProcessor(c)},set:function(a,b){var c=this.getNamespace(),d=this.getManager();return d.setProcessor(c.adjustPath(a),b),this},resolveProcessorName:function(a){var b=this.getManager(),c=this.getNamespace();return c.getScope().search(c.adjustPath(a),function(a){return b.hasProcessor(a)?a:void 0})}}),{Meta:c,Manager:a}}(),e=function(){var c=function(a,d,e){var f=function(a,c,d){var e=b.last(arguments);return b.isFunction(e)&&!e.prototype.__clazz||"[object Object]"===Object.prototype.toString.call(e)?(f.set(a,c,d),void 0):f.get(a,c,d)};return b.extend(f,c.prototype),f._manager=a,f._factory=d,f._namespace=e,f};b.extend(c.prototype,{getManager:function(){return this._manager},getFactory:function(){return this._factory},getNamespace:function(){return this._namespace},has:function(a){return!!this.resolveName(a)},get:function(c,d,e){b.isUndefined(e)&&b.isArray(d)&&(e=d,d=a);var f=this.resolvePath(c);if(!f)throw new Error('Clazz "'+c+'" does not exists!');e=e||[];var g=this.getManager();if(!g.hasClazz(f,d,e)){var h=this.getFactory(),i=g.getClazzData(f);g.setClazz(f,h.create({name:i.name,parent:d,metaParent:i.parent,meta:i.meta,dependencies:e,clazz:i.clazz}),d,e)}return g.getClazz(f,d,e)},set:function(c,d,e){b.isUndefined(e)&&(e=d,d=a);var f=this.getNamespace(),g=this.getManager();return b.isUndefined(e)&&(e=d,d=null),c=f.adjustPath(c),b.isString(d)&&(d=f.adjustPath(d)),g.setClazzData(c,{name:c,parent:d,meta:e,clazz:this}),this},resolvePath:function(a){var b=this.getNamespace(),c=this.getManager();return b.getScope().search(b.adjustPath(a),function(a){return c.hasClazzData(a)?a:void 0})}});var d=function(a){a=a||{},this._clazzUID=0,this._metaProcessor=a.metaProcessor||null,this._baseClazz=a.baseClazz||null};b.extend(d.prototype,{CLAZZ_NAME:"Clazz{uid}",getBaseClazz:function(){return this._baseClazz},setBaseClazz:function(a){if(!b.isFunction(a))throw new Error("Base clazz must be a function!");return this._baseClazz=a,this},getMetaProcessor:function(){return this._metaProcessor},setMetaProcessor:function(a){if(!b.isFunction(a.process))throw new Error('Meta processor must have "process" method!');return this._metaProcessor=a,this},create:function(a){var c=a.name||this.generateName(),d=a.parent,e=a.metaParent,f=a.meta||{},g=a.dependencies||[],h=a.clazz,i=this.createClazz();return i.__name=c,i.__clazz=h,b.isFunction(f)&&(f=f.apply(i,[i].concat(g))||{}),!f.parent&&e&&(f.parent=e),d=d||f.parent,b.isString(d)&&(d=[d]),b.isArray(d)&&(d=h.get.apply(h,d)),this.applyParent(i,d),i.prototype.__clazz=i,i.prototype.__proto=i.prototype,this.applyMeta(i,f),i},createClazz:function(){return function a(){var c;if(!(this instanceof a))return b.construct(a,b.toArray(arguments));if(b.isFunction(a.__construct)?c=a.__construct.apply(this,b.toArray(arguments)):a.__parent&&(c=a.__parent.apply(this,b.toArray(arguments))),!b.isUndefined(c))return c;for(var d in this)0===d.indexOf("__init")&&b.isFunction(this[d])&&this[d]();b.isFunction(this.init)&&this.init.apply(this,b.toArray(arguments))}},applyParent:function(c,d){if(d=d||this.getBaseClazz())for(var e in d)e in c||(b.isFunction(d[e])?c[e]=d[e]:"_"===e[0]&&(c[e]=a));return c.prototype=b.extend(Object.create(d?d.prototype:{}),c.prototype),c.__parent=d||null,c.prototype.constructor=c,c.prototype.__parent=d?d.prototype:null,c},applyMeta:function(a,b){return this.getMetaProcessor().process(a,b),a},generateName:function(){return this.CLAZZ_NAME.replace("{uid}",++this._clazzUID)}});var e=function(){this._clazz={},this._clazzData={}};return b.extend(e.prototype,{setClazzData:function(a,b){return this._clazzData[a]=b,this},hasClazzData:function(a){return a in this._clazzData},getClazzData:function(a){if(!this.hasClazzData(a))throw new Error('Data does not exists for clazz "'+a+'"!');return this._clazzData[a]},getClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return d[e][0]}throw new Error('Clazz "'+a+'" does not exists!')},hasClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return!0}return!1},setClazz:function(a,c,d,e){if(!b.isFunction(c))throw new Error("Clazz must be a function!");return a in this._clazz||(this._clazz[a]=[]),this._clazz[a].push([c,d,e||[]]),this}}),{Clazz:c,Factory:d,Manager:e}}(),f=new c.Scope({defaultInjects:["clazz","namespace"]}),g=f.getRootNamespace(),h=new d.Manager,i=new d.Meta(h,g),j=new e.Manager,k=new e.Factory,l=new e.Clazz(j,k,g);return f.set("namespace",function(){return this}),f.set("meta",function(){return new d.Meta(h,this)}),f.set("clazz",function(){return new e.Clazz(j,k,this)}),g("ClazzJS","clazz","meta","namespace",function(c,d,e){d("Base",{_objectTypes:{clazz:function(a){return a},proto:function(a){return a.prototype}},_processors:{clazz:{constants:"Constants",clazz_properties:"Properties",clazz_methods:"Methods",clazz_events:"Events"},proto:{properties:"Properties",methods:"Methods",events:"Events"}},process:function(a,c){a.__isClazz||b.extend(a,this.clazz_interface);for(var d in this._objectTypes){var e=this._objectTypes[d](a);e.__interfaces||(e.__interfaces=["common"],b.extend(e,this.common_interface))}a.__metaProcessors=c.meta_processors||{};var f=c.parent;if(f&&!a.__isSubclazzOf(f))throw new Error('Clazz "'+a.__name+'" must be subclazz of "'+f.__isClazz?f.__name:f+'"!');var g=a.__getMetaProcessors();for(var h in g){var e=this._objectTypes[h](a);for(var i in g[h]){var j=g[h][i];j.interface&&!e.__isInterfaceImplemented(i)&&e.__implementInterface(i,j.interface),j.process(e,c)}}},addObjectType:function(a,b){return a in this._processors||(this._processors[a]=[]),a in this._optionProcessors||(this._optionProcessors[a]={}),this._objectTypes[a]=b,this},removeObjectType:function(a){return a in this._processors&&delete this._processors,a in this._optionProcessors&&delete this._optionProcessors[a],delete this._objectTypes[a],this},getProcessors:function(a){var c=this._processors;for(var e in c)if(!a||a===e)for(var f in c[e])b.isString(c[e][f])&&(c[e][f]=d(c[e][f]));return b.isUndefined(a)?c:c[a]},setProcessors:function(a){for(var b in a)for(var c in a[b])this.setProcessor(b,c,a[b][c]);return this},hasProcessor:function(a,b){return b in this._processors[a]},setProcessor:function(a,b,c){if(b in this._processors[a])throw new Error('Processor "'+b+'" is already exists for object type "'+a+'"!');return this._processors[a][b]=c,this},removeProcessor:function(a,b){if(!(b in this._processors[a]))throw new Error('Processor "'+b+'" does not exists for object type "'+a+'"!');return delete this._processors[a][b],this},clazz_interface:{__isClazz:!0,__isSubclazzOf:function(a){for(var b=this;b;){if(b===a||b.__name===a)return!0;b=b.__parent}return!1}},common_interface:{__isInterfaceImplemented:function(a){return-1!==this.__interfaces.indexOf(a)},__implementInterface:function(a,c){if(-1!==this.__interfaces.indexOf(a))throw new Error('Interface "'+a+'" is already implemented!');return this.__interfaces.push(a),b.extend(this,c),this},__collectAllPropertyValues:function(a,c){var d=[];this.hasOwnProperty(a)&&d.push(this[a]),this.__proto&&this.__proto.hasOwnProperty(a)&&d.push(this.__proto[a]);for(var e=this.__parent;e;)e.hasOwnProperty(a)&&d.push(e[a]),e=e.__parent;for(var f=b.toArray(arguments).slice(2),g={},h=0,i=d.length;i>h;++h)this.__collectValues(g,d[h],c||1,f);return g},__collectValues:function f(a,b,c,d,e){d=[].concat(d||[]);for(var g in b)d[0]&&g!==d[0]||(c>1&&"[object Object]"===Object.prototype.toString.call(b[g])?(g in a||(a[g]={}),f(a[g],b[g],c-1,d.slice(1))):!e&&g in a||(a[g]=b[g]));return a},__getMetaProcessors:function(){var a=this.__isClazz?this:this.__clazz;return this.__collectValues(a.__collectAllPropertyValues("__metaProcessors",2),d("Base").getProcessors())}}}),d("Constants",{process:function(a,b){var c=b.constants||{};a.__constants={};for(var d in c)a.__constants[d]=c[d]},"interface":{__initConstants:function(){this.__constants={}},__getConstants:function(){return this.__collectAllPropertyValues("__constants",99)},__getConstant:function(){for(var a=b.toArray(arguments),c=this.__collectAllPropertyValues.apply(this,["__constants",99].concat(a)),d=0,e=a.length;e>d;++d){if(!(a[d]in c))throw new Error('Constant "'+a.splice(0,d).join(".")+'" does not exists!');c=a[d]}return c},__executeConstant:function(a,c){var d=this;if(b.isUndefined(c)&&(c=d.__getConstants()),!b.isUndefined(a)){if(!(a in c))throw new Error('Constant "'+a+'" does not defined!');if(c=c[a],"[object Object]"===Object.prototype.toString.call(c))return function(a){return d.__executeConstant(a,c)}}return c}}}),d("Events",{process:function(a,b){var c=a.__isClazz?"clazz_events":"events",d=b[c]||{};a.__events={};for(var e in d)for(var f in d[e])a.__addEventListener(e,f,d[e][f])},"interface":{__initEventsCallbacks:function(){this.__events={}},__emitEvent:function(a){var c=this.__getEventListeners(a);for(var d in c)c[d].apply(this,b.toArray(arguments).slice(1));return this},__addEventListener:function(a,b,c){if(this.__hasEventListener(a,b))throw new Error('Event listener for event "'+a+'" with name "'+b+'" is already exists!');return a in this.__events||(this.__events[a]={}),this.__events[a][b]=c,this},__removeEventListener:function(b,c){if(!this.hasEventCallback(b,c))throw new Error('There is no "'+b+(c?'"::"'+c:"")+'" event callback!');return this.__events[b][c]=a,this},__hasEventListener:function(a,b){return b in this.__getEventListeners(a)},__getEventListener:function(a,b){var c=this.__getEventListeners(a);if(!(b in c))throw new Error('Event listener for event "'+a+'" with name "'+b+'" does not exists!');return c[a][b]},__getEventListeners:function(a){return this.__collectAllPropertyValues.apply(this,["__events",2].concat(a||[]))}}}),d("Methods",{process:function(a,c){var d=a.__isClazz?"clazz_methods":"methods",e=c[d]||{};for(var f in e){if(!b.isFunction(e[f]))throw new Error('Method "'+f+'" must be a function!');a[f]=e[f]}}}),d("Properties",{_propertyMetaProcessor:"Property",process:function(a,c){var d=a.__isClazz?"clazz_properties":"properties",e=c[d]||{};a.__properties={},a.__setters={},a.__getters={};var f=this.getPropertyMetaProcessor();for(var g in e)f.process(a,e[g],g);var h=a.__getPropertiesParam();for(var g in h)if("default"in h[g]){var i=h[g].default;b.isFunction(i)&&(i=i.call(a)),a["_"+g]=i}},getPropertyMetaProcessor:function(){var a=this._propertyMetaProcessor;return b.isString(a)&&(this._propertyMetaProcessor=d(a)),a},setPropertyMetaProcessor:function(a){return this._propertyMetaProcessor=a,this},"interface":{__initProperties:function(){this.__properties={},this.__setters={},this.__getters={}},__setPropertiesParam:function(a){for(var b in a)this.__setPropertyParam(b,a[b]);return this},__getPropertiesParam:function(){return this.__collectAllPropertyValues("__properties",2)},__setPropertyParam:function(a,c,d){var e={};return b.isUndefined(d)?b.isObject(c)&&b.extend(e,c):e[c]=d,a in this.__properties||(this.__properties[a]={}),b.extend(this.__properties[a],e),this},__getPropertyParam:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__properties",2,a].concat(b||[]));return b?c[b]:c},__hasProperty:function(a){return"_"+a in this},__getPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=this.__applyGetters(c,this["_"+c]),e=0,f=a.length;f>e;++e){var g=a[e];if(!(g in d))throw new Error('Property "'+[c].concat(a.slice(0,e+1)).join(".")+'" does not exists!');d=this.__applyGetters(c,d[g],a.slice(0,e+1))}return d},__hasPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=this.__applyGetters(c,this["_"+c]),e=0,f=a.length;f>e;++e){var g=a[e];if(!(g in d))return!1;d=this.__applyGetters(c,d[g],a.slice(0,e+1))}return!b.isUndefined(d)&&!b.isNull(d)},__isPropertyValue:function(a,c){var d=this.__getPropertyValue(a);return b.isUndefined(c)?!!d:d===c},__clearPropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))throw new Error('Property "'+[d].concat(c).join(".")+'" does not exists!')}else e="_"+d,f=this;var g=f[e];return f[e]=b.isSimpleObject(g)&&{}||b.isArray&&[]||a,this.__checkEmitEvent()&&this.__emitPropertyCleared([d].concat(c),g),this},__removePropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))throw new Error('Property "'+[d].concat(c).join(".")+'" does not exists!')}else e="_"+d,f=this;var g=f[e];return c.length?delete f[e]:f[e]=a,this.__checkEmitEvent()&&this.__emitPropertyRemoved([d].concat(c),g),this},__setPropertyValue:function(a,c){b.isString(a)&&(a=a.split("."));var d=a.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;a.length?(e=b.last(a),f=this.__getPropertyValue([d].concat(a).slice(0,-1))):(e="_"+d,f=this);var g=e in f,h=f[e],i=this.__applySetters(d,c,a);return f[e]=i,this.__checkEmitEvent()&&this.__emitPropertySetted([d].concat(a),h,i),this},__emitPropertyRemoved:function(a,c){var d,e;return this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),a.length&&(d=a.slice(0,-1).join("."),e=b.last(a),this.__emitEvent("property."+d+".item_removed",e,c),this.__emitEvent("property.item_removed",d,e,c)),d=a.join("."),this.__emitEvent("property."+d+".removed",c),this.__emitEvent("property.removed",d,c),this},__emitPropertyCleared:function(a,c){var d,e,f,g;if(this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),b.isSimpleObject(c))for(e in c)this.__emitPropertyRemoved(a.concat(e),c[e]);else if(b.isArray(c))for(f=0,g=c.length;g>f;++f)this.__emitPropertyRemoved(a.concat(f),c[f]);return d=a.join("."),this.__emitEvent("property."+d+".cleared",c),this.__emitEvent("property.cleared",d,c),this},__emitPropertySetted:function(a,c,d,e){var f,g,h,i,j;this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split("."));var k=!0;if(b.isSimpleObject(c)&&b.isSimpleObject(d)){for(h in d)if(c[h]!==d[h]){k=!1;break}}else if(b.isArray(c)&&b.isArray(d)){for(i=0,j=d.length;j>i;++i)if(c[i]!==d[i]){k=!1;break}}else c!==d&&(k=!1);return k||(f=a.join("."),g=b.isUndefined(d)||b.isNull(d)?"setted":"changed",this.__emitEvent("property."+f+"."+g,c,d),this.__emitEvent("property."+g,f,c,d),a.length&&!e&&(f=a.slice(0,-1).join("."),h=b.last(a),this.__emitEvent("property."+f+".item_added",h,c),this.__emitEvent("property.item_added",f,h,c))),this},__checkEmitEvent:function(a){a=b.isUndefined(a)?!1:a;var c=b.isFunction(this.__emitEvent);if(a&&!c)throw new Error("__emitEvent method does not realized!");return c},__addSetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Setter callback must be a function!");return a in this.__setters||(this.__setters[a]={}),this.__setters[a][c]=[d,e],this},__getSetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__setters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[1]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applySetters:function(a,c,d){d=d||[];for(var e=this.__getSetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__addGetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Getter callback must be a function!");return a in this.__getters||(this.__getters[a]={}),this.__getters[a][c]=[d,e],this},__getGetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__getters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[1]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applyGetters:function(a,c,d){d=d||[];for(var e=this.__getGetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__setData:function(a){for(var b in a)this.__hasProperty(b)&&this.__setPropertyValue(b,a[b]);return this},__getData:function(){var a={},c=this.__getPropertiesMeta();for(var d in c){var e=this.__getPropertyValue(d);if(b.isArray(e))for(var f=0,g=e.length;g>f;++f)b.isFunction(e[f].__getData)&&(e[f]=e[f].__getData());else if(e.constructor==={}.constructor)for(var h in e)b.isFunction(e[h].__getData)&&(e[h]=e[h].__getData());else b.isFunction(e.__getData)&&(e=e.__getData());a[d]=e}return a}}}),d("Property",{process:function(c,e,f){c["_"+f]=a,b.isArray(e)?e=3!==e.length&&b.isSimpleObject(e[1])?{type:e}:{type:[e[0],e[2]||{}],"default":e[1]}:b.isSimpleObject(e)||(e={"default":e}),"methods"in e||(e.methods=["get","set","has","is","clear","remove"]);for(var g in e)if(g in this._options){var h=this._options[g];b.isString(h)&&(h=d(h)),h.process(c,e[g],f)}},addOption:function(a,b){if(a in this._options)throw new Error('Option "'+a+'" is already exists!');return this._options[a]=b,this},hasOption:function(a){return a in this._options},removeOption:function(a){if(!(a in this._options))throw new Error('Option "'+a+'" does not exists!');return delete this._options[a],this},_options:{type:"Property/Type","default":"Property/Default",methods:"Property/Methods",constraints:"Property/Constraints",converters:"Property/Converters",getters:"Property/Getters",setters:"Property/Setters"}}),e("Property","meta",function(c){c("Constraints",{SETTER_NAME:"__constraints__",SETTER_WEIGHT:-100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)if(!b[f].call(e,a,c,d))throw new Error('Constraint "'+f+'" was failed!');return a}}),c("Converters",{SETTER_NAME:"__converters__",SETTER_WEIGHT:100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)a=b[f].call(e,a,c,d);return a}}),c("Default",{process:function(a,c,d){b.isUndefined(c)||a.__setPropertyParam(d,"default",c)}}),c("Getters",{process:function(a,b,c){for(var d in b)a.__addGetter(c,d,b[d])}}),c("Methods",{process:function(a,b,c){for(var d=0,e=b.length;e>d;++d)this.addMethodToObject(b[d],a,c)},addMethodToObject:function(a,b,c){var d=this.createMethod(a,c);b[d.name]=d.body},createMethod:function(a,c){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');var d=this._methods[a](c);return b.isFunction(d)&&(d={name:this.getMethodName(c,a),body:d}),d},getMethodName:function(a,b){var c="";a=a.replace(/^(_+)/g,function(a){return c=a,""});var d="is"===b&&0===a.indexOf("is")?a:b+a[0].toUpperCase()+a.slice(1);return c+d},addMethod:function(a,b){if(a in this._methods)throw new Error('Method "'+a+'" is already exists!');return this._methods[a]=b,this},hasMethod:function(a){return a in this._methods},removeMethod:function(a){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');return delete this._methods[a],this},_methods:{get:function(a){return function(c){return this.__getPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},set:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__setPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},is:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__isPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},has:function(a){return function(c){return this.__hasPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},clear:function(a){return function(c){return this.__clearPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},remove:function(a){return function(c){return this.__removePropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}}}}),c("Setters",{process:function(a,b,c){for(var d in b)a.__addSetter(c,d,b[d])}}),c("Type",{SETTER_NAME:"__type__",SETTER_WEIGHT:-1e3,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(e,f){for(var g=b||{},h=0,i=f.length;i>h;++h){var j=g[1]||{};if(!("element"in j))return e;g=j.element}return d.apply(e,g,c,f,a)})},apply:function(a,c,d,e,f){if(b.isUndefined(a)||b.isNull(a))return a;var g={};if(b.isArray(c)&&(g=c[1]||{},c=c[0]),!(c in this._types))throw new Error('Property type "'+c+'" does not exists!');return this._types[c].call(this,a,g,d,e,f)},addType:function(a,b){if(a in this._types)throw new Error('Property type "'+a+'" is already exists!');return this._types[a]=b,this},hasType:function(a){return a in this._types},removeType:function(a){if(!(a in this._types))throw new Error('Property type "'+a+'" does not exists!');return delete this._types[a],this},setDefaultArrayDelimiter:function(a){if(!b.isString(a)&&!b.isRegExp(a))throw new Error("Delimiter must be a string or a regular expression!");return this._defaultArrayDelimiter=a,this},getDefaultArrayDelimiter:function(){return this._defaultArrayDelimiter},_defaultArrayDelimiter:/\s*,\s*/g,_types:{"boolean":function(a){return Boolean(a)},number:function(a,b,c){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" of property "'+c+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" of property "'+c+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b,c){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" of property "'+c+'" does not match pattern "'+b.pattern+'"!');if("variants"in b&&-1===b.variants.indexOf(a))throw new Error('Value "'+a+'" of property "'+c+'" must be one of "'+b.variants.join(", ")+'"!');return a},datetime:function(a,c,d){if(b.isNumber(a)&&!isNaN(a)?a=new Date(a):b.isString(a)&&(a=new Date(Date.parse(a))),!(a instanceof Date))throw new Error('Value of property "'+d+'" must have datetime type!');return a},array:function(a,c,d,e,f){if(b.isString(a)&&(a=a.split(c.delimiter||this._defaultArrayDelimiter)),"element"in c)for(var g=0,h=a.length;h>g;++g)a[g]=this.apply(a[g],c.element,d,e.concat(g),f);return a},hash:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+[d].concat(e).join(".")+'" must have object type!');if("keys"in c)for(var g in a)if(-1===c.keys.indexOf(g))throw new Error('Unsupported hash key "'+g+'" for property "'+[d].concat(e).join(".")+'"!');if("element"in c)for(var g in a)a[g]=this.apply.call(this,a[g],c.element,d,e.concat(g),f);return a},object:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+d+'" must have an object type!');if("instanceOf"in c){var g=c.instanceOf,h=f.__isClazz?f.__clazz:f.__clazz.__clazz;if(b.isString(g)&&(g=h.getNamespace().adjustPath(g),a.__clazz||(g=h(g))),a.__clazz?!a.__clazz.__isSubclazzOf(g):!(a instanceof g)){var i=g.__isClazz?g.__name:b.isString(g)?g:"another";throw new Error('Value of property "'+d+'" must be instance of '+i+" clazz!")}}return a},"function":function(a,c,d){if(!b.isFunction(a))throw new Error('Value of property "'+d+'" must have function type');return a}}})}),c("Base",function(){var a=0;return{clazz_methods:{create:function(){var a=b.construct(this,b.toArray(arguments));return this.emit("object.create",a),a},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},"const":function(){return this.__executeConstant.apply(this,b.toArray(arguments))},parent:function(a,c,d){a=a||this;var e=a.__isClazz?this.__parent:this.__parent.prototype;if(!c)return e;if(!(c in e))throw new Error('Parent does not have property "'+c+'"!');return b.isFunction(e[c])?e[c].apply(a,d||[]):e[c]}},methods:{getUID:function(){return this.__uid},init:function(b){return this.__uid=++a,this.__setData(b)},parent:function(a){var c=this;if(!c.__parent)throw new Error('Parent clazz does not exists for "'+this.__clazz.__name+'" clazz!');if(!b.isFunction(c.__parent[a]))throw new Error('Method "'+a+'" does not exists in clazz "'+this.__clazz.__name+'"!');return a=c.__parent[a],function(){return a.apply(this,b.toArray(arguments))}},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},"const":function(){return this.__clazz.__executeConstant.apply(this.__clazz,b.toArray(arguments))}}}})}),l.getFactory().setMetaProcessor(i("/ClazzJS/Base")).setBaseClazz(l("/ClazzJS/Base")),{Namespace:c,Clazz:e,Meta:d,namespace:g,clazz:l,meta:i,_:b}});
//# sourceMappingURL=dist/ClazzJS.min.map

@@ -64,1 +64,3 @@ Installation

Enjoy!
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/2bf3adae10921a661445015ca0b1745b "githalytics.com")](http://githalytics.com/alexpods/clazzjs)

@@ -225,1 +225,2 @@ Clazz declaration

[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/d67415cfa4749d0e389b14dfc8466a8f "githalytics.com")](http://githalytics.com/alexpods/clazzjs)
{
"name": "clazz-js",
"title": "ClazzJS",
"version": "0.3.2",
"version": "0.3.3",
"description": "Portable JavaScript library for class-style OOP programming",

@@ -6,0 +6,0 @@ "author": {

@@ -24,4 +24,6 @@ ClazzJS

1. [Installation](./docs/1.installation.md)
2. [Clazz declaration](./docs/2.clazz_declaration.md)
1. [Installation](https://github.com/alexpods/ClazzJS/blob/master/docs/1.installation.md)
2. [Clazz declaration](https://github.com/alexpods/ClazzJS/blob/master/docs/2.clazz_declaration.md)
3. [Properties](https://github.com/alexpods/ClazzJS/blob/master/docs/3.properties.md)
4. [Methods](https://github.com/alexpods/ClazzJS/blob/master/docs/4.methods.md)

@@ -34,3 +36,3 @@ Example

Declare of common 'Person' clazz:
Declaration of common 'Person' clazz:
```js

@@ -37,0 +39,0 @@ clazz("Person", {

@@ -15,2 +15,6 @@ var _ = (function() {

_.isSimpleObject = function(obj) {
return toString.call(obj) === '[object Object]';
};
_.isNull = function(obj) {

@@ -27,3 +31,3 @@ return obj === null;

})(isFunctions[i]);
};
}

@@ -30,0 +34,0 @@ _.toArray = function(obj) {

@@ -19,18 +19,21 @@ clazz('Base', function() {

return this.__executeConstant.apply(this, _.toArray(arguments));
},
parent: function(context, property, params) {
context = context || this;
var parent = context.__isClazz ? this.__parent : this.__parent.prototype;
if (!property) {
return parent;
}
if (!(property in parent)) {
throw new Error('Parent does not have property "' + property + '"!');
}
return _.isFunction(parent[property]) ? parent[property].apply(context, params || []) : parent[property];
}
},
methods: {
__construct: function() {
this.__uid = ++uid;
for (var method in this) {
if (0 === method.indexOf('__init') && _.isFunction(this[method])) {
this[method]();
}
}
if (_.isFunction(this.init)) {
this.init.apply(this, _.toArray(arguments));
}
},
getUID: function() {

@@ -41,2 +44,3 @@ return this.__uid;

init: function(data) {
this.__uid = ++uid;
return this.__setData(data);

@@ -43,0 +47,0 @@ },

@@ -9,7 +9,2 @@ meta('Base', {

_processors: {
clazz: {},
proto: {}
},
_optionProcessors: {
clazz: {

@@ -34,10 +29,2 @@ constants: 'Constants',

var parent = metaData.parent;
if (parent) {
if (!clazz.__isSubclazzOf(parent)) {
throw new Error('Clazz "' + clazz.__name + '" must be subclazz of "' + parent.__isClazz ? parent.__name : parent + '"!');
}
}
for (var objectType in this._objectTypes) {

@@ -52,40 +39,26 @@ var object = this._objectTypes[objectType](clazz);

for (var objectType in this._processors) {
clazz.__metaProcessors = metaData.meta_processors || {};
var object = this._objectTypes[objectType](clazz);
var processors = this._processors[objectType];
var parent = metaData.parent;
for (var name in processors) {
var processor = processors[name];
if (_.isString(processor)) {
processor = meta(processor);
}
if (processor.interface && !object.__isInterfaceImplemented(processor.__name)) {
object.__implementInterface(processor.__name, processor.interface);
}
processor.process(object, metaData);
if (parent) {
if (!clazz.__isSubclazzOf(parent)) {
throw new Error('Clazz "' + clazz.__name + '" must be subclazz of "' + parent.__isClazz ? parent.__name : parent + '"!');
}
}
for (var objectType in this._optionProcessors) {
var processors = clazz.__getMetaProcessors();
var object = this._objectTypes[objectType](clazz);
var processors = this._optionProcessors[objectType];
for (var type in processors) {
for (var option in processors) {
var processor = processors[option];
var object = this._objectTypes[type](clazz);
if (_.isString(processor)) {
processor = meta(processor);
}
for (var name in processors[type]) {
var processor = processors[type][name];
if (processor.interface && !object.__isInterfaceImplemented(processor.__name)) {
object.__implementInterface(processor.__name, processor.interface);
if (processor.interface && !object.__isInterfaceImplemented(name)) {
object.__implementInterface(name, processor.interface);
}
processor.process(object, metaData[option] || {}, option);
processor.process(object, metaData);
}

@@ -117,2 +90,28 @@ }

getProcessors: function(objectType) {
var processors = this._processors;
for (var type in processors) {
if (objectType && objectType !== type) {
continue;
}
for (var name in processors[type]) {
if (_.isString(processors[type][name])) {
processors[type][name] = meta(processors[type][name]);
}
}
}
return !_.isUndefined(objectType) ? processors[objectType] : processors;
},
setProcessors: function(processors) {
for (var type in processors) {
for (var name in processors[type]) {
this.setProcessor(type, name, processors[type][name]);
}
}
return this;
},
hasProcessor: function(objectType, name) {

@@ -122,7 +121,7 @@ return name in this._processors[objectType];

addProcessor: function(objectType, processor) {
if (processor.__name in this._processors[objectType]) {
throw new Error('Processor "' + processor.__name + '" is already exists for object type "' + objectType + '"!');
setProcessor: function(objectType, name, processor) {
if (name in this._processors[objectType]) {
throw new Error('Processor "' + name + '" is already exists for object type "' + objectType + '"!');
}
this._processors[objectType][processor.__name] = processor;
this._processors[objectType][name] = processor;
return this;

@@ -139,16 +138,2 @@ },

hasOptionProcessor: function(objectType, option) {
return option in this._optionProcessors[objectType][option];
},
addOptionProcessor: function(objectType, option, processor) {
this._optionProcessors[objectType][option] = processor;
return this;
},
removeOptionProcessor: function(objectType, option) {
delete this._optionProcessors[objectType][option];
return this;
},
clazz_interface: {

@@ -212,28 +197,34 @@

for (var i = 0, ii = propertyContainers.length; i < ii; ++i) {
collectValues(propertyValues, propertyContainers[i], level || 1, fields);
this.__collectValues(propertyValues, propertyContainers[i], level || 1, fields);
}
return propertyValues;
},
function collectValues(collector, container, level, fields) {
fields = [].concat(fields);
__collectValues: function self(collector, container, level, fields, reverse) {
fields = [].concat(fields || []);
for (var name in container) {
if (fields[0] && (name !== fields[0])) {
continue;
}
for (var name in container) {
if (fields[0] && (name !== fields[0])) {
continue;
}
if (level > 1 && Object.prototype.toString.call(container[name]) === '[object Object]') {
if (!(name in collector)) {
collector[name] = {};
}
collectValues(collector[name], container[name], level-1, fields.slice(1));
if (level > 1 && Object.prototype.toString.call(container[name]) === '[object Object]') {
if (!(name in collector)) {
collector[name] = {};
}
else if (!(name in collector)) {
collector[name] = container[name];
}
self(collector[name], container[name], level-1, fields.slice(1));
}
else if (reverse || (!(name in collector))) {
collector[name] = container[name];
}
}
return collector;
},
__getMetaProcessors: function() {
var object = this.__isClazz ? this : this.__clazz;
return this.__collectValues(object.__collectAllPropertyValues('__metaProcessors', 2), meta('Base').getProcessors());
}
}
});
meta('Constants', {
process: function(object, constants) {
process: function(object, metaData) {
var constants = metaData.constants || {};
object.__constants = {};

@@ -5,0 +7,0 @@

meta('Events', {
process: function(object, events) {
process: function(object, metaData) {
var option = object.__isClazz ? 'clazz_events' : 'events';
var events = metaData[option] || {};
object.__events = {};

@@ -5,0 +8,0 @@

meta('Methods', {
process: function(object, methods) {
process: function(object, metaData) {
var option = object.__isClazz ? 'clazz_methods' : 'methods';
var methods = metaData[option] || {};
for (var method in methods) {

@@ -5,0 +8,0 @@ if (!_.isFunction(methods[method])) {

@@ -5,3 +5,6 @@ meta('Properties', {

process: function(object, properties) {
process: function(object, metaData) {
var option = object.__isClazz ? 'clazz_properties' : 'properties';
var properties = metaData[option] || {};
object.__properties = {};

@@ -16,9 +19,26 @@ object.__setters = {};

}
var propertiesParams = object.__getPropertiesParam();
for (var property in propertiesParams) {
if ('default' in propertiesParams[property]) {
var defaultValue = propertiesParams[property].default;
if (_.isFunction(defaultValue)) {
defaultValue = defaultValue.call(object);
}
object['_' + property] = defaultValue;
}
}
},
getPropertyMetaProcessor: function() {
if (_.isString(this._propertyMetaProcessor)) {
this._propertyMetaProcessor = meta(this._propertyMetaProcessor);
var processor = this._propertyMetaProcessor;
if (_.isString(processor)) {
this._propertyMetaProcessor = meta(processor);
}
return this._propertyMetaProcessor;
return processor;
},

@@ -37,14 +57,2 @@

this.__getters = {};
var propertiesParams = this.__getPropertiesParam();
for (var property in propertiesParams) {
if ('default' in propertiesParams[property]) {
var defaultValue = propertiesParams[property].default;
if (_.isFunction(defaultValue)) {
defaultValue = defaultValue.ca
}
this['_' + property] = propertiesParams[property]['default'];
}
}
},

@@ -73,4 +81,2 @@

property = this.__adjustPropertyName(property);
if (!(property in this.__properties)) {

@@ -91,32 +97,28 @@ this.__properties[property] = {};

__hasProperty: function(property) {
property = this.__adjustPropertyName(property);
return ('_' + property) in this;
},
__adjustPropertyName: function(name) {
return name.replace(/(?:_)\w/, function (match) { return match[1].toUpperCase(); });
},
__getPropertyValue: function(fields) {
__getPropertyValue: function(property /* fields.. */) {
if (_.isString(fields)) {
fields = fields.split('.');
}
property = this.__adjustPropertyName(property);
var fields = _.toArray(arguments).slice(1);
var property = fields.shift();
if (!(('_' + property) in this)) {
if (!this.__hasProperty(property)) {
throw new Error('Property "' + property + '" does not exists!');
}
var value = this['_' + property];
var value = this.__applyGetters(property, this['_' + property]);
var getters = this.__getGetters(property);
for (var i = 0, ii = fields.length; i < ii; ++i) {
for (var name in getters) {
value = getters[name].call(this, value);
}
var field = fields[i];
for (var i = 0, ii = fields.length; i < ii; ++i) {
if (!(fields[i]) in value) {{
throw new Error('Property "' + [property].concat(fields.slice(0,i)).join('.') + '" does not exists!');
}}
value = value[fields[i]];
if (!(field in value)) {
throw new Error('Property "' + [property].concat(fields.slice(0, i+1)).join('.') + '" does not exists!');
}
value = this.__applyGetters(property, value[field], fields.slice(0, i+1));
}

@@ -127,12 +129,25 @@

__hasPropertyValue: function(property /* fields... */) {
__hasPropertyValue: function(fields) {
property = this.__adjustPropertyName(property);
var fields = _.toArray(arguments).slice(1);
if (_.isString(fields)) {
fields = fields.split('.');
}
var value = this.__getPropertyValue(property);
var property = fields.shift();
if (!this.__hasProperty(property)) {
throw new Error('Property "' + property + '" does not exists!');
}
var value = this.__applyGetters(property, this['_' + property]);
for (var i = 0, ii = fields.length; i < ii; ++i) {
if (!(fields[i] in value)) {
var field = fields[i];
if (!(field in value)) {
return false;
}
value = this.__applyGetters(property, value[field], fields.slice(0, i+1));
}

@@ -144,77 +159,115 @@

__isPropertyValue: function(property /* fields.. , compareValue */) {
var fields = _.toArray(arguments).slice(1,-1);
var compareValue = arguments.length > 1 ? _.last(arguments) : undefined;
var value = this.__getPropertyValue.apply(this, [property].concat(fields));
__isPropertyValue: function(fields, compareValue) {
var value = this.__getPropertyValue(fields);
return !_.isUndefined(compareValue) ? value === compareValue : !!value;
},
__clearPropertyValue: function(property /* fields */) {
__clearPropertyValue: function(fields) {
if (_.isString(fields)) {
fields = fields.split('.');
}
property = this.__adjustPropertyName(property);
var fields = _.toArray(arguments).slice(1);
var property = fields.shift();
var container = fields.length ? this.__getPropertyValue.apply(this, [property].concat(fields.slice(0,-1))) : this;
var field = fields.length ? _.last(fields) : '_' + property;
if (!this.__hasProperty(property)) {
throw new Error('Property "' + property + '" does not exists!');
}
if (!(field in container)) {
throw new Error('Property "' + [property].concat(fields) + '" does not exists!');
var field, container;
if (fields.length) {
field = _.last(fields);
container = this.__getPropertyValue([property].concat(fields).slice(0, -1));
if (!(field in container)) {
throw new Error('Property "' + [property].concat(fields).join('.') + '" does not exists!');
}
}
else {
field = '_' + property;
container = this;
}
var oldValue = container[field];
var newValue = undefined;
if (oldValue.constructor === {}.constructor) {
newValue = {};
container[field] = (_.isSimpleObject(oldValue) && {}) || (_.isArray && []) || undefined;
if (this.__checkEmitEvent()) {
this.__emitPropertyCleared([property].concat(fields), oldValue);
}
else if (_.isArray(oldValue)) {
newValue = [];
return this;
},
__removePropertyValue: function(fields) {
if (_.isString(fields)) {
fields = fields.split('.');
}
container[field] = newValue;
var property = fields.shift();
// Event emitting
if (_.isFunction(this.__emitEvent)) {
if (!this.__hasProperty(property)) {
throw new Error('Property "' + property + '" does not exists!');
}
if (oldValue.constructor === {}.constructor) {
for (var key in oldValue) {
this.__emitEvent('property.' + [property].concat(fields).join('.') + '.item_removed', key, oldValue[key]);
this.__emitEvent('property.' + [property].concat(fields, key).join('.') + '.removed', oldValue[key]);
}
var field, container;
if (fields.length) {
field = _.last(fields);
container = this.__getPropertyValue([property].concat(fields).slice(0, -1));
if (!(field in container)) {
throw new Error('Property "' + [property].concat(fields).join('.') + '" does not exists!');
}
else if (_.isArray(oldValue)) {
for (var i = 0, ii = oldValue.length; i < ii; ++i) {
this.__emitEvent('property.' + [property].concat(fields).join('.') + '.item_removed', i, oldValue[i]);
this.__emitEvent('property.' + [property].concat(fields, i).join('.') + '.removed', oldValue[i]);
}
}
}
else {
field = '_' + property;
container = this;
}
this.__emitEvent('property.cleared', fields.length ? [property].concat(fields) : property, oldValue);
this.__emitEvent('property.' + [property].concat(fields).join('.') + '.cleared', oldValue);
var oldValue = container[field];
if (fields.length) {
delete container[field]
}
else {
container[field] = undefined;
}
if (this.__checkEmitEvent()) {
this.__emitPropertyRemoved([property].concat(fields), oldValue);
}
return this;
},
__removePropertyValue: function(property /* fields */) {
__setPropertyValue: function(fields, value) {
if (_.isString(fields)) {
fields = fields.split('.');
}
property = this.__adjustPropertyName(property);
var fields = _.toArray(arguments).slice(1);
var property = fields.shift();
var container = fields.length ? this.__getPropertyValue.apply(this, [property].concat(fields.slice(0, -1))) : this;
var field = fields.length ? _.last(fields) : '_' + property;
if (!this.__hasProperty(property)) {
throw new Error('Property "' + property + '" does not exists!');
}
if (!(field in container)) {
throw new Error('Property "' + [property].concat(fields) + '" does not exists!');
var field, container;
if (fields.length) {
field = _.last(fields);
container = this.__getPropertyValue([property].concat(fields).slice(0, -1));
}
else {
field = '_' + property;
container = this;
}
var oldValue = container[field];
delete container[field];
var wasExisted = field in container;
var oldValue = container[field];
var newValue = this.__applySetters(property, value, fields);
// Event emitting
if (_.isFunction(this.__emitEvent)) {
this.__emitEvent('property.removed', fields.length ? [property].concat(fields) : property , oldValue);
this.__emitEvent('property.' + [property].concat(fields).join('.') + '.removed', oldValue);
container[field] = newValue;
if (this.__checkEmitEvent()) {
this.__emitPropertySetted([property].concat(fields), oldValue, newValue);
}

@@ -225,48 +278,100 @@

__setPropertyValue: function(property /* fields.. , value */) {
__emitPropertyRemoved: function(fields, oldValue) {
var prop, key;
property = this.__adjustPropertyName(property);
this.__checkEmitEvent(true);
if (!this.__hasProperty(property)) {
throw new Error('Property "' + property + '" does not exists!');
if (_.isString(fields)) {
fields = fields.split('.');
}
var fields = _.toArray(arguments).slice(1, -1);
var value = _.last(arguments);
var oldValue;
if (fields.length) {
prop = fields.slice(0, -1).join('.');
key = _.last(fields);
var container = this;
this.__emitEvent('property.' + prop + '.item_removed', key, oldValue);
this.__emitEvent('property.item_removed', prop, key, oldValue);
}
fields.unshift('_' + property);
var field = fields.pop();
prop = fields.join('.');
for (var i = 0, ii = fields.length; i < ii; ++i) {
if (_.isUndefined(container[fields[i]])) {
container[fields[i]] = {};
}
container = container[fields[i]];
this.__emitEvent('property.' + prop + '.removed', oldValue);
this.__emitEvent('property.removed', prop, oldValue);
return this;
},
__emitPropertyCleared: function(fields, oldValue) {
var prop, key, i, ii;
this.__checkEmitEvent(true);
if (_.isString(fields)) {
fields = fields.split('.');
}
if (_.isSimpleObject(oldValue)) {
for (key in oldValue) {
this.__emitPropertyRemoved(fields.concat(key), oldValue[key]);
}
}
else if (_.isArray(oldValue)) {
for (i = 0, ii = oldValue.length; i < ii; ++i) {
this.__emitPropertyRemoved(fields.concat(i), oldValue[i]);
}
}
oldValue = container[field];
container[field] = value;
prop = fields.join('.');
this.__emitEvent('property.' + prop + '.cleared', oldValue);
this.__emitEvent('property.cleared', prop, oldValue);
return this;
},
__emitPropertySetted: function(fields, newValue, oldValue, wasExists) {
var prop, event, key, i, ii;
this.__checkEmitEvent(true);
if (_.isString(fields)) {
fields = fields.split('.');
}
else {
var setters = this.__getSetters(property);
for (var name in setters) {
value = setters[name].call(this, value);
var isEqual = true;
if (_.isSimpleObject(newValue) && _.isSimpleObject(oldValue)) {
for (key in oldValue) {
if (newValue[key] !== oldValue[key]) {
isEqual = false;
break;
}
}
oldValue = this['_' + property];
this['_' + property] = value;
}
else if (_.isArray(newValue) && _.isArray(oldValue)) {
for (i = 0, ii = oldValue.length; i < ii; ++i) {
if (newValue[i] !== oldValue[i]) {
isEqual = false;
break;
}
}
}
else if (newValue !== oldValue) {
isEqual = false;
}
// Event emitting
if (_.isFunction(this.__emitEvent)) {
property = [property].concat(fields).join('.');
if (!isEqual) {
prop = fields.join('.');
event = _.isUndefined(oldValue) || _.isNull(oldValue) ? 'setted' : 'changed';
this.__emitEvent('property.changed', property, value, oldValue);
this.__emitEvent('property.' + property + '.changed', value, oldValue);
this.__emitEvent('property.' + prop + '.' + event, newValue, oldValue);
this.__emitEvent('property.' + event, prop, newValue, oldValue);
if (fields.length && !wasExists) {
prop = fields.slice(0,-1).join('.');
key = _.last(fields);
this.__emitEvent('property.' + prop + '.item_added', key, newValue);
this.__emitEvent('property.item_added', prop, key, newValue);
}
}

@@ -277,4 +382,24 @@

__addSetter: function(property, name, callback) {
if (!_.isFunction(callback)) {
__checkEmitEvent: function(throwError) {
throwError = !_.isUndefined(throwError) ? throwError : false;
var check = _.isFunction(this.__emitEvent)
if (throwError && !check) {
throw new Error('__emitEvent method does not realized!');
}
return check;
},
__addSetter: function(property, name, weight, callback) {
if (_.isUndefined(callback)) {
callback = weight;
weight = 0;
}
if (_.isArray(callback)) {
weight = callback[0];
callback = callback[1];
}
else if (!_.isFunction(callback)) {
throw new Error('Setter callback must be a function!');

@@ -285,3 +410,3 @@ }

}
this.__setters[property][name] = callback;
this.__setters[property][name] = [weight, callback];

@@ -291,15 +416,63 @@ return this;

__getSetters: function(property) {
__getSetters: function(property, sorted) {
var setters = this.__collectAllPropertyValues.apply(this, ['__setters', 1].concat(property || []));
return property ? (setters[property] || {}) : setters;
if (!property) {
return setters;
}
setters = setters[property];
if (!sorted) {
return setters[property];
}
var sortedSetters = [];
for (var name in setters) {
sortedSetters.push(setters[name]);
}
sortedSetters = sortedSetters.sort(function(s1, s2) { return s2[0] - s1[1]; });
for (var i = 0, ii = sortedSetters.length; i < ii; ++i) {
sortedSetters[i] = sortedSetters[i][1];
}
return sortedSetters;
},
__addGetter: function(property, callback) {
if (!_.isFunction(callback)) {
__applySetters: function(property, value, fields) {
fields = fields || [];
var setters = this.__getSetters(property, true);
for (var i = 0, ii = setters.length; i < ii; ++i) {
var result = setters[i].call(this, value, fields);
if (!_.isUndefined(result)) {
value = result;
}
}
return value;
},
__addGetter: function(property, name, weight, callback) {
if (_.isUndefined(callback)) {
callback = weight;
weight = 0;
}
if (_.isArray(callback)) {
weight = callback[0];
callback = callback[1];
}
else if (!_.isFunction(callback)) {
throw new Error('Getter callback must be a function!');
}
if (!(property in this.__getters)) {
this.__getters[property] = [];
this.__getters[property] = {};
}
this.__getters[property].push([weight, callback]);
this.__getters[property][name] = [weight, callback];

@@ -309,7 +482,45 @@ return this;

__getGetters: function(property) {
__getGetters: function(property, sorted) {
var getters = this.__collectAllPropertyValues.apply(this, ['__getters', 1].concat(property || []));
return property ? (getters[property] || {}) : getters;
if (!property) {
return getters;
}
getters = getters[property];
if (!sorted) {
return getters[property];
}
var sortedGetters = [];
for (var name in getters) {
sortedGetters.push(getters[name]);
}
sortedGetters = sortedGetters.sort(function(s1, s2) { return s2[0] - s1[1]; });
for (var i = 0, ii = sortedGetters.length; i < ii; ++i) {
sortedGetters[i] = sortedGetters[i][1];
}
return sortedGetters;
},
__applyGetters: function(property, value, fields) {
fields = fields || [];
var getters = this.__getGetters(property, true);
for (var i = 0, ii = getters.length; i < ii; ++i) {
var result = getters[i].call(this, value, fields);
if (!_.isUndefined(result)) {
value = result;
}
}
return value;
},
__setData: function(data) {

@@ -316,0 +527,0 @@ for (var property in data) {

@@ -7,7 +7,7 @@ meta('Property', {

if (_.isArray(propertyMeta)) {
propertyMeta = propertyMeta.length === 3
? { type: [propertyMeta[0], propertyMeta[2]], default: propertyMeta[1] }
propertyMeta = propertyMeta.length === 3 || !_.isSimpleObject(propertyMeta[1])
? { type: [propertyMeta[0], propertyMeta[2] || {}], default: propertyMeta[1] }
: { type: propertyMeta }
}
else if (!_.isObject(propertyMeta)) {
else if (!_.isSimpleObject(propertyMeta)) {
propertyMeta = { default: propertyMeta }

@@ -55,3 +55,2 @@ }

default: 'Property/Default',
alias: 'Property/Alias',
methods: 'Property/Methods',

@@ -58,0 +57,0 @@ constraints: 'Property/Constraints',

@@ -5,13 +5,15 @@ meta('Constraints', {

SETTER_WEIGHT: -100,
process: function(object, constraints, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME, function(value) {
return self.apply(value, constraints, property, this);
object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) {
return self.apply(value, constraints, property, fields, this);
});
},
apply: function(value, constraints, property, object) {
apply: function(value, constraints, property, fields, object) {
for (var name in constraints) {
if (!constraints[name].call(object, value, property)) {
if (!constraints[name].call(object, value, property, fields)) {
throw new Error('Constraint "' + name + '" was failed!');

@@ -18,0 +20,0 @@ }

@@ -5,13 +5,15 @@ meta('Converters', {

SETTER_WEIGHT: 100,
process: function(object, converters, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME , function(value) {
return self.apply(value, converters, property, this);
object.__addSetter(property, this.SETTER_NAME , this.SETTER_WEIGHT, function(value, fields) {
return self.apply(value, converters, property, fields, this);
});
},
apply: function(value, converters, property, object) {
apply: function(value, converters, property, fields, object) {
for (var name in converters) {
value = converters[name].call(object, value, property);
value = converters[name].call(object, value, property, fields);
}

@@ -18,0 +20,0 @@ return value;

meta('Methods', {
process: function(object, methods, property, aliases) {
process: function(object, methods, property) {

@@ -8,36 +8,42 @@ for (var i = 0, ii = methods.length; i < ii; ++i) {

}
var aliases = object.__getPropertyParam(property, 'aliases') || [];
for (var j = 0, jj = aliases.length; j < jj; ++j) {
for (var i = 0, ii = methods.length; i < ii; ++i) {
this.addMethodToObject(methods[i], object, property, aliases[j]);
}
}
},
addMethodToObject: function(name, object, property, alias) {
var method = this.createMethod(name, property, alias);
addMethodToObject: function(name, object, property) {
var method = this.createMethod(name, property);
object[method.name] = method.body;
},
createMethod: function(name, property, alias) {
createMethod: function(name, property) {
if (!(name in this._methods)) {
throw new Error('Method "' + name + '" does not exists!');
}
var method = this._methods[name](property, alias);
var method = this._methods[name](property);
if (_.isFunction(method)) {
var propertyName = typeof alias !== 'undefined' ? alias : property;
method = {
name: name + propertyName[0].toUpperCase() + propertyName.slice(1),
name: this.getMethodName(property, name),
body: method
}
}
return method;
},
getMethodName: function(propertyName, method) {
var prefix = '';
propertyName = propertyName.replace(/^(_+)/g, function(str) {
prefix = str;
return '';
});
var methodName = 'is' === method && 0 === propertyName.indexOf('is')
? propertyName
: method + propertyName[0].toUpperCase() + propertyName.slice(1);
return prefix + methodName;
},
addMethod: function(name, callback) {

@@ -65,34 +71,37 @@ if (name in this._methods) {

get: function(property) {
return function(/* fields */) {
return this.__getPropertyValue.apply(this, [property].concat(_.toArray(arguments)));
return function(fields) {
return this.__getPropertyValue([property].concat(_.isString(fields) ? fields.split('.') : fields || []));
};
},
set: function(property) {
return function(/* fields, value */) {
return this.__setPropertyValue.apply(this, [property].concat(_.toArray(arguments)));
return function(fields, value) {
if (_.isUndefined(value)) {
value = fields;
fields = undefined;
}
return this.__setPropertyValue([property].concat(_.isString(fields) ? fields.split('.') : fields || []), value);;
};
},
is: function(property, alias) {
var propertyName = !_.isUndefined(alias) ? alias : property;
return {
name: 0 !== propertyName.indexOf('is') ? 'is' + propertyName[0].toUpperCase() + propertyName.slice(1) : propertyName,
body: function(/* fields, value */) {
return this.__isPropertyValue.apply(this, [property].concat(_.toArray(arguments)));
is: function(property) {
return function(fields, value) {
if (_.isUndefined(value)) {
value = fields;
fields = undefined;
}
return this.__isPropertyValue([property].concat(_.isString(fields) ? fields.split('.') : fields || []), value);
}
},
has: function(property) {
return function(/* fields */) {
return this.__hasPropertyValue.apply(this, [property].concat(_.toArray(arguments)));
return function(fields) {
return this.__hasPropertyValue([property].concat(_.isString(fields) ? fields.split('.') : fields || []));
}
},
clear: function(property) {
return function(/* fields */) {
return this.__clearPropertyValue.apply(this, [property].concat(_.toArray(arguments)));
return function(fields) {
return this.__clearPropertyValue([property].concat(_.isString(fields) ? fields.split('.') : fields || []));
};
},
remove: function(property) {
return function(/* fields */) {
return this.__removePropertyValue.apply(this , [property].concat(_.toArray(arguments)));
return function(fields) {
return this.__removePropertyValue([property].concat(_.isString(fields) ? fields.split('.') : fields || []));
}

@@ -99,0 +108,0 @@ }

@@ -5,11 +5,26 @@ meta('Type', {

SETTER_WEIGHT: -1000,
process: function(object, type, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME, function(value) {
return self.apply(value, type, property, object);
object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) {
var fieldsType = type || {};
for (var i = 0, ii = fields.length; i < ii; ++i) {
var params = fieldsType[1] || {};
if (!('element' in params)) {
return value;
}
fieldsType = params.element;
}
return self.apply(value, fieldsType, property, fields, object);
});
},
apply: function(value, type, property, object) {
apply: function(value, type, property, fields, object) {
if (_.isUndefined(value) || _.isNull(value)) {

@@ -29,3 +44,3 @@ return value;

return this._types[type].call(this, value, params, property, object);
return this._types[type].call(this, value, params, property, fields, object);
},

@@ -107,4 +122,3 @@

},
array: function(value, params, property) {
var i, ii, type;
array: function(value, params, property, fields, object) {

@@ -114,21 +128,21 @@ if (_.isString(value)) {

}
if ('element' in params) {
type = [].concat(params.element);
for (i = 0, ii = value.length; i < ii; ++i) {
value[i] = this.apply.call(this, value[i], type, property + '.' + i);
for (var i = 0, ii = value.length; i < ii; ++i) {
value[i] = this.apply(value[i], params.element, property, fields.concat(i), object);
}
}
return value;
},
hash: function(value, params, property) {
var key, type;
hash: function(value, params, property, fields, object) {
if (!_.isObject(value)) {
throw new Error('Value of property "' + property +'" must have object type!');
throw new Error('Value of property "' + [property].concat(fields).join('.') +'" must have object type!');
}
if ('keys' in params) {
for (key in value) {
if (!(key in params.keys)) {
throw new Error('Unsupported hash key "' + key + '" for property "' + property + '"!');
for (var key in value) {
if (-1 === params.keys.indexOf(key)) {
throw new Error('Unsupported hash key "' + key + '" for property "' + [property].concat(fields).join('.') + '"!');
}

@@ -138,5 +152,4 @@ }

if ('element' in params) {
type = [].concat(params.element);
for (key in value) {
value[key] = this.apply.call(this, value[key], type, property + '.' + key);
for (var key in value) {
value[key] = this.apply.call(this, value[key], params.element, property, fields.concat(key), object);
}

@@ -146,3 +159,3 @@ }

},
object: function(value, params, property, object) {
object: function(value, params, property, fields, object) {

@@ -149,0 +162,0 @@ if (!_.isObject(value)) {

@@ -87,4 +87,4 @@ var Factory = function(options) {

if (_.isFunction(this.__construct)) {
result = this.__construct.apply(this, _.toArray(arguments));
if (_.isFunction(self.__construct)) {
result = self.__construct.apply(this, _.toArray(arguments));
}

@@ -98,2 +98,11 @@ else if (self.__parent) {

}
for (var method in this) {
if (0 === method.indexOf('__init') && _.isFunction(this[method])) {
this[method]();
}
}
if (_.isFunction(this.init)) {
this.init.apply(this, _.toArray(arguments));
}
};

@@ -100,0 +109,0 @@ },

@@ -22,6 +22,2 @@ var Manager = function() {

if (!('__name' in processor)) {
processor.__name = name;
}
this._processors[name] = processor;

@@ -28,0 +24,0 @@ return this;

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc