diff options
author | isaacs <i@izs.me> | 2013-07-24 07:46:54 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-07-24 07:46:54 +0400 |
commit | ef6a53a50425b47ff227172ba7b621a1594e7f06 (patch) | |
tree | 3423520447b91170cbbf36e4f141e9835281cdf3 /node_modules/inherits | |
parent | 9a8bc875e93371f2ffc5b5365d2f5d477377ca18 (diff) |
bump all deps to use inherits@2
Diffstat (limited to 'node_modules/inherits')
-rw-r--r-- | node_modules/inherits/README.md | 93 | ||||
-rw-r--r-- | node_modules/inherits/inherits-old.js | 40 | ||||
-rw-r--r-- | node_modules/inherits/inherits.js | 30 | ||||
-rw-r--r-- | node_modules/inherits/package.json | 37 |
4 files changed, 59 insertions, 141 deletions
diff --git a/node_modules/inherits/README.md b/node_modules/inherits/README.md index b2beaed93..b1c566585 100644 --- a/node_modules/inherits/README.md +++ b/node_modules/inherits/README.md @@ -1,51 +1,42 @@ -A dead simple way to do inheritance in JS. - - var inherits = require("inherits") - - function Animal () { - this.alive = true - } - Animal.prototype.say = function (what) { - console.log(what) - } - - inherits(Dog, Animal) - function Dog () { - Dog.super.apply(this) - } - Dog.prototype.sniff = function () { - this.say("sniff sniff") - } - Dog.prototype.bark = function () { - this.say("woof woof") - } - - inherits(Chihuahua, Dog) - function Chihuahua () { - Chihuahua.super.apply(this) - } - Chihuahua.prototype.bark = function () { - this.say("yip yip") - } - - // also works - function Cat () { - Cat.super.apply(this) - } - Cat.prototype.hiss = function () { - this.say("CHSKKSS!!") - } - inherits(Cat, Animal, { - meow: function () { this.say("miao miao") } - }) - Cat.prototype.purr = function () { - this.say("purr purr") - } - - - var c = new Chihuahua - assert(c instanceof Chihuahua) - assert(c instanceof Dog) - assert(c instanceof Animal) - -The actual function is laughably small. 10-lines small. +Browser-friendly inheritance fully compatible with standard node.js +[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). + +This package exports standard `inherits` from node.js `util` module in +node environment, but also provides alternative browser-friendly +implementation through [browser +field](https://gist.github.com/shtylman/4339901). Alternative +implementation is a literal copy of standard one located in standalone +module to avoid requiring of `util`. It also has a shim for old +browsers with no `Object.create` support. + +While keeping you sure you are using standard `inherits` +implementation in node.js environment, it allows bundlers such as +[browserify](https://github.com/substack/node-browserify) to not +include full `util` package to your client code if all you need is +just `inherits` function. It worth, because browser shim for `util` +package is large and `inherits` is often the single function you need +from it. + +It's recommended to use this package instead of +`require('util').inherits` for any code that has chances to be used +not only in node.js but in browser too. + +## usage + +```js +var inherits = require('inherits'); +// then use exactly as the standard one +``` + +## note on version ~1.0 + +Version ~1.0 had completely different motivation and is not compatible +neither with 2.0 nor with standard node.js `inherits`. + +If you are using version ~1.0 and planning to switch to ~2.0, be +careful: + +* new version uses `super_` instead of `super` for referencing + superclass +* new version overwrites current prototype while old one preserves any + existing fields on it diff --git a/node_modules/inherits/inherits-old.js b/node_modules/inherits/inherits-old.js deleted file mode 100644 index ef39252dd..000000000 --- a/node_modules/inherits/inherits-old.js +++ /dev/null @@ -1,40 +0,0 @@ -// This is a less perfect implementation of the inherits function, -// designed to work in cases where ES5 is not available. -// -// Note that it is a bit longer, and doesn't properly deal with -// getter/setters or property descriptor flags (enumerable, etc.) - -module.exports = inheritsOld - -function inheritsOld (c, p, proto) { - function F () { this.constructor = c } - F.prototype = p.prototype - var e = {} - for (var i in c.prototype) if (c.prototype.hasOwnProperty(i)) { - e[i] = c.prototype[i] - } - if (proto) for (var i in proto) if (proto.hasOwnProperty(i)) { - e[i] = proto[i] - } - c.prototype = new F() - for (var i in e) if (e.hasOwnProperty(i)) { - c.prototype[i] = e[i] - } - c.super = p -} - -// function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -// } -// function Parent () {} -// inheritsOld(Child, Parent) -// new Child diff --git a/node_modules/inherits/inherits.js b/node_modules/inherits/inherits.js index 061b39620..29f5e24f5 100644 --- a/node_modules/inherits/inherits.js +++ b/node_modules/inherits/inherits.js @@ -1,29 +1 @@ -module.exports = inherits - -function inherits (c, p, proto) { - proto = proto || {} - var e = {} - ;[c.prototype, proto].forEach(function (s) { - Object.getOwnPropertyNames(s).forEach(function (k) { - e[k] = Object.getOwnPropertyDescriptor(s, k) - }) - }) - c.prototype = Object.create(p.prototype, e) - c.super = p -} - -//function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -//} -//function Parent () {} -//inherits(Child, Parent) -//new Child +module.exports = require('util').inherits diff --git a/node_modules/inherits/package.json b/node_modules/inherits/package.json index b5499c1ec..deec27456 100644 --- a/node_modules/inherits/package.json +++ b/node_modules/inherits/package.json @@ -1,18 +1,22 @@ { "name": "inherits", - "description": "A tiny simple way to do classic inheritance in js", - "version": "1.0.0", + "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", + "version": "2.0.0", "keywords": [ "inheritance", "class", "klass", "oop", - "object-oriented" + "object-oriented", + "inherits", + "browser", + "browserify" ], "main": "./inherits.js", + "browser": "./inherits_browser.js", "repository": { "type": "git", - "url": "git://github.com/isaacs/inherits.git" + "url": "https://github.com/isaacs/inherits" }, "license": { "type": "WTFPL2" @@ -22,23 +26,14 @@ "email": "i@izs.me", "url": "http://blog.izs.me/" }, - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" + "scripts": { + "test": "node test" }, - "_id": "inherits@1.0.0", - "dependencies": {}, - "devDependencies": {}, - "optionalDependencies": {}, - "engines": { - "node": "*" + "readme": "Browser-friendly inheritance fully compatible with standard node.js\n[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).\n\nThis package exports standard `inherits` from node.js `util` module in\nnode environment, but also provides alternative browser-friendly\nimplementation through [browser\nfield](https://gist.github.com/shtylman/4339901). Alternative\nimplementation is a literal copy of standard one located in standalone\nmodule to avoid requiring of `util`. It also has a shim for old\nbrowsers with no `Object.create` support.\n\nWhile keeping you sure you are using standard `inherits`\nimplementation in node.js environment, it allows bundlers such as\n[browserify](https://github.com/substack/node-browserify) to not\ninclude full `util` package to your client code if all you need is\njust `inherits` function. It worth, because browser shim for `util`\npackage is large and `inherits` is often the single function you need\nfrom it.\n\nIt's recommended to use this package instead of\n`require('util').inherits` for any code that has chances to be used\nnot only in node.js but in browser too.\n\n## usage\n\n```js\nvar inherits = require('inherits');\n// then use exactly as the standard one\n```\n\n## note on version ~1.0\n\nVersion ~1.0 had completely different motivation and is not compatible\nneither with 2.0 nor with standard node.js `inherits`.\n\nIf you are using version ~1.0 and planning to switch to ~2.0, be\ncareful:\n\n* new version uses `super_` instead of `super` for referencing\n superclass\n* new version overwrites current prototype while old one preserves any\n existing fields on it\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/isaacs/inherits/issues" }, - "_engineSupported": true, - "_npmVersion": "1.1.10", - "_nodeVersion": "v0.7.7-pre", - "_defaultsLoaded": true, - "dist": { - "shasum": "12dbc03c9f7c203289234b214a7d05a311d71450" - }, - "_from": "git://github.com/isaacs/inherits" + "_id": "inherits@2.0.0", + "_from": "inherits@2" } |