Members
config
Properties| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config | object | Configuration object Properties
|
Methods
(async) countFileLines(file) → {Promise.<number>}
Count the number of lines in a file.
| Name | Type | Description |
|---|---|---|
file | string | The path to the file. |
- The number of lines in the file.
- Type:
- Promise.<number>
(async) createThumbnail(file, optionsopt) → {Promise.<void>}
Create a thumbnail for a given image file.
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file | string | The path to the image file. | ||||||||||||||||||||||||||||||||
options | Object | <optional> | {} | The options for creating the thumbnail. Properties
|
- Type:
- Promise.<void>
(async) decrypt(cipher, optionsopt) → {Promise.<string>}
Decrypt a given cipher using the specified decryption type and options.
| Name | Type | Attributes | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cipher | string | The cipher to be decrypted. | |||||||||||||||||
options | Object | <optional> | {} | The decryption options. Properties
|
- The decrypted text.
- Type:
- Promise.<string>
(async) download(url, opts, extra) → {Promise.<string>}
Download a file from a URL.
| Name | Type | Description |
|---|---|---|
url | string | The URL to download the file from. |
opts | object | Fetch options. |
extra | object | Extra options for downloading. |
- The path to the downloaded file.
- Type:
- Promise.<string>
(async) encrypt(text, optionsopt) → {Promise.<string>}
Encrypt a given text using the specified encryption type and options.
| Name | Type | Attributes | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
text | string | The text to be encrypted. | |||||||||||||||||
options | Object | <optional> | {} | The encryption options. Properties
|
- The encrypted text.
- Type:
- Promise.<string>
(async) fetchAndSave(options)
Fetch data from a URL and save it using the specified options.
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for fetching and saving data. Properties
|
(async) fetchBulk(url, bulk, opts)
Fetch data from a URL in bulk, processing it in steps and applying a handler function to each item.
| Name | Type | Description |
|---|---|---|
url | string | The URL to fetch data from. |
bulk | object | Bulk operation options. |
opts | object | Fetch options. |
(async) fetchUrl(url, optsopt, extraopt) → {Promise.<Object>}
Download a file/resource from a URL.
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url | string | The URL to download the file from. | |||||||||||||||||||||||||||||||||||||||||||||||||
opts | object | <optional> | {} | Fetch options. See Undici Client options for available options. Properties
| |||||||||||||||||||||||||||||||||||||||||||||||
extra.formData | boolean | <optional> | false | If true, sends the request body as multipart/form-data. Defaults to | |||||||||||||||||||||||||||||||||||||||||||||||
extra | object | <optional> | {} | Extra options for downloading. Properties
|
- The response object.
- Type:
- Promise.<Object>
formatByte(value, opts) → {string}
Format a value as bytes.
| Name | Type | Description |
|---|---|---|
value | number | The value to format. |
opts | object | Formatting options. |
- Formatted byte string.
- Type:
- string
formatFloat(value, opts) → {string}
Format a value as a floating-point number.
| Name | Type | Description |
|---|---|---|
value | number | The value to format. |
opts | object | Formatting options. |
- Formatted floating-point string.
- Type:
- string
formatInteger(value, opts) → {string}
Format a value as an integer.
| Name | Type | Description |
|---|---|---|
value | number | The value to format. |
opts | object | Formatting options. |
- Formatted integer string.
- Type:
- string
formatPercentage(value, opts) → {string}
Format a value as a percentage.
| Name | Type | Description |
|---|---|---|
value | number | The value to format. |
opts | object | Formatting options. |
- Formatted percentage string.
- Type:
- string
(async) gunzip(file, deleteOldopt) → {Promise.<void>}
Gunzip a file, optionally deleting the original file after extraction.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
file | string | The path to the file to be gunzipped. | ||
deleteOld | boolean | <optional> | false | If true, deletes the original file after extraction. Defaults to false. |
- Resolves when the gunzip operation is complete.
- Type:
- Promise.<void>
(async) gzip(file, deleteOldopt, expandopt) → {Promise.<void>}
Gzip or gunzip a file, optionally deleting the original file after the operation.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
file | string | The path to the file to be gzipped or gunzipped. | ||
deleteOld | boolean | <optional> | false | If true, deletes the original file after the operation. Defaults to |
expand | boolean | <optional> | false | If true, gunzips the file. If false, gzips the file. Defaults to |
- Resolves when the gzip or gunzip operation is complete.
- Type:
- Promise.<void>
(async) hash(input, typeopt, optionsopt) → {Promise.<string>}
Hash a given text or object using the specified algorithm and options.
| Name | Type | Attributes | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
input | string | | The text or object to be hashed. | |||||||||||||||||
type | string | <optional> | 'md5' | The hashing algorithm to use. Defaults to 'md5'. Set to 'bcrypt' for bcrypt hashing or 'short' for a short hash. | |||||||||||||||
options | object | <optional> | {} | Additional options for the hashing algorithm. Properties
|
- The resulting hash.
- Type:
- Promise.<string>
isBcrypt(text) → {boolean}
Check if a given text is a bcrypt hash.
| Name | Type | Description |
|---|---|---|
text | string | The text to be checked. |
- True if the text is a bcrypt hash, false otherwise.
- Type:
- boolean
isHtmlLink(text) → {boolean}
Check if a given text is an HTML link.
| Name | Type | Description |
|---|---|---|
text | string | The text to be checked. |
- True if the text is an HTML link, false otherwise.
- Type:
- boolean
isMd5(text) → {boolean}
Check if a given text is an MD5 hash.
| Name | Type | Description |
|---|---|---|
text | string | The text to be checked. |
- True if the text is an MD5 hash, false otherwise.
- Type:
- boolean
isSha256(text) → {boolean}
Check if a given text is a SHA-256 hash.
| Name | Type | Description |
|---|---|---|
text | string | The text to be checked. |
- True if the text is a SHA-256 hash, false otherwise.
- Type:
- boolean
randomRange(min, max, alphaopt) → {number|string}
Generate a random number or letter within a specified range.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
min | number | The minimum value of the range. | ||
max | number | The maximum value of the range. | ||
alpha | boolean | <optional> | false | Whether to return a letter instead of a number. |
- The generated random number or letter.
- Type:
- number |
string
thumbnailSizes(name) → {Array.<number>}
Get the dimensions for a given thumbnail size name.
| Name | Type | Description |
|---|---|---|
name | string | The name of the thumbnail size (e.g., 's', 'm', 'l', or ' |
- The width and height of the thumbnail.
- Type:
- Array.<number>