Skip to content
Abstract class

Target

Base class for targets, specifying where output files are written.

Extends: EventEmitter

Subclasses

Used by

Events

onwrite

ts
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

on()

ts
on(
	event: K,
	listener: (data: TEvents[K]) => unknown,
	options?: EventListenerOptions,
): () => void;

Registers a listener for the given event.

See EventListenerOptions.

slice()

ts
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.

Released under the Mozilla Public License 2.0.