raptor-render-context
Advanced tools
Comparing version 0.2.2-beta to 0.2.3-beta
@@ -31,2 +31,10 @@ /* | ||
function StreamWriter(stream) { | ||
this.stream = stream; | ||
} | ||
StreamWriter.prototype.write = function(data) { | ||
this.stream.push(data); | ||
}; | ||
function getAsyncAttributes(context) { | ||
@@ -134,8 +142,20 @@ var attrs = context.attributes; | ||
function Context(writer, attributes) { | ||
this.writer = writer || new StringBuilder(); | ||
this.w = this.write; | ||
this.listeners = {}; | ||
this.attributes = attributes || { | ||
events: new EventEmitter() | ||
}; | ||
if (writer) { | ||
if (writer.pipe) { | ||
var stream = writer; | ||
writer = new StreamWriter(stream); | ||
this.on('end', function() { | ||
stream.push(null); | ||
}); | ||
} | ||
} else { | ||
writer = new StringBuilder(); | ||
} | ||
this.writer = writer; | ||
this.w = this.write; | ||
} | ||
@@ -273,7 +293,7 @@ | ||
if (async) { | ||
async.count++; | ||
async.depth++; | ||
} else { | ||
attributes.async = { | ||
remaining: 0, | ||
count: 1 | ||
depth: 1 | ||
}; | ||
@@ -285,3 +305,3 @@ } | ||
var async = this.attributes.async; | ||
if (--async.count === 0) { | ||
if (--async.depth === 0) { | ||
async.firstPassComplete = true; | ||
@@ -296,5 +316,5 @@ if (async.remaining === 0) { | ||
if (typeof window === 'undefined') { | ||
extend(Context.prototype, require('./Context' + '_server')); // String concatenation to full the optimizers! | ||
extend(Context.prototype, require('./Context' + '_server')); // String concatenation to fool the bundlers | ||
} | ||
module.exports = Context; |
@@ -6,3 +6,3 @@ { | ||
"type": "git", | ||
"url": "https://github.com/raptorjs/raptor-render-context.git" | ||
"url": "https://github.com/raptorjs3/raptor-render-context.git" | ||
}, | ||
@@ -35,3 +35,3 @@ "scripts": { | ||
}, | ||
"version": "0.2.2-beta" | ||
"version": "0.2.3-beta" | ||
} |
13589
325