%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
'use strict';
const common = require('../common');
const {
Duplex,
Writable,
Transform,
} = require('stream');
const { setTimeout } = require('timers/promises');
const assert = require('assert');
{
class Foo extends Duplex {
async _destroy(err, cb) {
await setTimeout(common.platformTimeout(1));
throw new Error('boom');
}
}
const foo = new Foo();
foo.destroy();
foo.on('error', common.expectsError({
message: 'boom'
}));
foo.on('close', common.mustCall(() => {
assert(foo.destroyed);
}));
}
{
class Foo extends Duplex {
async _destroy(err, cb) {
await setTimeout(common.platformTimeout(1));
}
}
const foo = new Foo();
foo.destroy();
foo.on('close', common.mustCall(() => {
assert(foo.destroyed);
}));
}
{
class Foo extends Duplex {
async _construct() {
await setTimeout(common.platformTimeout(1));
}
_write = common.mustCall((chunk, encoding, cb) => {
cb();
});
_read() {}
}
const foo = new Foo();
foo.write('test', common.mustCall());
}
{
class Foo extends Duplex {
async _construct(callback) {
await setTimeout(common.platformTimeout(1));
callback();
}
_write = common.mustCall((chunk, encoding, cb) => {
cb();
});
_read() {}
}
const foo = new Foo();
foo.write('test', common.mustCall());
foo.on('error', common.mustNotCall());
}
{
class Foo extends Writable {
_write = common.mustCall((chunk, encoding, cb) => {
cb();
});
async _final() {
await setTimeout(common.platformTimeout(1));
}
}
const foo = new Foo();
foo.end('hello');
foo.on('finish', common.mustCall());
}
{
class Foo extends Writable {
_write = common.mustCall((chunk, encoding, cb) => {
cb();
});
async _final(callback) {
await setTimeout(common.platformTimeout(1));
callback();
}
}
const foo = new Foo();
foo.end('hello');
foo.on('finish', common.mustCall());
}
{
class Foo extends Writable {
_write = common.mustCall((chunk, encoding, cb) => {
cb();
});
async _final() {
await setTimeout(common.platformTimeout(1));
throw new Error('boom');
}
}
const foo = new Foo();
foo.end('hello');
foo.on('error', common.expectsError({
message: 'boom'
}));
foo.on('close', common.mustCall());
}
{
const expected = ['hello', 'world'];
class Foo extends Transform {
async _flush() {
return 'world';
}
_transform(chunk, encoding, callback) {
callback(null, chunk);
}
}
const foo = new Foo();
foo.end('hello');
foo.on('data', common.mustCall((chunk) => {
assert.strictEqual(chunk.toString(), expected.shift());
}, 2));
}
{
const expected = ['hello', 'world'];
class Foo extends Transform {
async _flush(callback) {
callback(null, 'world');
}
_transform(chunk, encoding, callback) {
callback(null, chunk);
}
}
const foo = new Foo();
foo.end('hello');
foo.on('data', common.mustCall((chunk) => {
assert.strictEqual(chunk.toString(), expected.shift());
}, 2));
}
{
class Foo extends Transform {
async _flush(callback) {
throw new Error('boom');
}
_transform(chunk, encoding, callback) {
callback(null, chunk);
}
}
const foo = new Foo();
foo.end('hello');
foo.on('data', common.mustCall());
foo.on('error', common.expectsError({
message: 'boom'
}));
foo.on('close', common.mustCall());
}
{
class Foo extends Transform {
async _transform(chunk) {
return chunk.toString().toUpperCase();
}
}
const foo = new Foo();
foo.end('hello');
foo.on('data', common.mustCall((chunk) => {
assert.strictEqual(chunk.toString(), 'HELLO');
}));
}
{
class Foo extends Transform {
async _transform(chunk, _, callback) {
callback(null, chunk.toString().toUpperCase());
}
}
const foo = new Foo();
foo.end('hello');
foo.on('data', common.mustCall((chunk) => {
assert.strictEqual(chunk.toString(), 'HELLO');
}));
}
{
class Foo extends Transform {
async _transform() {
throw new Error('boom');
}
}
const foo = new Foo();
foo.end('hello');
foo.on('error', common.expectsError({
message: 'boom'
}));
foo.on('close', common.mustCall());
}