Files
klz-cables.com/.pnpm-store/v10/files/6a/c4123d696a4882dd53841edfcd2b3b57787ca3f3f2f40a06538539c7947643077281109bc60ccd58d30756dcc5a632834e0994d49de658a570159df85d0640
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

35 lines
1.1 KiB
Plaintext

import { EndOfStreamError } from './EndOfStreamError.js';
export { EndOfStreamError } from './EndOfStreamError.js';
import { AbstractStreamReader } from "./AbstractStreamReader.js";
/**
* Read from a WebStream
* Reference: https://nodejs.org/api/webstreams.html#class-readablestreambyobreader
*/
export class WebStreamReader extends AbstractStreamReader {
constructor(stream) {
super();
this.reader = stream.getReader({ mode: 'byob' });
}
async readFromStream(buffer, offset, length) {
if (this.endOfStream) {
throw new EndOfStreamError();
}
const result = await this.reader.read(new Uint8Array(length));
if (result.done) {
this.endOfStream = result.done;
}
if (result.value) {
buffer.set(result.value, offset);
return result.value.byteLength;
}
return 0;
}
abort() {
return this.reader.cancel(); // Signals a loss of interest in the stream by a consumer
}
async close() {
await this.abort();
this.reader.releaseLock();
}
}