Skip to content
Myr

Now working on node 0.1.30 but using custom mixin

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

authored by ciaranj · committed by ciaranj · parent 496de51 · Browse files · 3 files+76 added−11 removed
This commit

State

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

Diff stats

3 files+76 added−11 removed

  • other:+76 added−11 removed

3 files+76 added−11 removed

modified:lib/express/plugins/view.js+5 added-1 removed
modified:lib/express/core.js+8 added-9 removed
12// Express - Core - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)3var utils = require('express/utils');4utils.mixin(require('sys'))5utils.mixin(require('express/exceptions'))6utils.mixin(require('express/collection'))7utils.mixin(require('express/event'))8utils.mixin(require('express/request'))9utils.mixin(require('express/plugin'))10utils.mixin(require('express/dsl'))114process.mixin(require('sys'))5process.mixin(require('express/exceptions'))6process.mixin(require('express/collection'))7process.mixin(require('express/event'))8process.mixin(require('express/request'))9process.mixin(require('express/plugin'))10process.mixin(require('express/dsl'))1112/**13 * Module dependencies.14 */1516var multipart = require('multipart'),17 events = require('events'),18 utils = require('express/utils'),18 fs = require('fs')19 20// --- Route21
301 unmodified lines
modified:lib/express/utils.js+63 added-1 removed
143 unmodified lines
144function Clone() {}145exports.clone = function(obj) {146 Clone.prototype = obj147 return new Clone148}148}149150// From jQuery.extend in the jQuery JavaScript Library v1.3.2151// Copyright (c) 2009 John Resig152// Dual licensed under the MIT and GPL licenses.153// http://docs.jquery.com/License154// Modified for node.js (formely for copying properties correctly)155exports.mixin = function() {156 // copy reference to target object157 var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, source;158159 // Handle a deep copy situation160 if ( typeof target === "boolean" ) {161 deep = target;162 target = arguments[1] || {};163 // skip the boolean and the target164 i = 2;165 }166167 // Handle case when target is a string or something (possible in deep copy)168 if ( typeof target !== "object" && !(typeof target === 'function') )169 target = {};170171 // mixin process itself if only one argument is passed172 if ( length == i ) {173 target = GLOBAL;174 --i;175 }176177 for ( ; i < length; i++ ) {178 // Only deal with non-null/undefined values179 if ( (source = arguments[i]) != null ) {180 // Extend the base object181 Object.getOwnPropertyNames(source).forEach(function(k){182 var d = Object.getOwnPropertyDescriptor(source, k) || {value: source[k]};183 if (d.get) {184 target.__defineGetter__(k, d.get);185 if (d.set) {186 target.__defineSetter__(k, d.set);187 }188 }189 else {190 // Prevent never-ending loop191 if (target === d.value) {192 continue;193 }194195 if (deep && d.value && typeof d.value === "object") {196 target[k] = process.mixin(deep,197 // Never move original objects, clone them198 target[k] || (d.value.length != null ? [] : {})199 , d.value);200 }201 else {202 target[k] = d.value;203 }204 }205 });206 }207 }208 // Return the modified object209 return target;210};