Module: utils

Main entry for utils module of YTMP3-JS project.

This module provides a set of submodules for working with various utilities. These submodules are:

Since:
  • 1.0.0
Author:
  • Ryuu Mitsuki <https://github.com/mitsuki31>
License:
  • MIT
Source:

Requires

Classes

ProgressBar

Members

(package, inner, constant) LOGDIR :string

The log directory for error logs.

Basically, the log directory is set to:

  • POSIX: $HOME/.ytmp3-js/logs
  • Windows: %USERPROFILE%\.ytmp3-js\logs
Type:
  • string
Since:
  • 1.0.0
Source:

(package, inner, constant) OUTDIR :string

The output directory for the downloaded audio files.

Type:
  • string
Since:
  • 1.0.0
Source:

(package, inner, constant) ROOTDIR :string

The root directory of the project.

Type:
  • string
Since:
  • 1.0.0
Source:

(package, inner, constant) YTMP3_HOMEDIR :string

The home directory path for the YTMP3-JS configuration and data files.

This path is constructed by joining the user's home directory with the '.ytmp3-js' folder. On POSIX systems, this will typically be "/home/<USERNAME>/.ytmp3-js", while on Windows systems, it will be "C:\Users\<USERNAME>\.ytmp3-js". For Termux Android, it will be "/data/data/com.termux/files/home/.ytmp3-js".

Type:
  • string
Since:
  • 1.1.0
Source:

Methods

(async, package, inner) createDirIfNotExist(dirpath) → {Promise.<void>}

Synchronously checks whether the specified directory path is exist, creates new if not exist with asynchronous operation.

Parameters:
Name Type Description
dirpath string

The directory path to be created if not exist.

Since:
  • 1.0.0
Source:
Returns:
Type
Promise.<void>

(package, inner) createDirIfNotExistSync()

Similar with createDirIfNotExist function, but it uses synchronous directory creation.

Since:
  • 1.0.1
Source:

Type Definitions

ProgressBarOptions

Options object for configuring the progress bar.

Type:
  • Object
Properties:
Name Type Attributes Default Description
barWidth 'auto' | number <optional>
'auto'

The width of the progress bar. Can be 'auto' or a number representing the number of characters.

barCharElapsed string <optional>
'#'

The character used to represent the progress of the bar.

barCharTotal string <optional>
'-'

The character used to represent the total length of the bar.

bytesInfo boolean <optional>
true

Whether to display the bytes downloaded information in MB.

Since:
  • 1.0.0
Source:

ResolvedProgressBarOptions

The resolved ProgressBarOptions options.

Type:
  • ProgressBarOptions
Properties:
Name Type Description
barWidth 'auto' | number

The width of the progress bar. Can be 'auto' or a number representing the number of characters.

barCharElapsed string

The character used to represent the progress of the bar.

barCharTotal string

The character used to represent the total length of the bar.

bytesInfo boolean

Whether to display the bytes downloaded information in MB.

Since:
  • 1.0.0
Source: