2015-04-13 19:46:52 +02:00
|
|
|
'use strict';
|
2017-07-18 00:33:46 +02:00
|
|
|
require('../common');
|
2015-04-13 19:46:52 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
|
|
|
const stream = require('stream');
|
2017-07-18 00:33:46 +02:00
|
|
|
const fixtures = require('../common/fixtures');
|
2015-04-13 19:46:52 +02:00
|
|
|
const encoding = 'base64';
|
|
|
|
|
2017-07-18 00:33:46 +02:00
|
|
|
const example = fixtures.path('x.txt');
|
2015-04-13 19:46:52 +02:00
|
|
|
const assertStream = new stream.Writable({
|
|
|
|
write: function(chunk, enc, next) {
|
2016-01-26 00:00:06 +01:00
|
|
|
const expected = Buffer.from('xyz');
|
2015-04-13 19:46:52 +02:00
|
|
|
assert(chunk.equals(expected));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
assertStream.setDefaultEncoding(encoding);
|
|
|
|
fs.createReadStream(example, encoding).pipe(assertStream);
|