2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-01 17:36:05 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2012-05-12 03:24:46 +02:00
|
|
|
|
2016-12-01 17:36:05 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2012-05-12 03:24:46 +02:00
|
|
|
|
2016-12-01 17:36:05 +01:00
|
|
|
const file = path.join(common.fixturesDir, 'x.txt');
|
|
|
|
let data = '';
|
|
|
|
let first = true;
|
2012-05-12 03:24:46 +02:00
|
|
|
|
|
|
|
var stream = fs.createReadStream(file);
|
|
|
|
stream.setEncoding('utf8');
|
|
|
|
stream.on('data', function(chunk) {
|
|
|
|
data += chunk;
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
stream.resume();
|
|
|
|
}
|
|
|
|
});
|
2015-06-13 19:47:14 +02:00
|
|
|
|
2012-05-12 03:24:46 +02:00
|
|
|
process.nextTick(function() {
|
|
|
|
stream.pause();
|
|
|
|
setTimeout(function() {
|
|
|
|
stream.resume();
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
2016-12-01 17:36:05 +01:00
|
|
|
assert.strictEqual(data, 'xyz\n');
|
2012-05-12 03:24:46 +02:00
|
|
|
});
|