HlsUtils
Source: HLSUtils.ts:9
Static utility helper for HLS operations and URL validation.
- Author: Nur Rony<pro.nmrony@gmail.com>
Constructors
new HlsUtils(): HlsUtils
Returns
HlsUtils
Static Methods
isNotFunction(fn: unknown): boolean
static
HLSUtils.ts:71Validation check to ensure provided hooks are executable functions.
Parameters
fn(unknown) — The value to check.
Returns
boolean—trueif the value is NOT a function.
isValidPlaylist(content: string): boolean
static
HLSUtils.ts:42Checks if the content starts with the mandatory HLS #EXTM3U tag.
Parameters
content(string) — The raw manifest string.
Returns
boolean—trueif it contains the HLS header.
isValidUrl(url: string, protocols: string[]): boolean | default
static
HLSUtils.ts:17Validates 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 | default—trueif 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>
static
HLSUtils.ts:61Filters out specific keys from an object.
Type Parameters
TextendsRecord<string, any>Kextendsstring | 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
static
HLSUtils.ts:51Utility 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:80Promise-based delay for retries and throttling
Parameters
ms(number) — {number}- time to sleep in microseconds
Returns
Promise<any>— Promise
stripFirstSlash(url: string): string
static
HLSUtils.ts:33Removes 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.