HLS Downloaderv0.0.0-semantic-release

default

Source: FileWriter.ts:13

Manages file system operations including directory creation, path resolution, and stream persistence.


Constructors

new default(destination: string, overwrite: boolean): default

Parameters

  • destination (string) — The root directory for downloads.
  • overwrite (boolean, default: "false") — Whether to overwrite existing files.

Returns

default


Methods

canWrite(url: string): Promise<boolean>

Verifies if writing is permitted based on the overwrite flag and existing files.

Parameters

  • url (string) — The URL to check against the file system.

Returns

  • Promise<boolean> — Returns true if writing should proceed.

getTargetPath(url: string): Promise<string>

Get the target directory path

Parameters

  • url (string) — The URL to transform.

Returns

  • Promise<string> — The localized file path.

prepareDirectory(url: string): Promise<string>

Ensures the destination directory exists for a specific URL.

Parameters

  • url (string) — The URL of the file to be saved.

Returns

  • Promise<string> — The prepared absolute target path.

saveStream( webStream: ReadableStream, filePath: string, ): Promise<void>

Pipes a web-standard ReadableStream to the local file system using stream/promises.

Parameters

  • webStream (ReadableStream) — The source stream from the network.
  • filePath (string) — The destination path.

Returns

  • Promise<void> — Resolves when the stream finishes writing.