motion
Version:
motion - moving development forward
80 lines (79 loc) • 4.89 kB
JSON
{
"_args": [
[
"inherit@https://registry.npmjs.org/inherit/-/inherit-2.2.3.tgz",
"/Users/nw/flint/packages/flint"
]
],
"_from": "inherit@>=2.2.2 <3.0.0",
"_id": "inherit@2.2.3",
"_inCache": true,
"_location": "/inherit",
"_phantomChildren": {},
"_requested": {
"name": "inherit",
"raw": "inherit@https://registry.npmjs.org/inherit/-/inherit-2.2.3.tgz",
"rawSpec": "https://registry.npmjs.org/inherit/-/inherit-2.2.3.tgz",
"scope": null,
"spec": "https://registry.npmjs.org/inherit/-/inherit-2.2.3.tgz",
"type": "remote"
},
"_requiredBy": [
"/js-yaml"
],
"_resolved": "https://registry.npmjs.org/inherit/-/inherit-2.2.3.tgz",
"_shasum": "33234f912ac3276ea7ba7ad71231967c7ae45c0d",
"_shrinkwrap": null,
"_spec": "inherit@https://registry.npmjs.org/inherit/-/inherit-2.2.3.tgz",
"_where": "/Users/nw/flint/packages/flint",
"author": {
"email": "dfilatov@yandex-team.ru",
"name": "Dmitry Filatov"
},
"bugs": {
"url": "https://github.com/dfilatov/node-inherit/issues"
},
"contributors": [
{
"name": "Dmitry Filatov",
"email": "dfilatov@yandex-team.ru"
},
{
"name": "Sergey Belov",
"email": "peimei@ya.ru",
"url": "http://github.com/arikon"
}
],
"dependencies": {},
"description": "Inheritance module for Node.js and browsers",
"devDependencies": {
"nodeunit": "0.8.0"
},
"enb": {
"sources": [
"lib/inherit.js"
]
},
"engines": {
"node": ">= 0.4.0"
},
"homepage": "https://github.com/dfilatov/node-inherit",
"keywords": [
"class",
"inheritance",
"mixins",
"prototype",
"static"
],
"license": "MIT",
"main": "index",
"name": "inherit",
"optionalDependencies": {},
"readme": "Inherit [](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",
"readmeFilename": "readme.md",
"repository": {
"type": "git",
"url": "git+https://github.com/dfilatov/node-inherit.git"
},
"version": "2.2.3"
}