(format)
| 12 | const dec = new TextDecoder(); |
| 13 | |
| 14 | async function test(format) { |
| 15 | const gzip = new CompressionStream(format); |
| 16 | const gunzip = new DecompressionStream(format); |
| 17 | |
| 18 | assert.strictEqual(gzip[Symbol.toStringTag], 'CompressionStream'); |
| 19 | assert.strictEqual(gunzip[Symbol.toStringTag], 'DecompressionStream'); |
| 20 | |
| 21 | gzip.readable.pipeTo(gunzip.writable).then(common.mustCall()); |
| 22 | |
| 23 | const reader = gunzip.readable.getReader(); |
| 24 | const writer = gzip.writable.getWriter(); |
| 25 | |
| 26 | const compressed_data = []; |
| 27 | const reader_function = common.mustCallAtLeast(({ value, done }) => { |
| 28 | if (value) |
| 29 | compressed_data.push(value); |
| 30 | if (!done) |
| 31 | return reader.read().then(reader_function); |
| 32 | assert.strictEqual(dec.decode(Buffer.concat(compressed_data)), 'hello'); |
| 33 | }); |
| 34 | const reader_promise = reader.read().then(reader_function); |
| 35 | |
| 36 | await Promise.all([ |
| 37 | reader_promise, |
| 38 | reader_promise.then(() => reader.read().then(({ done }) => assert(done))), |
| 39 | writer.write('hello'), |
| 40 | writer.close(), |
| 41 | ]); |
| 42 | } |
| 43 | |
| 44 | Promise.all(['gzip', 'deflate', 'deflate-raw', 'brotli'].map((i) => test(i))).then(common.mustCall()); |
| 45 |
no test coverage detected
searching dependent graphs…