deno.land / std@0.166.0 / node / _tools / test / parallel / test-stream-readable-emit-readable-short-stream.js
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154// deno-fmt-ignore-file// deno-lint-ignore-file
// Copyright Joyent and Node contributors. All rights reserved. MIT license.// Taken from Node 18.12.0// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
'use strict';
const common = require('../common');const stream = require('stream');const assert = require('assert');
{ const r = new stream.Readable({ read: common.mustCall(function() { this.push('content'); this.push(null); }) });
const t = new stream.Transform({ transform: common.mustCall(function(chunk, encoding, callback) { this.push(chunk); return callback(); }), flush: common.mustCall(function(callback) { return callback(); }) });
r.pipe(t); t.on('readable', common.mustCall(function() { while (true) { const chunk = t.read(); if (!chunk) break;
assert.strictEqual(chunk.toString(), 'content'); } }, 2));}
{ const t = new stream.Transform({ transform: common.mustCall(function(chunk, encoding, callback) { this.push(chunk); return callback(); }), flush: common.mustCall(function(callback) { return callback(); }) });
t.end('content');
t.on('readable', common.mustCall(function() { while (true) { const chunk = t.read(); if (!chunk) break; assert.strictEqual(chunk.toString(), 'content'); } }));}
{ const t = new stream.Transform({ transform: common.mustCall(function(chunk, encoding, callback) { this.push(chunk); return callback(); }), flush: common.mustCall(function(callback) { return callback(); }) });
t.write('content'); t.end();
t.on('readable', common.mustCall(function() { while (true) { const chunk = t.read(); if (!chunk) break; assert.strictEqual(chunk.toString(), 'content'); } }));}
{ const t = new stream.Readable({ read() { } });
t.on('readable', common.mustCall(function() { while (true) { const chunk = t.read(); if (!chunk) break; assert.strictEqual(chunk.toString(), 'content'); } }));
t.push('content'); t.push(null);}
{ const t = new stream.Readable({ read() { } });
t.on('readable', common.mustCall(function() { while (true) { const chunk = t.read(); if (!chunk) break; assert.strictEqual(chunk.toString(), 'content'); } }, 2));
process.nextTick(() => { t.push('content'); t.push(null); });}
{ const t = new stream.Transform({ transform: common.mustCall(function(chunk, encoding, callback) { this.push(chunk); return callback(); }), flush: common.mustCall(function(callback) { return callback(); }) });
t.on('readable', common.mustCall(function() { while (true) { const chunk = t.read(); if (!chunk) break; assert.strictEqual(chunk.toString(), 'content'); } }, 2));
t.write('content'); t.end();}
Version Info