{"name":"inherit","version":"2.2.7","description":"Inheritance module for Node.js and browsers","homepage":"https://github.com/dfilatov/node-inherit","keywords":["class","prototype","inheritance","mixins","static"],"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+https://github.com/dfilatov/node-inherit.git"},"license":"MIT","dependencies":{},"devDependencies":{"nyc":"^11.0.1","coveralls":"^2.13.1","nodeunit":"^0.11.1"},"main":"index","scripts":{"clean":"rm -r .nyc_output coverage","coverage":"nyc --reporter=text --reporter=html nodeunit; echo; echo 'Open coverage/index.html file in your browser'","coveralls":"nyc report --reporter=text-lcov | coveralls","test":"nyc nodeunit"},"enb":{"sources":["lib/inherit.js"]},"gitHead":"01fc3e9c5149915e4f065a4abaf962a057ca3805","bugs":{"url":"https://github.com/dfilatov/node-inherit/issues"},"_id":"inherit@2.2.7","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"dfilatov","email":"dfilatov@inbox.ru"},"dist":{"integrity":"sha512-dxJmC1j0Q32NFAjvbd6g3lXYLZ49HgzotgbSMwMkoiTXGhC9412Oc24g7A7M9cPPkw/vDsF2cSII+2zJwocUtQ==","shasum":"4e238e289bc7adddf8ff5053d0f26a2fcda94b9f","tarball":"http://registry-npm.ywwl.com/inherit/download/inherit-2.2.7.tgz","fileCount":6,"unpackedSize":16983,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbt80PCRA9TVsSAnZWagAAjFwP/1w/74m3rpAW/YImcl7n\nrppM58tRvqeAShRzHhNI4mbV95/cgUSkEqGZDo4f0MI4FXEdnFc8hfX2h4Nl\nqXfN1qwG5Sj9NeSkYebdHwIM7xiIGNZGkuNLxjqj+q3se8sq7KQmngLKSin+\nspKZ3e2zfL3tb8uJQrHo/OTywe9zSxrUORzRKFPmdz0Ad33BYXFFhihEJvEv\nuNb6mjps488jv7LN5ubaIhuTrEfmQZEcnnJsg3XIMhQMTxr3vszD2WA+z8Eo\nhLR5o9wP0Gu1DM7g2FUYahxhhypQSUMwqZdFFvjR1OfjK95xbUPZo3mdcLOQ\nwi9AetTpvbTo74GYp1mgXYye+8jv9t22CUPQVgSfAp/JLKgOll1RWyAPNtbt\n5nfdqJ2jwQZj8QxpMxvrN/pKCoCHkA7Zq6TcJNqz3ykNE9nvwlGGke5c0vyb\nZvg0qR/O6aURqIpv6QusK48IV8YGsSN6ZeWwtt7u1UevFmZphKJgQ2VdYN7V\n/81omjm4jl7FYS/Prbmkn3knWlHoNmU+nsnGlz3U1j2FcSkDCt3dgzg3h+1A\nEgODnDhZgmWuGLeZCvRjQU4WFWUpw5x4XqkSefDyzZSgmX1V32al0yIH+g8h\nDuMvw7hWx6LzzS/dep6bifxSx3ATkTvZht0TSzm9u9mzKteYd0XEuNql28Bi\n7vgw\r\n=Zolz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBJpEP0mZsIC2yo5QApHETrxP5Fq5sZ4asezCvHxMtQoAiEAqi66MlqT97rRRkcd4Jvz85zkqPymc1ub3HygjfmtpVU="}],"size":4592,"noattachment":false,"key":"/inherit/-/inherit-2.2.7.tgz"},"maintainers":[{"name":"dfilatov","email":"dfilatov@yandex-team.ru"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/inherit_2.2.7_1538772239212_0.8861756550245454"},"_hasShrinkwrap":false,"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":1538772239411,"_cnpm_publish_time":1538772239411,"dist-tags":{"latest":"2.2.7"}}