Add NullTarget

This commit is contained in:
Vanilagy
2025-09-02 17:20:09 +02:00
parent a769d099e2
commit 55dd8cdb4c
5 changed files with 78 additions and 4 deletions
+13 -1
View File
@@ -6,7 +6,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { BufferTargetWriter, StreamTargetWriter, Writer } from './writer';
import { BufferTargetWriter, NullTargetWriter, StreamTargetWriter, Writer } from './writer';
import { Output } from './output';
/**
@@ -104,3 +104,15 @@ export class StreamTarget extends Target {
return new StreamTargetWriter(this);
}
}
/**
* This target just discards all incoming data. It is useful for when you need an `Output` but extract data from it
* differently, for example through format-specific callbacks (`onMoof`, `onMdat`, ...) or encoder events.
* @public
*/
export class NullTarget extends Target {
/** @internal */
_createWriter() {
return new NullTargetWriter();
}
}