Removed process.mixin() dependency
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 364c131 · Browse files · 11 files·+29 added−160 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+29 added−160 removed
- tests:+7 added−1 removed
- other:+22 added−159 removed
Provenance
- Commit
247e6ad- Tree
f0726c7- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
364c131
11 files changed+29 added−160 removed
deleted:benchmarks/benchmark.js-83 removed
1-2-;(function(){3- var currentSuite4- 5- /**6- * Contents of _fn_. Strips function literal and signature.7- *8- * @param {function} fn9- * @return {string}10- * @api private11- */12- 13- function contentsOf(fn) {14- return fn.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1]15- }16- 17- /**18- * Pad _str_ to _len_.19- *20- * @param {string} str21- * @param {integer} len22- * @return {string}23- * @api private24- */25- 26- function pad(str, len) {27- return str + (new Array(len - str.length)).join(' ')28- }29- 30- /**31- * Time the execution of _fn_32- *33- * @param {function} fn34- * @return {float}35- * @api private36- */37- 38- function time(fn) {39- var start = Number(new Date)40- fn()41- return (Number(new Date) - start) / 100042- }43- 44- /**45- * Benchmark _fn_ with the given _label_.46- *47- * @param {string} label48- * @param {function} fn49- * @api public50- */51- 52- function benchmark(label, fn) {53- var duration = time(function(){54- for (var i = 0; i < currentSuite.times; ++i)55- fn()56- }).toFixed(3)57- print(pad(' ' + label, 50 - duration.toString().length) + duration + ' |')58- }59- 60- /**61- * Create a benchmark suite with the given _label_, which62- * will run each benchmark n _times_. If _times_ is omitted63- * then it defaults to 1.64- *65- * @param {string} label66- * @param {integer, function} times67- * @param {function} fn68- * @api public69- */70- 71- suite = function(label, times, fn) {72- currentSuite = this73- if (typeof times == 'function')74- this.times = 1, fn = times75- else76- this.times = times77- print('\n ' + pad(label, 42 - this.times.toString().length) + this.times + ' time(s)')78- print(' -------------------------------------------------')79- eval(contentsOf(fn))80- print('')81- }82- 83-})()deleted:benchmarks/views.js-56 removed
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
require.paths.unshift('lib')require.paths.unshift('benchmarks')process.mixin(GLOBAL, require('sys'))process.mixin(GLOBAL, require('benchmark'))require('express')
print = puts
engine = { ejs: require('ejs'), haml: require('haml'), sass: require('sass')}
options = { locals: { article: { title: 'Foo', body: 'bar' }}}
ejs = ' \n\<div id="primary"> \n\ <div class="block first"> \n\ <h1><%= article.title %></h1> \n\ <p><%= article.body %></p> \n\ </div> \n\</div> \n\'
haml = ' \n\#primary \n\ .block.first \n\ %h1= article.title \n\ %p= article.body \n\'
sass = ' \n\red: #ff0000 \n\body \n\ ul \n\ li \n\ a \n\ :color !red \n\ :list-style none \n\'
suite('Template Engines', 1000, function(){ benchmark('ejs', function(){ engine.ejs.render(ejs, options) }) benchmark('haml', function(){ engine.haml.render(haml, options) }) benchmark('sass', function(){ engine.sass.render(sass) })})No newline at end of filemodified:lib/express/plugins/cache.js+1 added-1 removed
194 unmodified lines195 * @api private196 */197 198 init: function(options) {199- process.mixin(this, options)199+ this.merge(options || {})200 this.store = new (this.dataStore || exports.Store.Memory)(options)201 Request.include({ cache: this.store })202 this.startReaper()203 },17 unmodified linesmodified:lib/express/plugins/hooks.js+8 added-2 removed
123456789101126 unmodified lines383940414238394344454647484924 unmodified lines
// Express - Hooks - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
/** * Callbacks. */
exports.callbacks = { before: [], after: [] }
/** * Add a _fn_ to be excuted before a request.26 unmodified lines * Initialize extensions. */ init: function() { global.merge({ process.mixin(GLOBAL, { before: exports.before, after: exports.after }) before: exports.before, after: exports.after }) } }, // --- Events24 unmodified linesmodified:lib/express/plugins/profiler.js+1 added-1 removed
16 unmodified lines1718192021212223242526 unmodified lines16 unmodified lines * @api private */ init: function(options) { process.mixin(this, options) this.merge(options || {}) } }, // --- Events26 unmodified linesmodified:lib/express/plugins/session.js+1 added-1 removed
155 unmodified lines156 * @api private157 */158 159 init: function(options) {160- process.mixin(this, options)160+ this.merge(options || {})161 this.store = new (this.dataStore || exports.Store.Memory)(options)162 this.startReaper()163 },164 41 unmodified linesmodified:lib/express/spec/mocks.js+7 added-1 removed
1 2 // Express - MockRequest - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)3 4+/**5+ * Module dependencies.6+ */7+ 8+var utils = require('express/utils')9+10 // --- MockRequest11 12 var MockRequest = Class({13 24 unmodified lines38 'accept': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',39 'accept-language': 'en-us',40 'connection': 'keep-alive'41 }36- process.mixin(true, this, options)42+ utils.mixin(true, this, options)43 }44 })45 46 // --- MockResponse89 unmodified linesmodified:lib/express/core.js+6 added-6 removed
8 unmodified lines9 utils = require('express/utils'),10 events = require('events'),11 fs = require('fs')12 13-utils.mixin(require('sys'))14-utils.mixin(require('express/exceptions'))15-utils.mixin(require('express/event'))16-utils.mixin(require('express/request'))17-utils.mixin(require('express/plugin'))18-utils.mixin(require('express/dsl'))13+global.merge(require('sys'))14+global.merge(require('express/exceptions'))15+global.merge(require('express/event'))16+global.merge(require('express/request'))17+global.merge(require('express/plugin'))18+global.merge(require('express/dsl'))19 20 // --- Route21 22 Route = Class({313 unmodified linesmodified:lib/express/event.js+2 added-1 removed
12345674 unmodified lines121314151516171819209 unmodified lines
// Express - Event - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
exports.Event = Class({ /** * Initialize with event _name_ and optional _data_.4 unmodified lines */ init: function(name, data) { this.name = name process.mixin(this, data) this.merge(data || {}) }, /** * Return event string.9 unmodified linesmodified:lib/express/request.js+2 added-4 removed
219 unmodified lines220 * @api public221 */222 223 trigger: function(name, data) {224- data = process.mixin(data || {}, {225- request: this,226- response: this.response227- })224+ data = data || {}225+ data.merge({ request: this, response: this.response })226 this.plugins.each(function(plugin){227 plugin.trigger(new Event(name, data))228 })229 return this44 unmodified linesmodified:Makefile+1 added-4 removed
15 unmodified lines16 17 app-upload:18 @$(NODE) examples/upload/app.js19 20-benchmark:21- @$(NODE) benchmarks/views.js22- 23-.PHONY: init test benchmark app20+.PHONY: init test app