Utils

new Utils()

Static utility helper for HLS operations and URL validation.

Author
  • Nur Rony<pro.nmrony@gmail.com>

Methods

(static) isNotFunction(fn)

Validation check to ensure provided hooks are executable functions.

Parameters:
NameTypeDescription
fn

The value to check.

Returns:

true if the value is NOT a function.

(static) isValidPlaylist(content)

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

Parameters:
NameTypeDescription
content

The raw manifest string.

Returns:

true if it contains the HLS header.

(static) isValidUrl(url, protocols)

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

Parameters:
NameTypeDescription
url

The URL string to validate.

protocols

An array of allowed protocols.

Throws:

If the protocol is not in the allowed list.

Type
UnsupportedProtocol
Returns:

true if valid.

(static) omit(subject, …keys)

Filters out specific keys from an object.

Parameters:
NameTypeAttributesDescription
subject

The source object.

keys<repeatable>

The keys to remove.

Returns:

A new object excluding the specified keys.

(static) parseUrl(url)

Utility to create a URL object from a string.

Parameters:
NameTypeDescription
url

The URL string to parse.

Returns:

A native Node/Web URL object.

(static) stripFirstSlash(url)

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

Parameters:
NameTypeDescription
url

The string to strip.

Returns:

The string without a leading slash.