Merge branch 'update-ext'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parents 606da1c, 37d490c · Browse files · 15 files·+82 added−65 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
15 files+82 added−65 removed
- tests:+1 added−1 removed
- other:+81 added−64 removed
Provenance
- Commit
2fbc495- Tree
5765fdc- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent 1
606da1c- Parent 2
37d490c
15 files changed+82 added−65 removed
modified:lib/express/pages/show-exceptions.js+12 added-8 removed
36 unmodified lines37383940414243444142434445464748495018 unmodified lines69707172717273747374757677787980818255 unmodified lines36 unmodified lines * @api private */
function hash(hash) { if (!hash || !hash.values.length) return '<tr><td class="empty" colspan="2">Empty</td></tr>' return hash.map(function(val, key){ return '<tr><td>' + key + ':</td><td>' + sys.inspect(val) + '</td></tr>' }).join('\n') var keys = Object.keys(hash), buf = [] if (!keys.length) return '<tr><td class="empty" colspan="2">Empty</td></tr>' for (var i = 0, len = keys.length; i < len; ++i) buf.push('<tr><td>' + keys[i] + ':</td><td>' + sys.inspect(hash[keys[i]]) + '</td></tr>') return buf.join('\n')}
/** * Return plain-text list items for exception _e_'s stack.18 unmodified lines * @api private */
function hashText(hash) { if (!hash || !hash.values.length) return '\n Empty' return hash.map(function(val, key){ return '\n ' + key + ': ' + sys.inspect(val) }).join('') var keys = Object.keys(hash), buf = '' if (!keys.length) return '\n Empty' for (var i = 0, len = keys.length; i < len; ++i) buf += '\n ' + keys[i] + ': ' + sys.inspect(hash[keys[i]]) return buf}
exports.render = function(request, e) { request.contentType('html')55 unmodified linesmodified:lib/express/plugins/cache.js+24 added-21 removed
124 unmodified lines125 if (key.indexOf('*') === -1)126 return callback(this.data[key] instanceof Cache127 ? this.data[key].val128 : null)129- var regexp = this.normalize(key) 130- callback(this.data.reduce(function(vals, cache){131- if (regexp.test(cache.key))132- vals[cache.key] = cache.val133- return vals134- }, {}))129+ var regexp = this.normalize(key),130+ keys = Object.keys(this.data),131+ matches = {}132+ for (var i = 0, len = keys.length; i < len; ++i)133+ if (regexp.test(keys[i]))134+ matches[keys[i]] = this.data[keys[i]].val135+ callback(matches)136 },137 138 /**139 * Clear data matching the given _key_.11 unmodified lines151 clear: function(key, callback) {152 if (key.indexOf('*') === -1)153 delete this.data[key]154 else {154- var regexp = this.normalize(key)155- this.data.each(function(val, key){156- if (regexp.test(key))157- delete this.data[key]158- }, this)155+ var regexp = this.normalize(key),156+ keys = Object.keys(this.data)157+ for (var i = 0, len = keys.length; i < len; ++i)158+ if (regexp.test(keys[i]))159+ delete this.data[keys[i]]160 }161 callback()162 },163 164 /**164- * Reap caches older than _ms_.165+ * Reap caches older than _ms_ or caches which166+ * have been "cleared" (null).167 *168 * @param {int} ms169 * @api private170 */171 170- reap: function(ms, callback) {171- var self = this,172- threshold = +new Date(Date.now() - ms)173- this.data.each(function(cache){174- if (cache.created < threshold)175- self.clear(cache.key, function(){})176- })177- if (callback) callback()172+ reap: function(ms) {173+ var threshold = +new Date(Date.now() - ms),174+ keys = Object.keys(this.data)175+ for (var i = 0, len = keys.length; i < len; ++i)176+ if (this.data[keys[i]].created < threshold ||177+ this.data[keys[i]].val === null)178+ this.clear(keys[i], function(){})179 },180 181 /**182 * Convert the given key matching _pattern_ 6 unmodified lines189 * @api private190 */191 192 normalize: function(pattern) {193+ // TODO: ensure that stuff like "page:/users/1?foo=bar" will work194+ // because they wont right now :)195 return new RegExp('^' + pattern.replace(/[*]/g, '(.*?)') + '$')196 }197 })198 15 unmodified lines214 * @api private215 */216 217 init: function(options) {215- this.merge(options || {})218+ Object.merge(this, options)219 this.store = new (this.dataStore || exports.Store.Memory)(options)220 Request.include({ cache: this.store })221 this.startReaper()222 },14 unmodified linesmodified:lib/express/plugins/cookie.js+10 added-3 removed
33 unmodified lines34 */35 36 exports.compileCookie = function(name, val, options) {37 if (!options) return name + '=' + val38- return name + '=' + val + '; ' + options.map(function(val, key){38+ var val,39+ buf = [name + '=' + val],40+ keys = Object.keys(options)41+ for (var i = 0, len = keys.length; i < len; ++i) {42+ val = options[keys[i]]43 if (val instanceof Date)44 val = val.toGMTString()41- return val === true ? key : key + '=' + val42- }).join('; ')45+ buf.push(val === true 46+ ? keys[i]47+ : keys[i] + '=' + val)48+ }49+ return buf.join('; ')50 }51 52 // --- Cookie53 68 unmodified linesmodified:lib/express/plugins/hooks.js+1 added-1 removed
37 unmodified lines38 * Initialize extensions.39 */40 41 init: function() {42- global.merge({42+ Object.merge(global, {43 before: exports.before,44 after: exports.after45 })46 }27 unmodified linesmodified:lib/express/plugins/logger.js+1 added-1 removed
65 unmodified lines66 * @api private67 */68 69 init: function(options) {70- this.merge(options || {})70+ Object.merge(this, options)71 }72 },73 74 on: {19 unmodified linesmodified:lib/express/plugins/session.js+9 added-11 removed
126 unmodified lines127 * @api public128 */129 130 length: function(callback) {131- callback(null, this.store.values.length)131+ callback(null, Object.keys(this.store).length)132 },133 134 /**135 * Reap sessions older than _ms_.136 *137 * @param {int} ms138- * @param {function} callback138 * @api private139 */140 142- reap: function(ms, callback) {143- var threshold = +new Date(Date.now() - ms)144- this.store.each(function(session, sid){145- if (session.lastAccess < threshold)146- this.destroy(sid)147- }, this)148- if (callback) callback()141+ reap: function(ms) {142+ var threshold = +new Date(Date.now() - ms),143+ sids = Object.keys(this.store)144+ for (var i = 0, len = sids.length; i < len; ++i)145+ if (this.store[sids[i]].lastAccess < threshold)146+ this.destroy(sids[i])147 },148 149 /**150 * Creates and passes a shiny new session.2 unmodified lines153 * @api public154 */155 156 generate: function(callback) {159- callback(null, new exports.Base(utils.uid()))157+ callback(null, new exports.Base(utils.uid()))158 }159 })160 161 // --- Session16 unmodified lines178 */179 180 init: function(options) {181 this.cookie = {}184- this.merge(options || {})182+ Object.merge(this, options)183 this.cookie.httpOnly = true184 this.store = new (this.dataStore || exports.Store.Memory)(options)185 this.startReaper()186 },47 unmodified linesmodified:lib/express/plugins/view.js+1 added-1 removed
153 unmodified lines154 options.context = options.context || this155 content = (engines[engine] = engines[engine] || require(engine)).render(content, options)156 if (type === 'views') this.contentType(contentType)157 if (layout)158- this.render([layout, contentType, engine].join('.'), options.mergeDeep({158+ this.render([layout, contentType, engine].join('.'), Object.mergeDeep(options, {159 layout: false,160 locals: { body: content }161 }), callback)162 else if (type === 'partials')11 unmodified linesmodified:lib/express/spec/mocks.js+1 added-1 removed
77 unmodified lines78 'accept': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',79 'accept-language': 'en-us',80 'connection': 'keep-alive'81 }82- this.mergeDeep(options)82+ Object.mergeDeep(this, options)83 }84 })85 86 // --- MockResponse92 unmodified linesmodified:lib/express/core.js+2 added-2 removed
11 unmodified lines12 http = require('http'),13 sys = require('sys'),14 fs = require('fs')15 16-global.merge(require('express/plugin'))17-global.merge(require('express/dsl'))16+Object.merge(global, require('express/plugin'))17+Object.merge(global, require('express/dsl'))18 19 // --- Route20 21 Route = new Class({306 unmodified linesmodified:lib/express/event.js+1 added-1 removed
11 unmodified lines12 */13 14 constructor: function(name, data) {15 this.name = name16- this.merge(data)16+ Object.merge(this, data)17 },18 19 /**20 * Return event string.9 unmodified linesmodified:lib/express/http.js+1 added-1 removed
27 unmodified lines28 path = url.pathname || '/',29 search = url.search || '',30 hash = url.hash || '',31 port = url.port || 80,32- headers = (headers || {}).merge({ Host: url.hostname }),32+ headers = Object.merge(headers || {}, { Host: url.hostname }),33 client = http.createClient(port, url.hostname)34 if (typeof data === 'object' && 'redirects' in data)35 redirects = data.redirects,36 delete data.redirects79 unmodified linesmodified:lib/express/plugins.js+9 added-9 removed
1 2 // Express - Plugins - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)3 4-global.merge(require('express/plugins/hooks'))5-global.merge(require('express/plugins/static'))6-global.merge(require('express/plugins/flash'))7-global.merge(require('express/plugins/cache'))8-global.merge(require('express/plugins/cookie'))9-global.merge(require('express/plugins/session'))10-global.merge(require('express/plugins/logger'))11-global.merge(require('express/plugins/content-length'))12-global.merge(require('express/plugins/method-override'))4+Object.merge(global, require('express/plugins/hooks'))5+Object.merge(global, require('express/plugins/static'))6+Object.merge(global, require('express/plugins/flash'))7+Object.merge(global, require('express/plugins/cache'))8+Object.merge(global, require('express/plugins/cookie'))9+Object.merge(global, require('express/plugins/session'))10+Object.merge(global, require('express/plugins/logger'))11+Object.merge(global, require('express/plugins/content-length'))12+Object.merge(global, require('express/plugins/method-override'))modified:lib/express/request.js+9 added-4 removed
46 unmodified lines47 * @api private48 */49 50 constructor: function(request, response) {51- this.merge(request)51+ Object.merge(this, request)52 response.headers = {}53 this.response = response 54 this.url = url.parse(this.url)55 this.url.pathname = exports.normalizePath(this.url.pathname) 64 unmodified lines120 121 accepts: function() {122 var accept = this.header('accept')123 if (!accept || accept === '*/*') return true124- return arguments.any(function(path){124+ return Object.values(arguments).any(function(path){125 var type = mime.type(path)126 return accept.indexOf(type) !== -1 ||127 accept.indexOf(type.split('/')[0] + '/*') !== -1128 })179 unmodified lines308 if (data instanceof Function)309 reverse = callback,310 callback = data,311 data = null312- data = { request: this, response: this.response }.merge(data)312+ data = Object.merge({ request: this, response: this.response }, data)313+ // TODO: no need to reverse plugins every time....314 var self = this,315 complete = 0,316 total = this.plugins.length,317 plugins = reverse2 unmodified lines320 ;(function next(err) {321 if (err || complete === total)322 callback(err)323 else {323- if (plugins.at(complete++).trigger(new Event(name, data), next) !== true)324+ // TODO: remove when this issue is resolved...325+ if (plugins[complete] === undefined)326+ ++complete,327 next()328+ else if (plugins[complete++].trigger(new Event(name, data), next) !== true)329+ next()330 }331 })()332 return this333 },95 unmodified linesmodified:lib/support/extnot shown
Its text is not shown, modified.
modified:Makefile+1 added-1 removed
1-1+ 2 AB = ab3 ABFLAGS = -n 3000 -c 504 NODE = node5 COFFEE = coffee38 unmodified lines