11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst { Readable, Writable, Transform, pipeline, PassThrough } = require('stream');
61cb0ef41Sopenharmony_ciconst { pipeline: pipelinePromise } = require('stream/promises');
71cb0ef41Sopenharmony_ciconst { ReadableStream, WritableStream, TransformStream } = require('stream/web');
81cb0ef41Sopenharmony_ciconst http = require('http');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci{
111cb0ef41Sopenharmony_ci  const values = [];
121cb0ef41Sopenharmony_ci  let c;
131cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
141cb0ef41Sopenharmony_ci    start(controller) {
151cb0ef41Sopenharmony_ci      c = controller;
161cb0ef41Sopenharmony_ci    }
171cb0ef41Sopenharmony_ci  });
181cb0ef41Sopenharmony_ci  const ws = new WritableStream({
191cb0ef41Sopenharmony_ci    write(chunk) {
201cb0ef41Sopenharmony_ci      values.push(chunk);
211cb0ef41Sopenharmony_ci    }
221cb0ef41Sopenharmony_ci  });
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci  pipeline(rs, ws, common.mustSucceed(() => {
251cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['hello', 'world']);
261cb0ef41Sopenharmony_ci  }));
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  c.enqueue('hello');
291cb0ef41Sopenharmony_ci  c.enqueue('world');
301cb0ef41Sopenharmony_ci  c.close();
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci{
341cb0ef41Sopenharmony_ci  let c;
351cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
361cb0ef41Sopenharmony_ci    start(controller) {
371cb0ef41Sopenharmony_ci      c = controller;
381cb0ef41Sopenharmony_ci    }
391cb0ef41Sopenharmony_ci  });
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci  const ws = new WritableStream({
421cb0ef41Sopenharmony_ci    write() { }
431cb0ef41Sopenharmony_ci  });
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci  pipeline(rs, ws, common.mustCall((err) => {
461cb0ef41Sopenharmony_ci    assert.strictEqual(err?.message, 'kaboom');
471cb0ef41Sopenharmony_ci  }));
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci  c.error(new Error('kaboom'));
501cb0ef41Sopenharmony_ci}
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci{
531cb0ef41Sopenharmony_ci  let c;
541cb0ef41Sopenharmony_ci  const values = [];
551cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
561cb0ef41Sopenharmony_ci    start(controller) {
571cb0ef41Sopenharmony_ci      c = controller;
581cb0ef41Sopenharmony_ci    }
591cb0ef41Sopenharmony_ci  });
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci  const ts = new TransformStream({
621cb0ef41Sopenharmony_ci    transform(chunk, controller) {
631cb0ef41Sopenharmony_ci      controller.enqueue(chunk?.toString().toUpperCase());
641cb0ef41Sopenharmony_ci    }
651cb0ef41Sopenharmony_ci  });
661cb0ef41Sopenharmony_ci
671cb0ef41Sopenharmony_ci  const ws = new WritableStream({
681cb0ef41Sopenharmony_ci    write(chunk) {
691cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
701cb0ef41Sopenharmony_ci    }
711cb0ef41Sopenharmony_ci  });
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ci  pipeline(rs, ts, ws, common.mustSucceed(() => {
741cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['HELLO', 'WORLD']);
751cb0ef41Sopenharmony_ci  }));
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ci  c.enqueue('hello');
781cb0ef41Sopenharmony_ci  c.enqueue('world');
791cb0ef41Sopenharmony_ci  c.close();
801cb0ef41Sopenharmony_ci}
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci{
831cb0ef41Sopenharmony_ci  function makeTransformStream() {
841cb0ef41Sopenharmony_ci    return new TransformStream({
851cb0ef41Sopenharmony_ci      transform(chunk, controller) {
861cb0ef41Sopenharmony_ci        controller.enqueue(chunk?.toString());
871cb0ef41Sopenharmony_ci      }
881cb0ef41Sopenharmony_ci    });
891cb0ef41Sopenharmony_ci  }
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ci  let c;
921cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
931cb0ef41Sopenharmony_ci    start(controller) {
941cb0ef41Sopenharmony_ci      c = controller;
951cb0ef41Sopenharmony_ci    }
961cb0ef41Sopenharmony_ci  });
971cb0ef41Sopenharmony_ci
981cb0ef41Sopenharmony_ci  const ws = new WritableStream({
991cb0ef41Sopenharmony_ci    write() { }
1001cb0ef41Sopenharmony_ci  });
1011cb0ef41Sopenharmony_ci
1021cb0ef41Sopenharmony_ci  pipeline(rs,
1031cb0ef41Sopenharmony_ci           makeTransformStream(),
1041cb0ef41Sopenharmony_ci           makeTransformStream(),
1051cb0ef41Sopenharmony_ci           makeTransformStream(),
1061cb0ef41Sopenharmony_ci           makeTransformStream(),
1071cb0ef41Sopenharmony_ci           ws,
1081cb0ef41Sopenharmony_ci           common.mustCall((err) => {
1091cb0ef41Sopenharmony_ci             assert.strictEqual(err?.message, 'kaboom');
1101cb0ef41Sopenharmony_ci           }));
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci  c.error(new Error('kaboom'));
1131cb0ef41Sopenharmony_ci}
1141cb0ef41Sopenharmony_ci
1151cb0ef41Sopenharmony_ci{
1161cb0ef41Sopenharmony_ci  const values = [];
1171cb0ef41Sopenharmony_ci
1181cb0ef41Sopenharmony_ci  const r = new Readable({
1191cb0ef41Sopenharmony_ci    read() { }
1201cb0ef41Sopenharmony_ci  });
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ci  const ws = new WritableStream({
1231cb0ef41Sopenharmony_ci    write(chunk) {
1241cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
1251cb0ef41Sopenharmony_ci    }
1261cb0ef41Sopenharmony_ci  });
1271cb0ef41Sopenharmony_ci
1281cb0ef41Sopenharmony_ci  pipeline(r, ws, common.mustSucceed(() => {
1291cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['helloworld']);
1301cb0ef41Sopenharmony_ci  }));
1311cb0ef41Sopenharmony_ci
1321cb0ef41Sopenharmony_ci  r.push('hello');
1331cb0ef41Sopenharmony_ci  r.push('world');
1341cb0ef41Sopenharmony_ci  r.push(null);
1351cb0ef41Sopenharmony_ci}
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci{
1381cb0ef41Sopenharmony_ci  const values = [];
1391cb0ef41Sopenharmony_ci  let c;
1401cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
1411cb0ef41Sopenharmony_ci    start(controller) {
1421cb0ef41Sopenharmony_ci      c = controller;
1431cb0ef41Sopenharmony_ci    }
1441cb0ef41Sopenharmony_ci  });
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ci  const w = new Writable({
1471cb0ef41Sopenharmony_ci    write(chunk, encoding, callback) {
1481cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
1491cb0ef41Sopenharmony_ci      callback();
1501cb0ef41Sopenharmony_ci    }
1511cb0ef41Sopenharmony_ci  });
1521cb0ef41Sopenharmony_ci
1531cb0ef41Sopenharmony_ci  pipeline(rs, w, common.mustSucceed(() => {
1541cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['hello', 'world']);
1551cb0ef41Sopenharmony_ci  }));
1561cb0ef41Sopenharmony_ci
1571cb0ef41Sopenharmony_ci  c.enqueue('hello');
1581cb0ef41Sopenharmony_ci  c.enqueue('world');
1591cb0ef41Sopenharmony_ci  c.close();
1601cb0ef41Sopenharmony_ci}
1611cb0ef41Sopenharmony_ci
1621cb0ef41Sopenharmony_ci{
1631cb0ef41Sopenharmony_ci  const values = [];
1641cb0ef41Sopenharmony_ci  let c;
1651cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
1661cb0ef41Sopenharmony_ci    start(controller) {
1671cb0ef41Sopenharmony_ci      c = controller;
1681cb0ef41Sopenharmony_ci    }
1691cb0ef41Sopenharmony_ci  });
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_ci  const ws = new WritableStream({
1721cb0ef41Sopenharmony_ci    write(chunk) {
1731cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
1741cb0ef41Sopenharmony_ci    }
1751cb0ef41Sopenharmony_ci  });
1761cb0ef41Sopenharmony_ci
1771cb0ef41Sopenharmony_ci  const t = new Transform({
1781cb0ef41Sopenharmony_ci    transform(chunk, encoding, callback) {
1791cb0ef41Sopenharmony_ci      callback(null, chunk?.toString().toUpperCase());
1801cb0ef41Sopenharmony_ci    }
1811cb0ef41Sopenharmony_ci  });
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_ci  pipeline(rs, t, ws, common.mustSucceed(() => {
1841cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['HELLOWORLD']);
1851cb0ef41Sopenharmony_ci  }));
1861cb0ef41Sopenharmony_ci
1871cb0ef41Sopenharmony_ci  c.enqueue('hello');
1881cb0ef41Sopenharmony_ci  c.enqueue('world');
1891cb0ef41Sopenharmony_ci  c.close();
1901cb0ef41Sopenharmony_ci}
1911cb0ef41Sopenharmony_ci
1921cb0ef41Sopenharmony_ci{
1931cb0ef41Sopenharmony_ci  const server = http.createServer((req, res) => {
1941cb0ef41Sopenharmony_ci    const rs = new ReadableStream({
1951cb0ef41Sopenharmony_ci      start(controller) {
1961cb0ef41Sopenharmony_ci        controller.enqueue('hello');
1971cb0ef41Sopenharmony_ci        controller.enqueue('world');
1981cb0ef41Sopenharmony_ci        controller.close();
1991cb0ef41Sopenharmony_ci      }
2001cb0ef41Sopenharmony_ci    });
2011cb0ef41Sopenharmony_ci    pipeline(rs, res, common.mustSucceed(() => {}));
2021cb0ef41Sopenharmony_ci  });
2031cb0ef41Sopenharmony_ci
2041cb0ef41Sopenharmony_ci  server.listen(0, common.mustCall(() => {
2051cb0ef41Sopenharmony_ci    const req = http.request({
2061cb0ef41Sopenharmony_ci      port: server.address().port
2071cb0ef41Sopenharmony_ci    });
2081cb0ef41Sopenharmony_ci    req.end();
2091cb0ef41Sopenharmony_ci    const values = [];
2101cb0ef41Sopenharmony_ci    req.on('response', (res) => {
2111cb0ef41Sopenharmony_ci      res.on('data', (chunk) => {
2121cb0ef41Sopenharmony_ci        values.push(chunk?.toString());
2131cb0ef41Sopenharmony_ci      });
2141cb0ef41Sopenharmony_ci      res.on('end', common.mustCall(() => {
2151cb0ef41Sopenharmony_ci        assert.deepStrictEqual(values, ['hello', 'world']);
2161cb0ef41Sopenharmony_ci        server.close();
2171cb0ef41Sopenharmony_ci      }));
2181cb0ef41Sopenharmony_ci    });
2191cb0ef41Sopenharmony_ci  }));
2201cb0ef41Sopenharmony_ci}
2211cb0ef41Sopenharmony_ci
2221cb0ef41Sopenharmony_ci{
2231cb0ef41Sopenharmony_ci  const values = [];
2241cb0ef41Sopenharmony_ci  const server = http.createServer((req, res) => {
2251cb0ef41Sopenharmony_ci    const ts = new TransformStream({
2261cb0ef41Sopenharmony_ci      transform(chunk, controller) {
2271cb0ef41Sopenharmony_ci        controller.enqueue(chunk?.toString().toUpperCase());
2281cb0ef41Sopenharmony_ci      }
2291cb0ef41Sopenharmony_ci    });
2301cb0ef41Sopenharmony_ci    pipeline(req, ts, res, common.mustSucceed());
2311cb0ef41Sopenharmony_ci  });
2321cb0ef41Sopenharmony_ci
2331cb0ef41Sopenharmony_ci  server.listen(0, () => {
2341cb0ef41Sopenharmony_ci    const req = http.request({
2351cb0ef41Sopenharmony_ci      port: server.address().port,
2361cb0ef41Sopenharmony_ci      method: 'POST',
2371cb0ef41Sopenharmony_ci    });
2381cb0ef41Sopenharmony_ci
2391cb0ef41Sopenharmony_ci
2401cb0ef41Sopenharmony_ci    const rs = new ReadableStream({
2411cb0ef41Sopenharmony_ci      start(controller) {
2421cb0ef41Sopenharmony_ci        controller.enqueue('hello');
2431cb0ef41Sopenharmony_ci        controller.close();
2441cb0ef41Sopenharmony_ci      }
2451cb0ef41Sopenharmony_ci    });
2461cb0ef41Sopenharmony_ci
2471cb0ef41Sopenharmony_ci    pipeline(rs, req, common.mustSucceed());
2481cb0ef41Sopenharmony_ci
2491cb0ef41Sopenharmony_ci    req.on('response', (res) => {
2501cb0ef41Sopenharmony_ci      res.on('data', (chunk) => {
2511cb0ef41Sopenharmony_ci        values.push(chunk?.toString());
2521cb0ef41Sopenharmony_ci      }
2531cb0ef41Sopenharmony_ci      );
2541cb0ef41Sopenharmony_ci      res.on('end', common.mustCall(() => {
2551cb0ef41Sopenharmony_ci        assert.deepStrictEqual(values, ['HELLO']);
2561cb0ef41Sopenharmony_ci        server.close();
2571cb0ef41Sopenharmony_ci      }));
2581cb0ef41Sopenharmony_ci    });
2591cb0ef41Sopenharmony_ci  });
2601cb0ef41Sopenharmony_ci}
2611cb0ef41Sopenharmony_ci
2621cb0ef41Sopenharmony_ci{
2631cb0ef41Sopenharmony_ci  const values = [];
2641cb0ef41Sopenharmony_ci  let c;
2651cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
2661cb0ef41Sopenharmony_ci    start(controller) {
2671cb0ef41Sopenharmony_ci      c = controller;
2681cb0ef41Sopenharmony_ci    }
2691cb0ef41Sopenharmony_ci  });
2701cb0ef41Sopenharmony_ci  const ws = new WritableStream({
2711cb0ef41Sopenharmony_ci    write(chunk) {
2721cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
2731cb0ef41Sopenharmony_ci    }
2741cb0ef41Sopenharmony_ci  });
2751cb0ef41Sopenharmony_ci
2761cb0ef41Sopenharmony_ci  pipelinePromise(rs, ws).then(common.mustCall(() => {
2771cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['hello', 'world']);
2781cb0ef41Sopenharmony_ci  }));
2791cb0ef41Sopenharmony_ci
2801cb0ef41Sopenharmony_ci  c.enqueue('hello');
2811cb0ef41Sopenharmony_ci  c.enqueue('world');
2821cb0ef41Sopenharmony_ci  c.close();
2831cb0ef41Sopenharmony_ci}
2841cb0ef41Sopenharmony_ci
2851cb0ef41Sopenharmony_ci{
2861cb0ef41Sopenharmony_ci  let c;
2871cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
2881cb0ef41Sopenharmony_ci    start(controller) {
2891cb0ef41Sopenharmony_ci      c = controller;
2901cb0ef41Sopenharmony_ci    }
2911cb0ef41Sopenharmony_ci  });
2921cb0ef41Sopenharmony_ci
2931cb0ef41Sopenharmony_ci  const ws = new WritableStream({
2941cb0ef41Sopenharmony_ci    write() { }
2951cb0ef41Sopenharmony_ci  });
2961cb0ef41Sopenharmony_ci
2971cb0ef41Sopenharmony_ci  pipelinePromise(rs, ws).then(common.mustNotCall()).catch(common.mustCall((err) => {
2981cb0ef41Sopenharmony_ci    assert.strictEqual(err?.message, 'kaboom');
2991cb0ef41Sopenharmony_ci  }));
3001cb0ef41Sopenharmony_ci
3011cb0ef41Sopenharmony_ci  c.error(new Error('kaboom'));
3021cb0ef41Sopenharmony_ci}
3031cb0ef41Sopenharmony_ci
3041cb0ef41Sopenharmony_ci{
3051cb0ef41Sopenharmony_ci  const values = [];
3061cb0ef41Sopenharmony_ci  let c;
3071cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
3081cb0ef41Sopenharmony_ci    start(controller) {
3091cb0ef41Sopenharmony_ci      c = controller;
3101cb0ef41Sopenharmony_ci    }
3111cb0ef41Sopenharmony_ci  });
3121cb0ef41Sopenharmony_ci
3131cb0ef41Sopenharmony_ci  pipeline(rs, async function(source) {
3141cb0ef41Sopenharmony_ci    for await (const chunk of source) {
3151cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
3161cb0ef41Sopenharmony_ci    }
3171cb0ef41Sopenharmony_ci  }, common.mustSucceed(() => {
3181cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['hello', 'world']);
3191cb0ef41Sopenharmony_ci  }));
3201cb0ef41Sopenharmony_ci
3211cb0ef41Sopenharmony_ci  c.enqueue('hello');
3221cb0ef41Sopenharmony_ci  c.enqueue('world');
3231cb0ef41Sopenharmony_ci  c.close();
3241cb0ef41Sopenharmony_ci}
3251cb0ef41Sopenharmony_ci
3261cb0ef41Sopenharmony_ci{
3271cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
3281cb0ef41Sopenharmony_ci    start() {}
3291cb0ef41Sopenharmony_ci  });
3301cb0ef41Sopenharmony_ci
3311cb0ef41Sopenharmony_ci  pipeline(rs, async function(source) {
3321cb0ef41Sopenharmony_ci    throw new Error('kaboom');
3331cb0ef41Sopenharmony_ci  }, (err) => {
3341cb0ef41Sopenharmony_ci    assert.strictEqual(err?.message, 'kaboom');
3351cb0ef41Sopenharmony_ci  });
3361cb0ef41Sopenharmony_ci}
3371cb0ef41Sopenharmony_ci
3381cb0ef41Sopenharmony_ci{
3391cb0ef41Sopenharmony_ci  const values = [];
3401cb0ef41Sopenharmony_ci  let c;
3411cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
3421cb0ef41Sopenharmony_ci    start(controller) {
3431cb0ef41Sopenharmony_ci      c = controller;
3441cb0ef41Sopenharmony_ci    }
3451cb0ef41Sopenharmony_ci  });
3461cb0ef41Sopenharmony_ci
3471cb0ef41Sopenharmony_ci  const ts = new TransformStream({
3481cb0ef41Sopenharmony_ci    transform(chunk, controller) {
3491cb0ef41Sopenharmony_ci      controller.enqueue(chunk?.toString().toUpperCase());
3501cb0ef41Sopenharmony_ci    }
3511cb0ef41Sopenharmony_ci  });
3521cb0ef41Sopenharmony_ci
3531cb0ef41Sopenharmony_ci  pipeline(rs, ts, async function(source) {
3541cb0ef41Sopenharmony_ci    for await (const chunk of source) {
3551cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
3561cb0ef41Sopenharmony_ci    }
3571cb0ef41Sopenharmony_ci  }, common.mustSucceed(() => {
3581cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['HELLO', 'WORLD']);
3591cb0ef41Sopenharmony_ci  }));
3601cb0ef41Sopenharmony_ci
3611cb0ef41Sopenharmony_ci  c.enqueue('hello');
3621cb0ef41Sopenharmony_ci  c.enqueue('world');
3631cb0ef41Sopenharmony_ci  c.close();
3641cb0ef41Sopenharmony_ci}
3651cb0ef41Sopenharmony_ci
3661cb0ef41Sopenharmony_ci{
3671cb0ef41Sopenharmony_ci  const values = [];
3681cb0ef41Sopenharmony_ci  let c;
3691cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
3701cb0ef41Sopenharmony_ci    start(controller) {
3711cb0ef41Sopenharmony_ci      c = controller;
3721cb0ef41Sopenharmony_ci    }
3731cb0ef41Sopenharmony_ci  });
3741cb0ef41Sopenharmony_ci
3751cb0ef41Sopenharmony_ci  const ws = new WritableStream({
3761cb0ef41Sopenharmony_ci    write(chunk) {
3771cb0ef41Sopenharmony_ci      values.push(chunk?.toString());
3781cb0ef41Sopenharmony_ci    }
3791cb0ef41Sopenharmony_ci  });
3801cb0ef41Sopenharmony_ci
3811cb0ef41Sopenharmony_ci  pipeline(rs, async function* (source) {
3821cb0ef41Sopenharmony_ci    for await (const chunk of source) {
3831cb0ef41Sopenharmony_ci      yield chunk?.toString().toUpperCase();
3841cb0ef41Sopenharmony_ci    }
3851cb0ef41Sopenharmony_ci  }, ws, common.mustSucceed(() => {
3861cb0ef41Sopenharmony_ci    assert.deepStrictEqual(values, ['HELLO', 'WORLD']);
3871cb0ef41Sopenharmony_ci  }));
3881cb0ef41Sopenharmony_ci
3891cb0ef41Sopenharmony_ci  c.enqueue('hello');
3901cb0ef41Sopenharmony_ci  c.enqueue('world');
3911cb0ef41Sopenharmony_ci  c.close();
3921cb0ef41Sopenharmony_ci}
3931cb0ef41Sopenharmony_ci
3941cb0ef41Sopenharmony_ci{
3951cb0ef41Sopenharmony_ci  let c;
3961cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
3971cb0ef41Sopenharmony_ci    start(controller) {
3981cb0ef41Sopenharmony_ci      c = controller;
3991cb0ef41Sopenharmony_ci    }
4001cb0ef41Sopenharmony_ci  });
4011cb0ef41Sopenharmony_ci
4021cb0ef41Sopenharmony_ci  const ws = new WritableStream({
4031cb0ef41Sopenharmony_ci    write(chunk) { }
4041cb0ef41Sopenharmony_ci  }, { highWaterMark: 0 });
4051cb0ef41Sopenharmony_ci
4061cb0ef41Sopenharmony_ci  pipeline(rs, ws, common.mustNotCall());
4071cb0ef41Sopenharmony_ci
4081cb0ef41Sopenharmony_ci  for (let i = 0; i < 10; i++) {
4091cb0ef41Sopenharmony_ci    c.enqueue(`${i}`);
4101cb0ef41Sopenharmony_ci  }
4111cb0ef41Sopenharmony_ci  c.close();
4121cb0ef41Sopenharmony_ci}
4131cb0ef41Sopenharmony_ci
4141cb0ef41Sopenharmony_ci{
4151cb0ef41Sopenharmony_ci  const rs = new ReadableStream({
4161cb0ef41Sopenharmony_ci    start(controller) {
4171cb0ef41Sopenharmony_ci      controller.close();
4181cb0ef41Sopenharmony_ci    }
4191cb0ef41Sopenharmony_ci  });
4201cb0ef41Sopenharmony_ci
4211cb0ef41Sopenharmony_ci  pipeline(rs, new PassThrough(), common.mustSucceed());
4221cb0ef41Sopenharmony_ci}
423