From aabe19834da45272f8f2070e702b0d401f771e19 Mon Sep 17 00:00:00 2001 From: Joseph Lokahi Podwys Date: Thu, 30 Jul 2015 12:33:13 -0600 Subject: [PATCH] Adding type checking. Removing dumb stuff. --- expressStream.js | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/expressStream.js b/expressStream.js index 3672336..c7aaa43 100644 --- a/expressStream.js +++ b/expressStream.js @@ -2,28 +2,13 @@ var fs = require('fs'); var streamBefore = []; var streamAfter = []; -var openDocument = false; -var closeHeadOpenBody = false; -var closeDocument = false; exports.streamBefore = function(before){ - streamBefore = before; + streamBefore = (typeof before === 'object' && before.length) ? before : []; } exports.streamAfter = function(after){ - streamAfter = after; -} - -exports.openDocument = function(val){ - openDocument = val; -} - -exports.closeHeadOpenBody = function(val){ - closeHeadOpenBody = val; -} - -exports.closeDocument = function(val){ - closeDocument = val; + streamAfter = (typeof after === 'object' && after.length) ? after : []; } exports.stream = function(middlewareViews){ @@ -49,17 +34,10 @@ exports.stream = function(middlewareViews){ for(var i = 0; i < streamAfter.length; i++){ res.stream(streamAfter[i]); } - if(closeDocument){ - res.write(''); - } this._end(); } } - if(openDocument){ - res.write(''); - } - for(var i = 0; i < streamBefore.length; i++){ res.stream(streamBefore[i]); } @@ -75,10 +53,6 @@ exports.stream = function(middlewareViews){ } } - if(closeHeadOpenBody){ - res.write(''); - } - next(); } }