Skip to content
Myr

js-oo as submodule

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent d95f116 · Browse files · 4 files+4 added−106 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+4 added−106 removed

  • other:+4 added−106 removed

4 files+4 added−106 removed

added:lib/support/js-oonot shown

Its text is not shown, added.

deleted:lib/support/oo.js-105 removed
12// OO - Class - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)3// Based on http://ejohn.org/blog/simple-javascript-inheritance/4// which is based on implementations by Prototype / base256;(function(){7 var global = this, initialize = true8 var referencesSuper = /xyz/.test(function(){ xyz }) ? /\b__super__\b/ : /.*/910 /**11 * Shortcut for Class.extend()12 *13 * @param {hash} props14 * @return {function}15 * @api public16 */1718 Class = function(props){19 if (this == global)20 return Class.extend(props) 21 }22 23 // --- Version24 25 Class.version = '1.2.0'26 27 /**28 * Create a new class.29 *30 * User = Class({31 * init: function(name){32 * this.name = name33 * }34 * })35 *36 * Classes may be subclassed using the .extend() method, and37 * the associated superclass method via this.__super__().38 *39 * Admin = User.extend({40 * init: function(name, password) {41 * this.__super__(name)42 * // or this.__super__.apply(this, arguments)43 * this.password = password44 * }45 * })46 *47 * @param {hash} props48 * @return {function}49 * @api public50 */51 52 Class.extend = function(props) {53 var __super__ = this.prototype54 55 initialize = false56 var prototype = new this57 initialize = true5859 function Class() {60 if (initialize && this.init)61 this.init.apply(this, arguments)62 }63 64 function extend(props) {65 for (var key in props)66 if (props.hasOwnProperty(key))67 Class[key] = props[key]68 }69 70 Class.include = function(props) {71 for (var name in props)72 if (name == 'include')73 if (props[name] instanceof Array)74 for (var i = 0, len = props[name].length; i < len; ++i)75 Class.include(props[name][i])76 else77 Class.include(props[name])78 else if (name == 'extend')79 if (props[name] instanceof Array)80 for (var i = 0, len = props[name].length; i < len; ++i)81 extend(props[name][i])82 else83 extend(props[name])84 else if (props.hasOwnProperty(name))85 prototype[name] = 86 typeof props[name] == 'function' &&87 typeof __super__[name] == 'function' &&88 referencesSuper.test(props[name]) ?89 (function(name, fn){90 return function() {91 this.__super__ = __super__[name]92 return fn.apply(this, arguments)93 }94 })(name, props[name])95 : props[name]96 }97 98 Class.include(props)99 Class.prototype = prototype100 Class.constructor = Class101 Class.extend = arguments.callee102 103 return Class104 }105})()
modified:lib/express.js+1 added-1 removed
modified:.gitmodules+3 added
2 unmodified lines
3 url = git://github.com/creationix/haml-js.git4[submodule "lib/support/haml"]5 path = lib/support/haml6 url = git://github.com/creationix/haml-js.git7[submodule "lib/support/js-oo"]8 path = lib/support/js-oo9 url = git://github.com/visionmedia/js-oo.git