BufferTarget
A target that writes data directly into an ArrayBuffer in memory. Great for performance, but not suitable for very large files. The buffer will be available once the output has been finalized.
Extends: Target
Constructor
constructor(
options: BufferTargetOptions = {},
): BufferTarget;Creates a new BufferTarget. The buffer holding the data will be created and managed internally.
See BufferTargetOptions.
Properties
buffer
buffer: ArrayBuffer | null;Stores the final output buffer. Until the output is finalized, this will be null.
Events
onwrite
onwrite: ((start: number, end: number) => unknown) | null;Called each time data is written to the target. Will be called with the byte range into which data was written.
Use this callback to track the size of the output file as it grows. But be warned, this function is chatty and gets called extremely often.
Methods
slice()
slice(
offset: number,
): RangedTarget;Returns a new RangedTarget that writes data to this target using the given offset.
Useful for writing a file into a section of a larger file.