{"_id":"classjs","_rev":"28-0d8928d7b651598d6f3b4ee6c685882c","name":"classjs","description":"Simple Class System for JavaScript","dist-tags":{"latest":"0.8.0"},"versions":{"0.1.0":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.1.0","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"lib":".","main":"class.js","readme":"class.js\n========\n\nSimple Class System for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n\n  * Inheritance\n  * Mixins\n  * Interfaces\n  * Properties\n    * getter / setter\n    * visibility\n  \t* type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex)\n  \t* format value\n    * validation\n    * init value\n    * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * __super__ - reference on super class\n  * Singleton\n  * Browser & commonJS support\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Usage\n\nBrowser:\n\n```html\n<script src=\"unsercore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\nvar Monkey = Class.define(EventEmitter, {\n\tproperties : {\n\t\t\"legs\" : {\n\t\t\ttype : \"Number\",\n\t\t\tinit : 4,\n\t\t\tvalidate : function(value, old) {\n\t\t\t\treturn value <= 4;\n\t\t\t},\n\t\t\tapply : \"_applyLegs\",\n\t\t\tevent : \"legsChanged\"\n\t\t},\n\n\t\thead : {\n\t\t\ttype : \"Object\",\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyLegs : function(value, old) {\n\t\t\tconsole.log(value, old);\n\t\t},\n\t\t\n\t\tjump : function() {\n\t\t\tconsole.log(\"jump\");\n\t\t}\n\t}\n});\n\nvar TwoLeggedMonkey = Monkey.extend({\n\tconstructor : function() {\n\t\tthis.__super__.apply(this, arguments);\n\t\tthis.setLegs(3, false); // Do not fire the event\n\t},\n\t\n\tjump : function() {\n\t\tthis.__super__.jump.apply(arguments);\n\t}\n});\n\nvar monkey = new TwoLeggedMonkey();\nmonkey.on(\"legsChanged\", function(data) {\n\tconsole.log(\"Legs changed to %i\", data.value);\n});\nmonkey.jump();\nmonkey.setLegs(2);\n```\n\n","_id":"classjs@0.1.0","dist":{"shasum":"19d0c4470fa4ccfa673b0245ec98ac5471f0e198","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.1.0.tgz","integrity":"sha512-wCMlD0AAD+3rLsoSRqICQhU88z4OyV4k+1s2gdjiS05iIQqVNZ1FB1gYdthz34Oy2wy8IjUANwLifZ8csfOkMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+QVANcbzLCXh9pLIMEliILX/8g1PCs5cEb1of3Ko7EAIgZ8Ch0Bb8/DeKA5EFZyGkES3wPalMqveY62BVBavTKuc="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.1.1":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.1.1","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple Class System for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n\n  * Inheritance\n  * Mixins\n  * Interfaces\n  * Properties\n    * getter / setter\n    * visibility\n  \t* type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex)\n  \t* format value\n    * validation\n    * init value\n    * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * __super__ - reference on super class\n  * Singleton\n  * Browser & commonJS support\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Usage\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\nvar Monkey = Class.define(EventEmitter, {\n\tproperties : {\n\t\t\"legs\" : {\n\t\t\ttype : \"Number\",\n\t\t\tinit : 4,\n\t\t\tvalidate : function(value, old) {\n\t\t\t\treturn value <= 4;\n\t\t\t},\n\t\t\tapply : \"_applyLegs\",\n\t\t\tevent : \"legsChanged\"\n\t\t},\n\n\t\thead : {\n\t\t\ttype : \"Object\",\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyLegs : function(value, old) {\n\t\t\tconsole.log(value, old);\n\t\t},\n\t\t\n\t\tjump : function() {\n\t\t\tconsole.log(\"jump\");\n\t\t}\n\t}\n});\n\nvar TwoLeggedMonkey = Monkey.extend({\n\tconstructor : function() {\n\t\tthis.__super__.apply(this, arguments);\n\t\tthis.setLegs(3, false); // Do not fire the event\n\t},\n\t\n\tjump : function() {\n\t\tthis.__super__.jump.apply(arguments);\n\t}\n});\n\nvar monkey = new TwoLeggedMonkey();\nmonkey.on(\"legsChanged\", function(data) {\n\tconsole.log(\"Legs changed to %i\", data.value);\n});\nmonkey.jump();\nmonkey.setLegs(2);\n```\n\n","_id":"classjs@0.1.1","dist":{"shasum":"cbf8d3d7d55690ef5c59aba4e6b94e26875428f8","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.1.1.tgz","integrity":"sha512-Sc5MpyIkhtGi9emOZikt3eJ7LMNu+lWJR/L++qbzhzQoAu/XZhpT/jhM9jFR2TVvdCY9dsq24cH4dzfNFwIMfw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHV2D8wGSEMqX4FL7JsUMOBP1e7mLxFA7gQCFUZ0u9+jAiAIeIoleRaL5MggwCUws2TDK0E84QuS9seicVeHnZn1dg=="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.2.0":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.2.0","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple Class System for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n\n  * Inheritance\n  * Mixins\n  * Interfaces\n  * Properties\n    * getter / setter\n    * visibility\n  \t* type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex)\n  \t* format value\n    * validation\n    * init value\n    * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * __super__ - reference on super class\n  * Singleton\n  * Browser & commonJS support\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Usage\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\nvar Monkey = Class.define(EventEmitter, {\n\tproperties : {\n\t\t\"legs\" : {\n\t\t\ttype : \"Number\",\n\t\t\tinit : 4,\n\t\t\tvalidate : function(value, old) {\n\t\t\t\treturn value <= 4;\n\t\t\t},\n\t\t\tapply : \"_applyLegs\",\n\t\t\tevent : \"legsChanged\"\n\t\t},\n\n\t\thead : {\n\t\t\ttype : \"Object\",\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyLegs : function(value, old) {\n\t\t\tconsole.log(value, old);\n\t\t},\n\t\t\n\t\tjump : function() {\n\t\t\tconsole.log(\"jump\");\n\t\t}\n\t}\n});\n\nvar TwoLeggedMonkey = Monkey.extend({\n\tconstructor : function() {\n\t\tthis.__super__.apply(this, arguments);\n\t\tthis.setLegs(3, false); // Do not fire the event\n\t},\n\t\n\tjump : function() {\n\t\tthis.__super__.jump.apply(arguments);\n\t}\n});\n\nvar monkey = new TwoLeggedMonkey();\nmonkey.on(\"legsChanged\", function(data) {\n\tconsole.log(\"Legs changed to %i\", data.value);\n});\nmonkey.jump();\nmonkey.setLegs(2);\n```\n\n","_id":"classjs@0.2.0","dist":{"shasum":"89847e7101313ee7e3d558193c4c993d510e1eb5","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.2.0.tgz","integrity":"sha512-R3w0aaEqBvUolOe65B1uqK/6hVgWtCwZ03C8nlDi5HMvPfwdWMEZXEfdIxmEQS7+MrZFd0bjpXGRvvdpGn4ZMw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCem3ZMoPcmq7HR4qhoTj4cbHYhqWyUj4YLiwz9U1BHuAIgDRjpTLBomHAw9FLzgWDH7fVZw6+0IPYR+7SQXSONYQ4="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.5.0":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.5.0","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (1.93KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference on super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n\tproperties : {\n\t\tactivated : \"Boolean\",\n\t\tname : {\n\t\t\ttype : \"String\",\n\t\t\tinit : \"No Name\",\n\t\t\tvalidate : function(value, old, prop) {\n\t\t\t\treturn value != \"foo\"; // alternative you can return a custom error message as a string\n\t\t\t},\n\t\t\tapply : \"_applyName\",\n\t\t\tevent : \"nameChanged\"\n\t\t},\n\t\tstreet : {\n\t\t\ttype : \"String\",\n\t\t\tformat : function(value, old, prop) {\n\t\t\t\treturn value.toUpperCase()\t\n\t\t\t},\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t},\n\t\tcity : {\n\t\t\ttype : \"String\",\n\t\t\tnullable : true\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyName : function(value, old, prop) {\n\t\t\tconsole.log(value, old, prop);\n\t\t},\n\t\t\n\t\taddEmploye : function(employe) {\n\t\t\tconsole.log(\"employe\");\n\t\t}\n\t}\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n\tnamespace : \"my.cool.Company\",\n\n\tconstructor : function() {\n\t\tCompany.apply(this, arguments);\n\t\tthis.setName(\"My Company\"); \n\t\tthis._setStreet(\"Some Street\", false);\n\t\tthis.setCity(null);\n\t},\n\t\n\t\n\tmembers : {\n\t\taddEmploye : function(employe) {\n\t\t\t// Call overridden method\n\t\t\tthis.__super__.addEmploye.apply(this, arguments);\n\t\t}\n\t}\n\t\n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n\tconsole.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n              \tset : true|false,\n                get : true|false,\n              \tnullable : true|false,\n                event : String\n            }\n    ...\t\n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nFor example you can override the default error handler for class.js:\n\n```js\n  Class.error = function(error) {\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    throw error;\n  }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n * 0.5 (2012/7/27, not published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n  * API & Feature freeze for 1.0\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## ToDo for 1.0\n\n * Split up plugins\n * use grunt","_id":"classjs@0.5.0","dist":{"shasum":"f251ea6aa562ef59e39acc2dcfe3602fb22fce5b","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.5.0.tgz","integrity":"sha512-H7/GJ4MiJsPWzzwDezE8s7XJjGRL3c6hrkPFZBKPw1uSPUX6Qs5h2BfF7+1I0aa47fqP2HpeogQG/6CmN22wmw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxnYzf0fGes9VoosIJbS31We9njdtTDqrRZFTdxA4iVQIgHyOwaPotUIDVFj/Nwrhb44PKOGc+JXPHgJ6jr6kzRvU="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.5.1":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.5.1","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (1.93KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference on super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n\tproperties : {\n\t\tactivated : \"Boolean\",\n\t\tname : {\n\t\t\ttype : \"String\",\n\t\t\tinit : \"No Name\",\n\t\t\tvalidate : function(value, old, prop) {\n\t\t\t\treturn value != \"foo\"; // alternative you can return a custom error message as a string\n\t\t\t},\n\t\t\tapply : \"_applyName\",\n\t\t\tevent : \"nameChanged\"\n\t\t},\n\t\tstreet : {\n\t\t\ttype : \"String\",\n\t\t\tformat : function(value, old, prop) {\n\t\t\t\treturn value.toUpperCase()\t\n\t\t\t},\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t},\n\t\tcity : {\n\t\t\ttype : \"String\",\n\t\t\tnullable : true\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyName : function(value, old, prop) {\n\t\t\tconsole.log(value, old, prop);\n\t\t},\n\t\t\n\t\taddEmploye : function(employe) {\n\t\t\tconsole.log(\"employe\");\n\t\t}\n\t}\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n\tnamespace : \"my.cool.Company\",\n\n\tconstructor : function() {\n\t\tCompany.apply(this, arguments);\n\t\tthis.setName(\"My Company\"); \n\t\tthis._setStreet(\"Some Street\", false);\n\t\tthis.setCity(null);\n\t},\n\t\n\t\n\tmembers : {\n\t\taddEmploye : function(employe) {\n\t\t\t// Call overridden method\n\t\t\tthis.__super__.addEmploye.apply(this, arguments);\n\t\t}\n\t}\n\t\n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n\tconsole.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n              \tset : true|false,\n                get : true|false,\n              \tnullable : true|false,\n                event : String\n            }\n    ...\t\n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nFor example you can override the default error handler for class.js:\n\n```js\n  Class.error = function(error) {\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    throw error;\n  }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n * 0.5 (2012/7/27, not published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n  * API & Feature freeze for 1.0\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## ToDo for 1.0\n\n * Split up plugins\n * use grunt","_id":"classjs@0.5.1","dist":{"shasum":"0f4a6ef98198ef5e92b5c6ddd7f18603f0286d7d","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.5.1.tgz","integrity":"sha512-QPB3zNfMHs8kkURCJwG1fnIYtMN2x9P6CK7cgVLLzuXUo/kU/dlrB0i0aXMYP5hzfJ3M7HsQyjJvKXKe+7dPmQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD5Z3yPzmMG/O7xH+ny7R57IJIk16IP4i2EhgctpICnpwIgdKXYJTxggVXw8MDOFphAUomHD2hxT0RmhVnxF5AQKeg="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.5.2":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.5.2","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"devDependencies":{"qunit":"*"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (1.95KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference on super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n\tproperties : {\n\t\tactivated : \"Boolean\",\n\t\tname : {\n\t\t\ttype : \"String\",\n\t\t\tinit : \"No Name\",\n\t\t\tvalidate : function(value, old, prop) {\n\t\t\t\treturn value != \"foo\"; // alternative you can return a custom error message as a string\n\t\t\t},\n\t\t\tapply : \"_applyName\",\n\t\t\tevent : \"nameChanged\"\n\t\t},\n\t\tstreet : {\n\t\t\ttype : \"String\",\n\t\t\tformat : function(value, old, prop) {\n\t\t\t\treturn value.toUpperCase()\t\n\t\t\t},\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t},\n\t\tcity : {\n\t\t\ttype : \"String\",\n\t\t\tnullable : true\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyName : function(value, old, prop) {\n\t\t\tconsole.log(value, old, prop);\n\t\t},\n\t\t\n\t\taddEmploye : function(employe) {\n\t\t\tconsole.log(\"employe\");\n\t\t}\n\t}\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n\tnamespace : \"my.cool.Company\",\n\n\tconstructor : function() {\n\t\tCompany.apply(this, arguments);\n\t\tthis.setName(\"My Company\"); \n\t\tthis._setStreet(\"Some Street\", false);\n\t\tthis.setCity(null);\n\t},\n\t\n\t\n\tmembers : {\n\t\taddEmploye : function(employe) {\n\t\t\t// Call overridden method\n\t\t\tthis.__super__.addEmploye.apply(this, arguments);\n\t\t}\n\t}\n\t\n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n\tconsole.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n              \tset : true|false,\n                get : true|false,\n              \tnullable : true|false,\n                event : String\n            }\n    ...\t\n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nFor example you can override the default error handler for class.js:\n\n```js\n  Class.error = function(error) {\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    throw error;\n  }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n\n * 0.5.2 (2012/7/27, published to npm)\n  * Added node tests\n * 0.5.1 (2012/7/27, published to npm)\n  * Node.js fixes\n * 0.5 (2012/7/27, published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n  * API & Feature freeze for 1.0\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## ToDo for 1.0\n\n * Split up plugins\n * use grunt","_id":"classjs@0.5.2","dist":{"shasum":"472aed7e333bd17c98b8df88850f11ee5bde4156","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.5.2.tgz","integrity":"sha512-gKBX2FW5Sohq8v3/78RICGQgJ+/Fm1tM3abn9QbxdYy04Ol36xxJAgcd/CLAqLG71Z8U9UuZvclQ26VosVFwrg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHatXlvaxIxKpvwfKAYs/GG8qsPwauEo8cuwjJ7tzYqpAiEA6ADfEy6cr6iT/UwaB4BosLBwvm+VjE5/bs6x4103y8k="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.6.0":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.6.0","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"devDependencies":{"qunit":"*"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (1.98KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference on super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Tests & Custom Builds\n\nclass.js is using grunt (https://github.com/cowboy/grunt) to build the modules and to run the tests.\nIf you would like to create a custom build of class.js or develop a feature, please follow these steps:\n\nTo install Grunt run the follwing command (npm (http://npmjs.org/) needed):\n \n```\nnpm install -g grunt\n```\n\nTest & Build the project, run:\n```\ngrunt\n```\n\nAutomatically build project whenever a lib/*.js file is changed:\n```\ngrunt watch\n```\n\nRun tests only:\n```\ngrunt qunit\n```\n\nThe tests are located in the ```test``` folder. With the index*.html files you can run the tests manually in any browser you want.\n\n\n## Example\n\n\n```js\n\nvar ICompany = {\n  addEmploye : function(employe) {\n    // Check passed arguments\n    if (Array.prototype.slice.call(arguments).length != 1) {\n      throw new Error(\"Wrong length of arguments\");\n    }\n    if (typeof employe !== \"object\") {\n      throw new Error(\"Wrong type for argument employe\");\n    }\n  }\n};\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n  interfaces : [ICompany],\n\tproperties : {\n\t\tactivated : \"Boolean\",\n\t\tname : {\n\t\t\ttype : \"String\",\n\t\t\tinit : \"No Name\",\n\t\t\tvalidate : function(value, old, prop) {\n\t\t\t\treturn value != \"foo\"; // alternative you can return a custom error message as a string\n\t\t\t},\n\t\t\tapply : \"_applyName\",\n\t\t\tevent : \"nameChanged\"\n\t\t},\n\t\tstreet : {\n\t\t\ttype : \"String\",\n\t\t\tformat : function(value, old, prop) {\n\t\t\t\treturn value.toUpperCase()\t\n\t\t\t},\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t},\n\t\tcity : {\n\t\t\ttype : \"String\",\n\t\t\tnullable : true\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyName : function(value, old, prop) {\n\t\t\tconsole.log(value, old, prop);\n\t\t},\n\t\t\n\t\taddEmploye : function(employe) {\n\t\t\tconsole.log(\"employe\");\n\t\t}\n\t}\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n\tnamespace : \"my.cool.Company\",\n\n\tconstructor : function() {\n\t\tCompany.apply(this, arguments);\n\t\tthis.setName(\"My Company\"); \n\t\tthis._setStreet(\"Some Street\", false);\n\t\tthis.setCity(null);\n\t},\n\t\n\t\n\tmembers : {\n\t\taddEmploye : function(employe) {\n\t\t\t// Call overridden method\n\t\t\tthis.__super__.addEmploye.apply(this, arguments);\n\t\t}\n\t}\n\t\n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n\tconsole.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n              \tset : true|false,\n                get : true|false,\n              \tnullable : true|false,\n                event : String\n            }\n    ...\t\n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\n________________________________________________________________________________________________________________________\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nFor example you can override the default error handler for class.js:\n\n```js\n  Class.error = function(error) {\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    throw error;\n  }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n\n * 0.6\n  * Splitted up files\n  * Use grunt to build project\n  * Interfaces can now have parameter checks\n  * API & Feature freeze for 1.0\n * 0.5.2 (2012/7/27, published to npm)\n  * Added node tests\n * 0.5.1 (2012/7/27, published to npm)\n  * Node.js fixes\n * 0.5 (2012/7/27, published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## Contribute\n\n * If you have a feature request or an issue please report it here: https://github.com/tjbutz/class.js/issues\n * If you have developed a plugin for class.js please let me know. I will list the plugin on this page.\n\n## ToDo for 1.0\n\n * Split up plugins\n * use grunt","_id":"classjs@0.6.0","dist":{"shasum":"d02c26e1490ab302279c3f5659afff954796ec87","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.6.0.tgz","integrity":"sha512-Mk9Z4lh2MCaCno53Qa2uJXbVNDXDLLuB1KDdILoQfAeVNGcUW58YRKnn3lTGpO+FvuYVG6itz95+1xNNXhkTuw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC8i9BTThQqI3cupyiM6/2Db+HrfPiQD9s4rSx2cKBVOQIgK2XNKl0+WAtkPSoVtojnVylFJD6dlMISIv+KjRbSod0="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.6.1":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.6.1","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"devDependencies":{"qunit":"*"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (1.98KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference to super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\n\nvar ICompany = {\n  addEmploye : function(employe) {\n    // Check passed arguments\n    if (Array.prototype.slice.call(arguments).length != 1) {\n      throw new Error(\"Wrong length of arguments\");\n    }\n    if (typeof employe !== \"object\") {\n      throw new Error(\"Wrong type for argument employe\");\n    }\n  }\n};\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n  interfaces : [ICompany],\n\tproperties : {\n\t\tactivated : \"Boolean\",\n\t\tname : {\n\t\t\ttype : \"String\",\n\t\t\tinit : \"No Name\",\n\t\t\tvalidate : function(value, old, prop) {\n\t\t\t\treturn value != \"foo\"; // alternative you can return a custom error message as a string\n\t\t\t},\n\t\t\tapply : \"_applyName\",\n\t\t\tevent : \"nameChanged\"\n\t\t},\n\t\tstreet : {\n\t\t\ttype : \"String\",\n\t\t\tformat : function(value, old, prop) {\n\t\t\t\treturn value.toUpperCase()\t\n\t\t\t},\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t},\n\t\tcity : {\n\t\t\ttype : \"String\",\n\t\t\tnullable : true\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyName : function(value, old, prop) {\n\t\t\tconsole.log(value, old, prop);\n\t\t},\n\t\t\n\t\taddEmploye : function(employe) {\n\t\t\tconsole.log(\"employe\");\n\t\t}\n\t}\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n\tnamespace : \"my.cool.Company\",\n\n\tconstructor : function() {\n\t\tCompany.apply(this, arguments);\n\t\tthis.setName(\"My Company\"); \n\t\tthis._setStreet(\"Some Street\", false);\n\t\tthis.setCity(null);\n\t},\n\t\n\t\n\tmembers : {\n\t\taddEmploye : function(employe) {\n\t\t\t// Call overridden method\n\t\t\tthis.__super__.addEmploye.apply(this, arguments);\n\t\t}\n\t}\n\t\n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n\tconsole.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## Tests & Custom Builds\n\nclass.js is using grunt (https://github.com/cowboy/grunt) to build the modules and to run the tests.\nIf you would like to create a custom build of class.js or develop a feature, please follow these steps:\n\nTo install Grunt run the follwing command (npm (http://npmjs.org/) needed):\n \n```\nnpm install -g grunt\n```\n\nTest & Build the project, run:\n```\ngrunt\n```\n\nAutomatically build project whenever a lib/*.js file is changed:\n```\ngrunt watch\n```\n\nRun tests only:\n```\ngrunt qunit\n```\n\nThe tests are located in the ```test``` folder. With the index*.html files you can run the tests manually in any browser you want.\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n              \tset : true|false,\n                get : true|false,\n              \tnullable : true|false,\n                event : String\n            }\n    ...\t\n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\n________________________________________________________________________________________________________________________\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nFor example you can override the default error handler for class.js:\n\n```js\n  Class.error = function(error) {\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    throw error;\n  }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n\n * 0.6.1 (2012/7/29, not yet released)\n  * Improved ECMA5 property support\n  * Do not set the same value for a property twice\n  * Removed Class.error handling from property system\n  * Bugfixes\n * 0.6 (2012/7/28, published to npm)\n  * Splitted up files\n  * Use grunt to build project\n  * Interfaces can now have parameter checks\n * 0.5.2 (2012/7/27, published to npm)\n  * Added node tests\n * 0.5.1 (2012/7/27, published to npm)\n  * Node.js fixes\n * 0.5 (2012/7/27, published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## Contribute\n\n * If you have a feature request or an issue please report it here: https://github.com/tjbutz/class.js/issues\n * If you have developed a plugin for class.js please let me know. I will list the plugin on this page.\n * If you use class.js in your project please let me know. I will list the project on this page.\n\n## ToDo for 1.0\n\n * Examples","_id":"classjs@0.6.1","dist":{"shasum":"ad4a190c5abdb50dcf2142141627ce68358c55cf","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.6.1.tgz","integrity":"sha512-nI68Dp0D+BkSdBlV+9EDT9Bkq2GFTXquzWH++W2pw3+UPVdO0lDIctUYIBLrqZK2Q0R3rdsr6WVuCvPznVlxJg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBe4ZDvtGKu/eWb/kmgPvBw8lQFcmoYYP1OUPu2Av9i9AiEAxh271/HzGg8iyHsdM9NF/xonYNxIBEcIxXm0Gc+7vCs="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.6.2":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.6.2","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"devDependencies":{"qunit":"*"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (1.98KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference to super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, Date, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\n\nvar ICompany = {\n  addEmploye : function(employe) {\n    // Check passed arguments\n    if (Array.prototype.slice.call(arguments).length != 1) {\n      throw new Error(\"Wrong length of arguments\");\n    }\n    if (typeof employe !== \"object\") {\n      throw new Error(\"Wrong type for argument employe\");\n    }\n  }\n};\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n  interfaces : [ICompany],\n\tproperties : {\n\t\tactivated : \"Boolean\",\n\t\tname : {\n\t\t\ttype : \"String\",\n\t\t\tinit : \"No Name\",\n\t\t\tvalidate : function(value, old, prop) {\n\t\t\t\treturn value != \"foo\"; // alternative you can return a custom error message as a string\n\t\t\t},\n\t\t\tapply : \"_applyName\",\n\t\t\tevent : \"nameChanged\"\n\t\t},\n\t\tstreet : {\n\t\t\ttype : \"String\",\n\t\t\tformat : function(value, old, prop) {\n\t\t\t\treturn value.toUpperCase()\t\n\t\t\t},\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t},\n\t\tcity : {\n\t\t\ttype : \"String\",\n\t\t\tnullable : true\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyName : function(value, old, prop) {\n\t\t\tconsole.log(value, old, prop);\n\t\t},\n\t\t\n\t\taddEmploye : function(employe) {\n\t\t\tconsole.log(\"employe\");\n\t\t}\n\t}\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n\tnamespace : \"my.cool.Company\",\n\n\tconstructor : function() {\n\t\tCompany.apply(this, arguments);\n\t\tthis.setName(\"My Company\"); \n\t\tthis._setStreet(\"Some Street\", false);\n\t\tthis.setCity(null);\n\t},\n\t\n\t\n\tmembers : {\n\t\taddEmploye : function(employe) {\n\t\t\t// Call overridden method\n\t\t\tthis.__super__.addEmploye.apply(this, arguments);\n\t\t}\n\t}\n\t\n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n\tconsole.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## Tests & Custom Builds\n\nclass.js is using grunt (https://github.com/cowboy/grunt) to build the modules and to run the tests.\nIf you would like to create a custom build of class.js or develop a feature, please follow these steps:\n\nTo install Grunt run the follwing command (npm (http://npmjs.org/) needed):\n \n```\nnpm install -g grunt\n```\n\nTest & Build the project, run:\n```\ngrunt\n```\n\nAutomatically build project whenever a lib/*.js file is changed:\n```\ngrunt watch\n```\n\nRun tests only:\n```\ngrunt qunit\n```\n\nThe tests are located in the ```test``` folder. With the index*.html files you can run the tests manually in any browser you want.\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex|Date\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n              \tset : true|false,\n                get : true|false,\n              \tnullable : true|false,\n                event : String\n            }\n    ...\t\n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\n________________________________________________________________________________________________________________________\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nIn your error handler you can check for the type:\n\n```js\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n\n * 0.6.2 (2012/8/5, published to npm)\n  * Added \"Date\" type to properties\n  * Refactoring\n * 0.6.1 (2012/7/29, published to npm)\n  * Improved ECMA5 property support\n  * Do not set the same value for a property twice\n  * Removed Class.error handling from property system\n  * Bugfixes\n * 0.6 (2012/7/28, published to npm)\n  * Splitted up files\n  * Use grunt to build project\n  * Interfaces can now have parameter checks\n * 0.5.2 (2012/7/27, published to npm)\n  * Added node tests\n * 0.5.1 (2012/7/27, published to npm)\n  * Node.js fixes\n * 0.5 (2012/7/27, published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## Contribute\n\n * If you have a feature request or an issue please report it here: https://github.com/tjbutz/class.js/issues\n * If you have developed a plugin for class.js please let me know. I will list the plugin on this page.\n * If you use class.js in your project please let me know. I will list the project on this page.\n\n## ToDo for 1.0\n\n * Examples","_id":"classjs@0.6.2","dist":{"shasum":"fb7d4f88315799d982b3a5d231af64e926cadc90","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.6.2.tgz","integrity":"sha512-aJwww5xqGWxJJmshNkZDCNKe38VHGCx7axc925x9Z+m9o4xZ2lB8UGEqBfLeU2XcWzgfYhmQabp/Dnj1BjNPHQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD0/Wq4Vti76gkpH7Czl1VlvMQFpC4S+m1/YTHRmuFNPAIgK1b3YQkyeshzSsUOj4Ef2S5jcrJnTODD5Z9Goduvd/8="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.7.0":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.7.0","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance","backbone"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"devDependencies":{"qunit":"*"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (2KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference to super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, Date, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\nvar Class = require('classjs');\nvar EventEmitter = require(\"events\").EventEmitter;\n\nvar ICompany = {\n  addEmploye : function(employe) {\n    // Check passed arguments\n    if (Array.prototype.slice.call(arguments).length != 1) {\n      throw new Error(\"Wrong length of arguments\");\n    }\n    if (typeof employe !== \"object\") {\n      throw new Error(\"Wrong type for argument employe\");\n    }\n  }\n};\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n  interfaces : [ICompany],\n  properties : {\n    activated : \"Boolean\",\n    name : {\n      type : \"String\",\n      init : \"No Name\",\n      validate : function(value, old, prop) {\n        return value != \"foo\"; // alternative you can return a custom error message as a string\n      },\n      apply : \"_applyName\",\n      event : \"nameChanged\"\n    },\n    street : {\n      type : \"String\",\n      format : function(value, old, prop) {\n        return value.toUpperCase()  \n      },\n      get : false, // generate only private getter / setter\n      set : false\n    },\n    city : {\n      type : \"String\",\n      nullable : true\n    }\n  },\n\n  members : {\n    _applyName : function(value, old, prop) {\n      console.log(\"Apply name method called with value: %s | old value: %s | property: %s\", value, old, prop);\n    },\n    \n    addEmploye : function(employe) {\n      console.log(\"Base method 'addEmploye' called: \", employe);\n    }\n  }\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n  namespace : \"my.cool.Company\",\n\n  constructor : function() {\n    this.__super__.apply(this, arguments);\n    this.setName(\"My Company\"); \n    this._setStreet(\"Some Street\", false);\n    this.setCity(null);\n  },\n  \n  \n  members : {\n    addEmploye : function(employe) {\n      // Call overridden method\n      this.__super__.addEmploye.apply(this, arguments);\n      console.log(\"Overridden method 'addEmploye' called: \", employe);\n    }\n  }\n  \n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n  console.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## Tests & Custom Builds\n\nclass.js is using grunt (https://github.com/cowboy/grunt) to build the modules and to run the tests.\nIf you would like to create a custom build of class.js or develop a feature, please follow these steps:\n\nTo install Grunt run the follwing command (npm (http://npmjs.org/) needed):\n \n```\nnpm install -g grunt\n```\n\nTest & Build the project, run:\n```\ngrunt\n```\n\nAutomatically build project whenever a lib/*.js file is changed:\n```\ngrunt watch\n```\n\nRun tests only:\n```\ngrunt qunit\n```\n\nThe tests are located in the ```test``` folder. With the index*.html files you can run the tests manually in any browser you want.\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex|Date\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n                set : true|false,\n                get : true|false,\n                nullable : true|false,\n                event : String\n            }\n    ... \n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\n________________________________________________________________________________________________________________________\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nIn your error handler you can check for the type:\n\n```js\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n\n * 0.7.0 (2012/8/26, published to npm)\n  * Enhanced __super__ functionality \n  * Bugfixes\n * 0.6.2 (2012/8/5, published to npm)\n  * Added \"Date\" type to properties\n  * Refactoring\n * 0.6.1 (2012/7/29, published to npm)\n  * Improved ECMA5 property support\n  * Do not set the same value for a property twice\n  * Removed Class.error handling from property system\n  * Bugfixes\n * 0.6 (2012/7/28, published to npm)\n  * Splitted up files\n  * Use grunt to build project\n  * Interfaces can now have parameter checks\n * 0.5.2 (2012/7/27, published to npm)\n  * Added node tests\n * 0.5.1 (2012/7/27, published to npm)\n  * Node.js fixes\n * 0.5 (2012/7/27, published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## Contribute\n\n * If you have a feature request or an issue please report it here: https://github.com/tjbutz/class.js/issues\n * If you have developed a plugin for class.js please let me know. I will list the plugin on this page.\n * If you use class.js in your project please let me know. I will list the project on this page.\n\n## ToDo for 1.0\n\n * Examples","_id":"classjs@0.7.0","dist":{"shasum":"689f1a970bc23bcd455f16ccb4833b152f2387c2","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.7.0.tgz","integrity":"sha512-ZxGSZo7iCCGVKOIuSB9gQg1JBtNXRXnD2b4qh0p9NfnUwODSNrJkFM+4U/LA3ApRhl3PjaCDsU830D8MDl9jzg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB58pW4rnU3IWu3Jn7kMKMNzlMuNaWChYYtEhlovb2A8AiEAwvL+o3KBD7Xap9sAcoceLhAvjgkEW3WCowPXn9W+bQs="}]},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.7.1":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.7.1","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance","backbone"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"devDependencies":{"qunit":"*"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (2KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference to super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, Date, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\nvar Class = require('classjs');\nvar EventEmitter = require(\"events\").EventEmitter;\n\nvar ICompany = {\n  addEmploye : function(employe) {\n    // Check passed arguments\n    if (Array.prototype.slice.call(arguments).length != 1) {\n      throw new Error(\"Wrong length of arguments\");\n    }\n    if (typeof employe !== \"object\") {\n      throw new Error(\"Wrong type for argument employe\");\n    }\n  }\n};\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n  interfaces : [ICompany],\n  properties : {\n    activated : \"Boolean\",\n    name : {\n      type : \"String\",\n      init : \"No Name\",\n      validate : function(value, old, prop) {\n        return value != \"foo\"; // alternative you can return a custom error message as a string\n      },\n      apply : \"_applyName\",\n      event : \"nameChanged\"\n    },\n    street : {\n      type : \"String\",\n      format : function(value, old, prop) {\n        return value.toUpperCase()  \n      },\n      get : false, // generate only private getter / setter\n      set : false\n    },\n    city : {\n      type : \"String\",\n      nullable : true\n    }\n  },\n\n  members : {\n    _applyName : function(value, old, prop) {\n      console.log(\"Apply name method called with value: %s | old value: %s | property: %s\", value, old, prop);\n    },\n    \n    addEmploye : function(employe) {\n      console.log(\"Base method 'addEmploye' called: \", employe);\n    }\n  }\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n  namespace : \"my.cool.Company\",\n\n  constructor : function() {\n    this.__super__.apply(this, arguments);\n    this.setName(\"My Company\"); \n    this._setStreet(\"Some Street\", false);\n    this.setCity(null);\n  },\n  \n  \n  members : {\n    addEmploye : function(employe) {\n      // Call overridden method\n      this.__super__.addEmploye.apply(this, arguments);\n      console.log(\"Overridden method 'addEmploye' called: \", employe);\n    }\n  }\n  \n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n  console.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## Tests & Custom Builds\n\nclass.js is using grunt (https://github.com/cowboy/grunt) to build the modules and to run the tests.\nIf you would like to create a custom build of class.js or develop a feature, please follow these steps:\n\nTo install Grunt run the follwing command (npm (http://npmjs.org/) needed):\n \n```\nnpm install -g grunt\n```\n\nTest & Build the project, run:\n```\ngrunt\n```\n\nAutomatically build project whenever a lib/*.js file is changed:\n```\ngrunt watch\n```\n\nRun tests only:\n```\ngrunt qunit\n```\n\nThe tests are located in the ```test``` folder. With the index*.html files you can run the tests manually in any browser you want.\n\n## API\n\n```js\nClass.define(superClass, definition)\n```\n\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex|Date\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n                set : true|false,\n                get : true|false,\n                nullable : true|false,\n                event : String\n            }\n    ... \n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(definition)\n```\n\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\n________________________________________________________________________________________________________________________\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nIn your error handler you can check for the type:\n\n```js\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n\n * 0.7.1 (2012/12/19, not published to npm)\n  * Fixed constructor after inheritance\n * 0.7.0 (2012/8/26, published to npm)\n  * Enhanced ```__super__``` functionality\n  * node.js example\n  * Bugfixes\n * 0.6.2 (2012/8/5, published to npm)\n  * Added \"Date\" type to properties\n  * Refactoring\n * 0.6.1 (2012/7/29, published to npm)\n  * Improved ECMA5 property support\n  * Do not set the same value for a property twice\n  * Removed Class.error handling from property system\n  * Bugfixes\n * 0.6 (2012/7/28, published to npm)\n  * Splitted up files\n  * Use grunt to build project\n  * Interfaces can now have parameter checks\n * 0.5.2 (2012/7/27, published to npm)\n  * Added node tests\n * 0.5.1 (2012/7/27, published to npm)\n  * Node.js fixes\n * 0.5 (2012/7/27, published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## Contribute\n\n * If you have a feature request or an issue please report it here: https://github.com/tjbutz/class.js/issues\n * If you have developed a plugin for class.js please let me know. I will list the plugin on this page.\n * If you use class.js in your project please let me know. I will list the project on this page.","readmeFilename":"README.md","_id":"classjs@0.7.1","dist":{"shasum":"a99811f427a374dbc276a910f081019196b0b0e1","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.7.1.tgz","integrity":"sha512-n8RB6vDCXUkZlli3Y90PoBe7mLwES15/c/ludU4MC9wrI7CDDL8Nn35kH60fR7bpYygA55QGy9o6K67Dt/F0MA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCSR+V/htFHquX6cr8KanVgVfSW+LW52+9JC3uAwGjmFwIhAM/5g31m7rSzNKl4w6WhOy3GRedH3ovBmoObPbcxDcQY"}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"tjbutz","email":"tinobutz@gmail.com"},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]},"0.8.0":{"name":"classjs","description":"Simple Class System for JavaScript","version":"0.8.0","author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"url":"https://github.com/tjbutz/class.js","keywords":["util","server","client","browser","class","inheritance","backbone"],"contributors":[],"dependencies":{"underscore":">=1.3.1"},"devDependencies":{"qunit":"*"},"lib":".","repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"licenses":[{"type":"MIT","url":"https://github.com/tjbutz/class.js/blob/master/LICENSE"}],"bugs":{"url":"https://github.com/tjbutz/class.js/issues"},"main":"class.js","readme":"class.js\n========\n\nSimple (2KB minified & gzipped & all features) class system for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n  * Core:\n    * Inheritance \n    * ```__super__``` - reference to super class\n  * Plugins:\n    * Mixins\n    * Interfaces\n    * Singleton\n    * Namespaces\n    * Properties\n      * getter / setter (Optional:Support for ECMA5 getter / setter)\n      * visibility\n      * type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex, Date, more can be added)\n      * format value\n      * validation\n      * init value,\n      * nullable\n      * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * Extensible: Add your own definition keys and types\n  * Browser & commonJS support\n  * Well tested\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Installation\n\nBrowser:\n\n```html\n<script src=\"underscore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\nvar Class = require('classjs');\nvar EventEmitter = require(\"events\").EventEmitter;\n\nvar ICompany = {\n  addEmploye : function(employe) {\n    // Check passed arguments\n    if (Array.prototype.slice.call(arguments).length != 1) {\n      throw new Error(\"Wrong length of arguments\");\n    }\n    if (typeof employe !== \"object\") {\n      throw new Error(\"Wrong type for argument employe\");\n    }\n  }\n};\n\n// Define a new class. Extend from EventEmitter.\nvar Company = Class.define(EventEmitter, {\n  interfaces : [ICompany],\n  properties : {\n    activated : \"Boolean\",\n    name : {\n      type : \"String\",\n      init : \"No Name\",\n      validate : function(value, old, prop) {\n        return value != \"foo\"; // alternative you can return a custom error message as a string\n      },\n      apply : \"_applyName\",\n      event : \"nameChanged\"\n    },\n    street : {\n      type : \"String\",\n      format : function(value, old, prop) {\n        return value.toUpperCase()  \n      },\n      get : false, // generate only private getter / setter\n      set : false\n    },\n    city : {\n      type : \"String\",\n      nullable : true\n    }\n  },\n\n  members : {\n    _applyName : function(value, old, prop) {\n      console.log(\"Apply name method called with value: %s | old value: %s | property: %s\", value, old, prop);\n    },\n    \n    addEmploye : function(employe) {\n      console.log(\"Base method 'addEmploye' called: \", employe);\n    }\n  }\n});\n\n// Extend from \"Company\"\nvar MyCompany = Company.extend({\n  namespace : \"my.cool.Company\",\n\n  constructor : function() {\n    this.__super__.apply(this, arguments);\n    this.setName(\"My Company\"); \n    this._setStreet(\"Some Street\", false);\n    this.setCity(null);\n  },\n  \n  \n  members : {\n    addEmploye : function(employe) {\n      // Call overridden method\n      this.__super__.addEmploye.apply(this, arguments);\n      console.log(\"Overridden method 'addEmploye' called: \", employe);\n    }\n  }\n  \n});\n\nvar company = new MyCompany();\ncompany.on(\"nameChanged\", function(data) {\n  console.log(\"Name changed to %s\", data.value);\n});\ncompany.addEmploye({name:\"Lena\"});\ncompany.setName(\"My new Company\");\n```\n\n## Tests & Custom Builds\n\nclass.js is using grunt (https://github.com/cowboy/grunt) to build the modules and to run the tests.\nIf you would like to create a custom build of class.js or develop a feature, please follow these steps:\n\nTo install Grunt run the follwing command (npm (http://npmjs.org/) needed):\n \n```\nnpm install -g grunt\n```\n\nTest & Build the project, run:\n```\ngrunt\n```\n\nAutomatically build project whenever a lib/*.js file is changed:\n```\ngrunt watch\n```\n\nRun tests only:\n```\ngrunt qunit\n```\n\nThe tests are located in the ```test``` folder. With the index*.html files you can run the tests manually in any browser you want.\n\n## API\n\n```js\nClass.define(name, superClass, definition)\n```\n\n  * name: The name of the class (optional)\n  * superClass: Class (optional)\n  * definition: Object (optional)\n\nDefines a new class.\n\n```js\n\nClass.define(name, superClass, {\n  namespace : String,\n\n  singleton : true|false,\n\n  mixins : [Object|Class],\n\n  interfaces : [Object|Class],\n  \n  constructor : Function, // Optional. Super constructor is called implicit when not available\n\n  properties : {\n    prop1 : \"Number|Boolean|String|Object|Function|Array|Element|Regex\" | Class, // Simple property definition\n    prop2 : {\n                type : \"Number|Boolean|String|Object|Function|Array|Element|Regex|Date\" | Class, // Complex property definition\n                init : Mixed\n                format : \"Function\" | Function,\n                validate : \"Function\" | Function | [\"Function\"|Function],\n                apply : \"Function\" | Function,\n                set : true|false,\n                get : true|false,\n                nullable : true|false,\n                event : String\n            }\n    ... \n  },\n  \n\n\n  statics : {\n    static1 : Function,\n    static2 : Function,\n    ...\n  },\n  \n  members : {\n    member1 : Function\n    member2 : Function\n    ...\n  }\n});\n```\n\n________________________________________________________________________________________________________________________\n\n```js\nSomeClass.extend(name, definition)\n```\n\n  * name: The name of the class (optional)\n  * definition: Object (optional) (see Class.extend for more details)\n\nThe ```extend``` method is added automatically to every created Class. Extends from the given class.\n\n```js\n\n  var MyClass = Class.define();\n  var SomeClass = MyClass.extend();\n  var obj = new SomeClass();\n\n```\n\n## Advanced\n\nSometimes it can be usefull not to use the full feature set of class.js. You can use the methods that are used for the class definitions standalone as well:\n\n```js\nClass.singleton(clazz, setSingleton)\nClass.mixins(clazz, mixins)\nClass.interfaces(clazz, interfaces)\nClass.properties(clazz, properties)\nClass.statics(clazz, statics)\nClass.members(clazz, members)\nClass.namespace(namespace, clazz)\n```   \n________________________________________________________________________________________________________________________\n\nExtending types\n\n```js\nClass.types (provided by properties plugin)\n```\n\nFor example:\n\n```js\nClass.types[\"MyType\"] = function(value) {\n  return value instanceof MyType;\n}\n```\n________________________________________________________________________________________________________________________\n\nExtending definition\n\n```js\nClass.definition\n```\n\nFor example:\n\n```js\nClass.definition.push(\"mykey\");\nClass.mykey = function(clazz, definition) {\n  for (var key in definition) {\n    clazz.prototype[key] = function() {\n      alert(\"My New Extension\");\n    }\n  }\n}\n```\n________________________________________________________________________________________________________________________\n\nClass define hooks\n\n```js\nClass.onBeforeClassDefine\nClass.onAfterClassDefine \n```\n\nFor example:\n\n```js\nClass.onBeforeClassDefine = function() {\n  console.log(\"Before Class Define called\");\n };\n\nClass.onAfterClassDefine = function() {\n  console.log(\"After Class Define called\");\n};\n```\n\nBefore instantiation hooks\n\n```js\nClass.onBeforeInstantiation\nClass.onAfterInstantiation \n```\n\n________________________________________________________________________________________________________________________\n\nFor example:\n\n```js\nClass.onBeforeInstantiation = function() {\n  console.log(\"Before object is instantiated\");\n};\n\nClass.onAfterInstantiation = function() {\n  console.log(\"After object is instantiated\");\n};\n```\n\n________________________________________________________________________________________________________________________\n\nECMA5 Getter / Setter\n\nWhen ECMA5 Mode is activated instead of setProp / getProp methods, ECMA5 getter and setter are generated. This can be used\nlike normal JavaScript properties, but will check for types / validate / format / etc.\n\n```js\nClass.ECMA5;\n```\n\nFor example:\n\n```js\nClass.ECMA5 = true;\n\nvar MyClass = Class.define({\n  properties : {\n    foo : \"Boolean\"\n    bar : \"Number\"      \n  }\n});\n\n\nvar obj = new MyClass();\nobj.bar = 1 // no setBar(1) needed\nvar bar = obj.bar; // no getBar() needed\nobj.foo = \"string\" // will throw an exception\n```\n________________________________________________________________________________________________________________________\n\nError Types\n\n```js\nClass.ValidationError\nClass.TypeError // extends from validation error\n```\n\nIn your error handler you can check for the type:\n\n```js\n    if (error instanceof Class.TypeError) {\n      console.log(error.message);\n      console.log(error.type);\n      console.log(error.value);\n      console.log(error.property);\n    }\n\n    if (error instanceof Class.ValidationError) {\n      console.log(error.message);\n      console.log(error.value);\n      console.log(error.property);\n    }\n```\n\nor use it for validation: \n\n\n```js\n\n  var MyClass = Class.define({\n    properties : {\n      foo : \"Boolean\"\n      bar : \"Number\"      \n    }\n  });\n\n  var data = {\n    foo : true,\n    bar : \"Some String\"\n  };\n  \n  var obj = new MyClass();\n  var errors = [];\n\n  var validate = function(property, value) {\n    errors = [];\n    for (var property in data) {\n      try {\n        obj.set(property, data[value]);  \n      } catch (exc) {\n        errors.push(exc);\n      }\n    }\n    return errors.length === 0;\n  }\n\n  for (var property in data) {\n    validate(property, data[property])\n  }\n\n  if (validate(data)) {\n    console.log(\"Validation OK. Submit form\");\n  } else {\n    console.log(\"Errors\", errors);\n  }\n```\n\n## Version History\n\n * 0.8.0 (2013/11/23, published to npm)\n  * Named Classes\n  * Namespace can now have a different context\n * 0.7.1 (2012/12/19, published to npm)\n  * Fixed constructor after inheritance\n * 0.7.0 (2012/8/26, published to npm)\n  * Enhanced ```__super__``` functionality\n  * node.js example\n  * Bugfixes\n * 0.6.2 (2012/8/5, published to npm)\n  * Added \"Date\" type to properties\n  * Refactoring\n * 0.6.1 (2012/7/29, published to npm)\n  * Improved ECMA5 property support\n  * Do not set the same value for a property twice\n  * Removed Class.error handling from property system\n  * Bugfixes\n * 0.6 (2012/7/28, published to npm)\n  * Splitted up files\n  * Use grunt to build project\n  * Interfaces can now have parameter checks\n * 0.5.2 (2012/7/27, published to npm)\n  * Added node tests\n * 0.5.1 (2012/7/27, published to npm)\n  * Node.js fixes\n * 0.5 (2012/7/27, published to npm)\n  * Added ECMA5 getter/setter\n  * API stabilization / changes\n  * Removed \"notfire\" event parameter from property setter\n * 0.4 (2012/7/27, not published to npm)\n  * Improved plugin system\n  * Added strict mode\n  * API stabilization / changes\n    * Removed instanceOf method\n    * Class.definition is now an array to ensure order of execution\n  * Before / After Class definition hooks\n  * Before / After instantiation hooks\n  * Bugfixes\n  * More tests\n * 0.3 (2012/7/27, not published to npm)\n  * Plugin system\n  * QUnit tests\n  * Namespaces\n  * Bugfixes\n  * Validation can be an array of validators\n  * Simple properties (prop:type) now possible\n  * Valiator & Formater can now be a member function\n  * More documentation\n * 0.2 (2012/7/26)\n  * Bugfixes\n  * API stabilization\n  * Documentation\n * 0.1.1 (2012/7/26)\n  * Minor Bugfixes\n  * Docu\n * 0.1 (2012/7/26)\n  * Inital release\n\n## Contribute\n\n * If you have a feature request or an issue please report it here: https://github.com/tjbutz/class.js/issues\n * If you have developed a plugin for class.js please let me know. I will list the plugin on this page.\n * If you use class.js in your project please let me know. I will list the project on this page.","readmeFilename":"README.md","_id":"classjs@0.8.0","dist":{"shasum":"da2f038c6467a04ddfd27160ef3822411bdc2d8e","tarball":"https://registry.npmjs.org/classjs/-/classjs-0.8.0.tgz","integrity":"sha512-6j+RHQ9Krdqfk7bMJ2YbzoROTc+S0K7V9ndBm1H7kfOS2fb/HEPrAtiGu1hNEnO/GEiLBSPvJ5Yramm0raLkgw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCgn1b2Nr/uqlVUs25AHi3CSGKaxlJ+kp+M5mWhQ1WtdQIgH9+BRSof9uuLVQNaiVUHdrJInbTqO3otN5TzQq3Jz7s="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"tjbutz","email":"tinobutz@gmail.com"},"maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}]}},"readme":"class.js\n========\n\nSimple Class System for JavaScript. Designed to work with backbone.js and node.js.\n\n## Features\n\n  * Inheritance\n  * Mixins\n  * Interfaces\n  * Properties\n    * getter / setter\n    * visibility\n  \t* type check (Class, Object, String, Number, Boolean, Function, Array, Element, Regex)\n  \t* format value\n    * validation\n    * init value\n    * events (optional, event emitter needed: e.g. Backbone.Events, node.js events.EventEmitter)\n  * __super__ - reference on super class\n  * Singleton\n  * Browser & commonJS support\n\n## Dependencies\n\n  * http://underscorejs.org\n\n## Usage\n\nBrowser:\n\n```html\n<script src=\"unsercore.js\"></script>\n<script src=\"class.js\"></script>\n```\n\nnode.js:\n\n```\nnpm install classjs\n```\n\n```js\nrequire(\"classjs\");\n```\n\n## Example\n\n\n```js\nvar Monkey = Class.define(EventEmitter, {\n\tproperties : {\n\t\t\"legs\" : {\n\t\t\ttype : \"Number\",\n\t\t\tinit : 4,\n\t\t\tvalidate : function(value, old) {\n\t\t\t\treturn value <= 4;\n\t\t\t},\n\t\t\tapply : \"_applyLegs\",\n\t\t\tevent : \"legsChanged\"\n\t\t},\n\n\t\thead : {\n\t\t\ttype : \"Object\",\n\t\t\tget : false, // generate only private getter / setter\n\t\t\tset : false\n\t\t}\n\t},\n\n\tmembers : {\n\t\t_applyLegs : function(value, old) {\n\t\t\tconsole.log(value, old);\n\t\t},\n\t\t\n\t\tjump : function() {\n\t\t\tconsole.log(\"jump\");\n\t\t}\n\t}\n});\n\nvar TwoLeggedMonkey = Monkey.extend({\n\tconstructor : function() {\n\t\tthis.__super__.apply(this, arguments);\n\t\tthis.setLegs(3, false); // Do not fire the event\n\t},\n\t\n\tjump : function() {\n\t\tthis.__super__.jump.apply(arguments);\n\t}\n});\n\nvar monkey = new TwoLeggedMonkey();\nmonkey.on(\"legsChanged\", function(data) {\n\tconsole.log(\"Legs changed to %i\", data.value);\n});\nmonkey.jump();\nmonkey.setLegs(2);\n```\n\n","maintainers":[{"name":"tjbutz","email":"tinobutz@gmail.com"}],"time":{"modified":"2022-06-13T06:06:08.258Z","created":"2012-07-25T22:36:25.552Z","0.1.0":"2012-07-25T22:36:27.593Z","0.1.1":"2012-07-25T23:13:45.499Z","0.2.0":"2012-07-26T00:44:49.794Z","0.5.0":"2012-07-27T19:02:07.432Z","0.5.1":"2012-07-27T19:25:20.054Z","0.5.2":"2012-07-27T20:14:49.929Z","0.6.0":"2012-07-28T08:36:43.331Z","0.6.1":"2012-07-29T18:12:18.208Z","0.6.2":"2012-08-05T18:38:21.381Z","0.7.0":"2012-08-25T23:32:07.906Z","0.7.1":"2013-10-02T20:45:47.025Z","0.8.0":"2013-11-23T15:14:24.764Z"},"author":{"name":"Tino Butz","email":"tinobutz@gmail.com"},"repository":{"type":"git","url":"https://github.com/tjbutz/class.js.git"},"users":{"fgribreau":true}}