Permalink
Browse files

[fix] small perf fix

* fixes streaming test missconception
  • Loading branch information...
1 parent 7447d62 commit 025915873e39dfaeafb583015aa901113ccc1e19 @dscape dscape committed Mar 20, 2012
Showing with 5 additions and 7 deletions.
  1. +3 −1 lib/core.js
  2. +1 −1 package.json
  3. +1 −5 test/streaming-test.js
View
@@ -16,6 +16,8 @@ var http = require('http'),
var core = exports;
core.createServer = function (options) {
+ var isArray = Array.isArray(options.after);
+
if (!options) {
throw new Error('options is required to create a server');
}
@@ -25,7 +27,7 @@ core.createServer = function (options) {
before: options.before,
// without new after is a huge memory leak that pipes to every
// single open connection
- after: Array.isArray(options.after) &&
+ after: isArray &&
options.after.map(function (a) {
return new a;
}),
View
@@ -1,7 +1,7 @@
{
"name": "union",
"description": "A hybrid buffered / streaming middleware kernel backwards compatible with connect.",
- "version": "0.2.0",
+ "version": "0.2.1",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",
"contributors": [
{ "name": "Charlie Robbins", "email": "charlie.robbins@gmail.com" },
View
@@ -12,12 +12,8 @@ vows.describe('union/streaming').addBatch({
union.createServer({
before: [
function (req, res, next) {
- var chunks = '';
- req.on('data', function (chunk) {
- chunks += chunk;
- });
req.on('end', function () {
- self.callback(null,chunks);
+ self.callback(null, req.chunks);
});
}
],

0 comments on commit 0259158

Please sign in to comment.