Skip to content

Commit

Permalink
Adding type checking. Removing dumb stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Lokahi Podwys committed Jul 30, 2015
1 parent c645e1a commit aabe198
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions expressStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -49,17 +34,10 @@ exports.stream = function(middlewareViews){
for(var i = 0; i < streamAfter.length; i++){
res.stream(streamAfter[i]);
}
if(closeDocument){
res.write('</body></html>');
}
this._end();
}
}

if(openDocument){
res.write('<!DOCTYPE html><html><head>');
}

for(var i = 0; i < streamBefore.length; i++){
res.stream(streamBefore[i]);
}
Expand All @@ -75,10 +53,6 @@ exports.stream = function(middlewareViews){
}
}

if(closeHeadOpenBody){
res.write('</head><body>');
}

next();
}
}

0 comments on commit aabe198

Please sign in to comment.