{"name":"inherit","version":"1.0.0","description":"Inheritance module for node","homepage":"https://github.com/dfilatov/node-inherit","keywords":["inheritance"],"author":{"name":"Dmitry Filatov","email":"dfilatov@yandex-team.ru"},"contributors":[{"name":"Dmitry Filatov","email":"dfilatov@yandex-team.ru"},{"name":"Sergey Belov","email":"peimei@ya.ru","url":"http://github.com/arikon"}],"repository":{"type":"git","url":"git://github.com/dfilatov/node-inherit.git"},"dependencies":{},"devDependencies":{"nodeunit":"0.5.3"},"main":"index","engines":{"node":">= 0.4.0"},"_npmJsonOpts":{"file":"/Users/dfilatov/.npm/inherit/1.0.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"inherit@1.0.0","_engineSupported":true,"_npmVersion":"1.0.26","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"c7ac619a9477232cc801df90498746088443608d","tarball":"http://registry-npm.ywwl.com/inherit/download/inherit-1.0.0.tgz","integrity":"sha512-C07MZbB7cjT2g8uX9DOTI/fMAg0+etWQGNF/kZw561D2bND9ozlZQhQdKm6tQvzF3QKn8up1/Pbmtz8HiPyvVA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCvt6ek5E7GmHCq+/gsWikVidhOzH7dvDfaKpKP054D2QIhAMWg7z89o5itAy/kFi82EL/W936cOlOK1WsOgPXWE+LW"}],"size":2012,"noattachment":false,"key":"/inherit/-/inherit-1.0.0.tgz"},"scripts":{},"maintainers":[{"name":"dfilatov","email":"dfilatov@yandex-team.ru"}],"directories":{},"readme":"Inherit [![NPM version](https://badge.fury.io/js/inherit.png)](http://badge.fury.io/js/inherit)\n=======\nThis module provides some syntax sugar for \"class\" declarations, constructors, mixins, \"super\" calls and static members.\n\nGetting Started\n---------------\n### In Node.js ###\nYou can install using Node Package Manager (npm):\n\n    npm install inherit\n\n### In Browsers ###\n```html\n<script type=\"text/javascript\" src=\"inherit.js\"></script>\n```\nIt also supports RequireJS module format and [YM module](https://github.com/ymaps/modules) format.\n\nModule has been tested in IE6+, Mozilla Firefox 3+, Chrome 5+, Safari 5+, Opera 10+.\n\nSpecification\n-------------\n### Creating a base class ###\n````js\nFunction inherit(Object props);\n````\n### Creating a base class with static properties ###\n````js\nFunction inherit(\n    Object props,\n    Object staticProps);\n````\n### Creating a derived class ###\n````js\nFunction inherit(\n    Function BaseClass,\n    Object props,\n    Object staticProps);\n````\n### Creating a derived class with mixins ###\n````js\nFunction inherit(\n    [\n        Function BaseClass,\n        Function Mixin,\n        Function AnotherMixin,\n        ...\n    ],\n    Object props,\n    Object staticProps);\n````\n\nExample\n------------\n```javascript\nvar inherit = require('inherit');\n\n// base \"class\"\nvar A = inherit(/** @lends A.prototype */{\n    __constructor : function(property) { // constructor\n        this.property = property;\n    },\n\n    getProperty : function() {\n        return this.property + ' of instanceA';\n    },\n    \n    getType : function() {\n        return 'A';\n    },\n\n    getStaticProperty : function() {\n        return this.__self.staticProperty; // access to static\n    }\n}, /** @lends A */ {    \n    staticProperty : 'staticA',\n    \n    staticMethod : function() {\n        return this.staticProperty;\n    }\n});\n\n// inherited \"class\" from A\nvar B = inherit(A, /** @lends B.prototype */{\n    getProperty : function() { // overriding\n        return this.property + ' of instanceB';\n    },\n    \n    getType : function() { // overriding + \"super\" call\n        return this.__base() + 'B';\n    }\n}, /** @lends B */ {\n    staticMethod : function() { // static overriding + \"super\" call\n        return this.__base() + ' of staticB';\n    }\n});\n\n// mixin M\nvar M = inherit({\n    getMixedProperty : function() {\n        return 'mixed property';\n    }\n});\n\n// inherited \"class\" from A with mixin M\nvar C = inherit([A, M], {\n    getMixedProperty : function() {\n        return this.__base() + ' from C';\n    }\n});\n\nvar instanceOfB = new B('property');\n\ninstanceOfB.getProperty(); // returns 'property of instanceB'\ninstanceOfB.getType(); // returns 'AB'\nB.staticMethod(); // returns 'staticA of staticB'\n\nvar instanceOfC = new C();\ninstanceOfC.getMixedProperty() // returns \"mixed property from C\"\n```\n","publish_time":1318415379843,"_cnpm_publish_time":1318415379843,"dist-tags":{"latest":"2.2.7"}}