stream-content
v0.1.2
Published
Convert between stream and buffer(or string)
Downloads
3
Maintainers
Readme
stream-content
Convert between stream and buffer(or string).
Usage
var sc = require('stream-content');
readAll(readableStream, [encoding], callback)
Read content from a readable stream.
sc.readAll(readableStream, encoding, function(err, data) {
console.log(data);
});
writeAll(writableStream, content, [encoding], callback)
Write content into a writable stream.
sc.writeAll(writableStream, 'hello world', function(err) {
console.log('done');
});
createReadableStream(content, [encoding])
Create a readable stream from content.
sc.createReadableStream('hello world').pipe(process.stdout);
createReadableStreamFromCallback(fn)
Create a readable stream from callback of a function.
sc.createReadableStreamFromCallback(function(cb) {
setTimeout(function() {
cb('hello world');
}, 1000);
});
createWritableStreamFromCallback(fn)
Create a writable stream from callback of a function.
sc.createWritableStreamFromCallback(function(content, cb) {
fs.writeFile('file.txt', content, cb);
});