1
mirror of https://github.com/jakejarvis/careful-downloader.git synced 2025-04-25 16:35:24 -04:00

update the types file with new options

This commit is contained in:
Jake Jarvis 2021-10-16 06:32:41 -04:00
parent a5fade6ddc
commit 5d3410f47f
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39

28
index.d.ts vendored
View File

@ -1,4 +1,20 @@
export interface Options {
/**
* Absolute URL to a checksums file, usually just a `.txt` containing
* filenames and hashes.
*
* Either this option or `options.checksumHash` is required.
*/
readonly checksumUrl?: string;
/**
* A single hash for the given downloaded file.
* e.g. `abcd1234abcd1234abcd1234...`.
*
* Either this option or `options.checksumUrl` is required.
*/
readonly checksumHash?: string;
/**
* Manually set the filename of the download, helpful if the one provided by
* the server doesn't match the filename listed in the checksum file.
@ -45,15 +61,15 @@ export interface Options {
readonly algorithm?: string;
/**
* Tell the file stream to read the download as a binary, UTF-8 text file,
* base64, etc.
* Tell the file stream to read the checksums as a string (hex) or binary.
*
* @default "binary"
*/
* @default "hex"
*/
readonly encoding?: BufferEncoding;
}
/**
* Download a file and validate it with its corresponding checksum file.
* Download a file and validate it against a checksum hash. Returns the path to
* the validated file or folder (if it's safe).
*/
export default function downloader(downloadUrl: string, checksumUrl: string, options: Options): Promise<string>;
export default function downloader(downloadUrl: string, options: Options): Promise<string>;