HLS Downloaderv0.0.0-semantic-release

HlsUtils

Source: HLSUtils.ts:9

Static utility helper for HLS operations and URL validation.


Constructors

new HlsUtils(): HlsUtils

Returns

HlsUtils


Static Methods

isNotFunction(fn: unknown): boolean

Validation check to ensure provided hooks are executable functions.

Parameters

  • fn (unknown) — The value to check.

Returns

  • booleantrue if the value is NOT a function.

isValidPlaylist(content: string): boolean

Checks if the content starts with the mandatory HLS #EXTM3U tag.

Parameters

  • content (string) — The raw manifest string.

Returns

  • booleantrue if it contains the HLS header.

isValidUrl(url: string, protocols: string[]): boolean | default

Validates if the provided string is a properly formatted URL with supported protocols.

Parameters

  • url (string) — The URL string to validate.
  • protocols (string[], default: "...") — An array of allowed protocols.

Returns

  • boolean | defaulttrue if valid.

Throws

  • If the protocol is not in the allowed list.

omit< T extends Record<string, any>, K extends string | number | symbol, >( subject: T, ...keys: (K | K[])[], ): Omit<T, K>

Filters out specific keys from an object.

Type Parameters

  • T extends Record<string, any>
  • K extends string | number | symbol

Parameters

  • subject (T) — The source object.
  • keys ((K | K[])[]) — The keys to remove.

Returns

  • Omit<T, K> — A new object excluding the specified keys.

parseUrl(url: string): URL

Utility to create a URL object from a string.

Parameters

  • url (string) — The URL string to parse.

Returns

  • URL — A native Node/Web URL object.

sleep(ms: number): Promise<any>

staticasync
HLSUtils.ts:80

Promise-based delay for retries and throttling

Parameters

  • ms (number) — {number}- time to sleep in microseconds

Returns

  • Promise<any> — Promise

stripFirstSlash(url: string): string

Removes the leading slash from a pathname for safe path joining.

Parameters

  • url (string) — The string to strip.

Returns

  • string — The string without a leading slash.