Skip to content
Abstract class

PathedSource

A source which can create new sources from file paths. Required for multi-file inputs such as HLS playlists.

Extends: Source

Subclasses

Events

onread

ts
onread: ((start: number, end: number) => unknown) | null;

Called each time data is retrieved from the source. Will be called with the retrieved range (end exclusive).

Methods

getSize()

ts
getSize(): Promise<number>;

Resolves with the total size of the file in bytes. This function is memoized, meaning only the first call will retrieve the size.

Throws an error if the source is unsized.

getSizeOrNull()

ts
getSizeOrNull(): Promise<number | null>;

Resolves with the total size of the file in bytes. This function is memoized, meaning only the first call will retrieve the size.

Returns null if the source is unsized.

ref()

ts
ref(): SourceRef<this>;

Creates a new SourceRef pointing to this source. You are expected to call .free() on said SourceRef when you're done with it.

See SourceRef.

slice()

ts
slice(
	offset: number,
	length?: number,
): RangedSource;

Returns a new RangedSource that maps data onto this source using the given offset and length. If a length is not provided, the ranged source spans until the end of this source's data.

Useful for reading files that are embedded within larger files.

Released under the Mozilla Public License 2.0.