Skip to content
Myr

Started new specs

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

authored by visionmedia · committed by visionmedia · parent 2603bb4 · Browse files · 4 files+117 added−0 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+117 added−0 removed

  • tests:+29 added−0 removed
  • other:+88 added−0 removed

4 files+117 added−0 removed

added:lib/express/core.js+2 added
added:lib/support/oo.js+83 added
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.0.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 for (var name in props)60 prototype[name] = 61 typeof props[name] == 'function' &&62 typeof __super__[name] == 'function' &&63 referencesSuper.test(props[name]) ?64 (function(name, fn){65 return function() {66 this.__super__ = __super__[name]67 return fn.apply(this, arguments)68 }69 })(name, props[name])70 : props[name]71 72 function Class() {73 if (initialize && this.init)74 this.init.apply(this, arguments)75 }76 77 Class.prototype = prototype78 Class.constructor = Class79 Class.extend = arguments.callee80 81 return Class82 }83})()
modified:lib/express.js+3 added
added:spec/spec.node.js+29 added