Started removing usage of Collection
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 2932bf5 · Browse files · 5 files·+31 added−19 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+31 added−19 removed
- other:+31 added−19 removed
Provenance
- Commit
593634f- Tree
53be183- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
2932bf5
5 files changed+31 added−19 removed
modified:lib/express/plugins/body-decoder.js+6 added
12345678910111213141513 unmodified lines
// Express - BodyDecoder - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
/** * Module dependencies. */
var queryString = require('querystring')
// --- BodyDecoder
exports.BodyDecoder = Plugin.extend({ on: { /**13 unmodified linesmodified:lib/express/plugins/cache.js+7 added-5 removed
28 unmodified lines29 * @api public30 */31 32 set: function(key, val) {33- if (typeof key !== 'string') throw new Error(this.name + ' store #set() key must be a string')33+ if (typeof key !== 'string')34+ throw new Error(this.name + ' store #set() key must be a string')35 },36 37 /**38 * Ensure that the given _key_ is a string.3 unmodified lines42 * @api public43 */44 45 get: function(key) {45- if (typeof key !== 'string') throw new Error(this.name + 'store #get() key must be a string')46+ if (typeof key !== 'string')47+ throw new Error(this.name + 'store #get() key must be a string')48 },49 50 /**51 * Convert to '[NAME Store]'.63 unmodified lines115 return this.data[key] instanceof Cache ?116 this.data[key].val :117 null118 var regexp = this.normalize(key) 117- return $(this.data).reduce({}, function(vals, cache){119+ return this.data.reduce(function(vals, cache){120 if (regexp.test(cache.key))121 vals[cache.key] = cache.val122 return vals121- })123+ }, {})124 },125 126 /**127 * Clear data matching the given _key_.26 unmodified lines154 155 reap: function(ms) {156 var self = this,157 threshold = Number(new Date(Number(new Date) - ms))156- $(this.data).each(function(cache){158+ this.data.each(function(cache){159 if (cache.created < threshold)160 self.clear(cache.key)161 })162 },58 unmodified linesmodified:lib/express/plugins/cookie.js+4 added-4 removed
8 unmodified lines910111213131415161717181920216 unmodified lines28293031323233343536373839394041424367 unmodified lines8 unmodified lines * @api public */
exports.parseCookie = function(cookie) { return $(cookie.replace(/^ *| *$/g, '').split(/ *; */)).reduce({}, function(hash, pair){ return cookie.replace(/^ *| *$/g, '').split(/ *; */).reduce(function(hash, pair){ var parts = pair.split(/ *= */) hash[parts[0]] = parts[1] return hash }) }, {})}
/** * Compile cookie _name_, _val_ and _options_ to a string.6 unmodified lines */
exports.compileCookie = function(name, val, options) { if (!options) return name + '=' + val return name + '=' + val + '; ' + $(options).map(function(val, key){ return name + '=' + val + '; ' + options.map(function(val, key){ if (val instanceof Date) val = val.toString() .replace(/^(\w+)/, '$1,') .replace(/(\w+) (\d+) (\d+)/, '$2-$1-$3') .replace(/GMT.*$/, 'GMT') return val === true ? key : key + '=' + val }).toArray().join('; ') }).join('; ')}
// --- Cookie
67 unmodified linesmodified:lib/express/core.js+6 added-8 removed
122 unmodified lines123 * @api private124 */125 126 matchingRoute: function(){127- var self = this128- return $(Express.routes).find(function(route){129- return self.match(route)130- })127+ return Express.routes.find(function(route){128+ return this.match(route)129+ }, this)130 },131 132 /**133 * Check if _route_ matches the current request.20 unmodified lines154 * @api private155 */156 157 mapParams: function(route) {159- var self = this160- $(route.params).each(function(key, i){161- self.request.params.path[key] = self.request.captures[++i]162- })158+ route.params.each(function(key, i){159+ this.request.params.path[key] = this.request.captures[++i]160+ }, this)161 }162 })163 164 // --- Server172 unmodified linesmodified:lib/express/plugin.js+8 added-2 removed
112345678910111213144 unmodified lines1920212217232425262734 unmodified linesvar utils = require('express/utils');
// Express - Plugin - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
/** * Module dependencies. */
var utils = require('express/utils');
/** * Push _plugin_ with _options_ to the plugin stack. * If _plugin_ has already been pushed, then it's options * will override any previously set. *4 unmodified lines
exports.use = function(plugin, options) { if (Express.environment === 'test' && 'init' in plugin) plugin.init(options) $(Express.plugins).each(function(other, i){ Express.plugins.each(function(other, i){ if (other.klass === plugin) delete Express.plugins[i] }) Express.plugins.push({34 unmodified lines