in src/io/xpi.ts [206:228]
async getChunkAsBuffer(path: string, chunkLength: number): Promise<Buffer> {
this.checkPath(path);
const zipfile = await this.open();
return new Promise((resolve, reject) => {
zipfile.openReadStream(this.files[path], (err, readStream) => {
if (err) {
reject(err);
return;
}
if (!readStream) {
reject(new Error('readStream is falsey'));
return;
}
readStream.pipe(
new FirstChunkStream({ chunkLength }, (_, enc) => {
resolve(enc);
}),
);
});
});
}