thedesk/app/node_modules/pullstream/examples/pullFromFile.js

19 lines
473 B
JavaScript
Raw Normal View History

2018-02-18 18:29:06 +11:00
var PullStream = require('../');
var fs = require('fs');
var path = require('path');
var ps = new PullStream();
var loremIpsumStream = fs.createReadStream(path.join(__dirname, 'loremIpsum.txt'));
var outputStream = fs.createWriteStream(path.join(__dirname, 'loremIpsum.out'));
loremIpsumStream.pipe(ps);
ps.pull(5, function (err, data) {
console.log(data.toString('utf8'));
ps.pipe(100, outputStream).on('end', function () {
console.log('all done');
});
});