()
| 118 | } |
| 119 | |
| 120 | async function runWebStream() { |
| 121 | const fh = await fs.promises.open(filename, 'r'); |
| 122 | try { |
| 123 | const rs = fh.readableWebStream(); |
| 124 | |
| 125 | const upper = new TransformStream({ |
| 126 | transform(chunk, controller) { |
| 127 | const buf = new Uint8Array(chunk.length); |
| 128 | for (let i = 0; i < chunk.length; i++) { |
| 129 | const b = chunk[i]; |
| 130 | buf[i] = (b >= 0x61 && b <= 0x7a) ? b - 0x20 : b; |
| 131 | } |
| 132 | controller.enqueue(buf); |
| 133 | }, |
| 134 | }); |
| 135 | |
| 136 | const compress = new CompressionStream('gzip'); |
| 137 | const output = rs.pipeThrough(upper).pipeThrough(compress); |
| 138 | const reader = output.getReader(); |
| 139 | |
| 140 | let totalBytes = 0; |
| 141 | while (true) { |
| 142 | const { done, value } = await reader.read(); |
| 143 | if (done) break; |
| 144 | totalBytes += value.byteLength; |
| 145 | } |
| 146 | return totalBytes; |
| 147 | } finally { |
| 148 | await fh.close(); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // --------------------------------------------------------------------------- |
| 153 | // Pull/iter path: pull() with uppercase transform + selected compression |
no test coverage detected
searching dependent graphs…