Created
November 11, 2014 21:59
-
-
Save mulderp/14073312b462a153ae11 to your computer and use it in GitHub Desktop.
streams fun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var findit = require('findit')('./posts'); | |
findit.on('file', function(file, stat) { | |
(fs.createReadStream(file)).pipe(through(function(data) { | |
this.queue(marked(data.toString())); | |
})).pipe(process.stdout); | |
}); |
hmm.. still not the wanted output...
var duplexer = require('duplexer');
var rs = fs.createReadStream('./templates/index.html');
var tr = trumpet();
var indexStream = (function() {
var input = concat(function(data) {
output.queue(data.toString());
output.queue(null);
});
var output = through();
return duplexer(input, output);
})();
var findit = require('findit')('./posts');
findit.on('file', function(file, stat) {
(fs.createReadStream(file)).pipe(through(function(data) {
this.queue(marked(data.toString()));
})).pipe(indexStream);
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
attempt to pipe contents onto index html