Add Output.cancel

This commit is contained in:
Vanilagy
2025-01-02 19:57:32 +01:00
parent c42495ec7e
commit 141bed1b37
4 changed files with 49 additions and 4 deletions
+12
View File
@@ -17,6 +17,8 @@ export abstract class Writer {
abstract flush(): Promise<void>;
/** Called after muxing has finished. */
abstract finalize(): Promise<void>;
/** Closes the writer. */
abstract close(): Promise<void>;
}
/**
@@ -74,6 +76,8 @@ export class ArrayBufferTargetWriter extends Writer {
this.target.buffer = this.buffer.slice(0, Math.max(this.maxPos, this.pos));
}
async close() {}
getSlice(start: number, end: number) {
return this.bytes.slice(start, end);
}
@@ -185,6 +189,10 @@ export class StreamTargetWriter extends Writer {
assert(this.writer);
return this.writer.close();
}
async close() {
return this.writer?.close();
}
}
const DEFAULT_CHUNK_SIZE = 2 ** 24;
@@ -375,4 +383,8 @@ export class ChunkedStreamTargetWriter extends Writer {
return this.writer.close();
}
async close() {
return this.writer?.close();
}
}