use actual file size in dl progress. detect cancelled stream
This commit is contained in:
parent
2afe79c941
commit
5483dc2506
6 changed files with 35 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
|||
/* global ReadableStream TransformStream */
|
||||
|
||||
export function transformStream(readable, transformer) {
|
||||
export function transformStream(readable, transformer, oncancel) {
|
||||
if (typeof TransformStream === 'function') {
|
||||
return readable.pipeThrough(new TransformStream(transformer));
|
||||
}
|
||||
|
@ -30,8 +30,11 @@ export function transformStream(readable, transformer) {
|
|||
await transformer.transform(data.value, wrappedController);
|
||||
}
|
||||
},
|
||||
cancel() {
|
||||
readable.cancel();
|
||||
cancel(reason) {
|
||||
readable.cancel(reason);
|
||||
if (oncancel) {
|
||||
oncancel(reason);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue