diff --git a/src/index.ts b/src/index.ts index 40dee9b7..4ff3afee 100755 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ import type { ReadDirItem, StatResult, DownloadFileOptions, - DownloadResult, + DownloadFileResult, Encoding, EncodingOrOptions, ProcessedOptions, @@ -52,7 +52,7 @@ function parseOptions(encodingOrOptions?: EncodingOrOptions): ProcessedOptions { return options; } -function encodeContents(contents: string, encoding: Encoding) { +function encodeContents(contents: string, encoding: Encoding): string { if (encoding === 'utf8') { return btoa(encode_utf8(contents)); } @@ -68,7 +68,7 @@ function encodeContents(contents: string, encoding: Encoding) { throw new Error('Invalid encoding type "' + String(encoding) + '"'); } -function decodeContents(b64: string, encoding: Encoding) { +function decodeContents(b64: string, encoding: Encoding): string { if (encoding === 'utf8') { return atob(decode_utf8(b64)); } @@ -208,10 +208,7 @@ export default { return RNFSManager.write(normalizeFilePath(filepath), b64, position).then(() => void 0); }, - downloadFile(options: DownloadFileOptions): { - jobId: number; - promise: Promise; - } { + downloadFile(options: DownloadFileOptions): DownloadFileResult { const jobId = getJobId(); let subscriptions: EmitterSubscription[] = []; diff --git a/src/types.ts b/src/types.ts index fd5ffda8..32d94d89 100644 --- a/src/types.ts +++ b/src/types.ts @@ -51,24 +51,29 @@ export type DownloadFileOptions = { }; export type DownloadBeginCallbackResult = { - jobId: number; // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; // The download jobId, required if one wishes to cancel the download. See `stopDownload`. statusCode: number; // The HTTP status code contentLength: number; // The total size in bytes of the download resource headers: Headers; // The HTTP response headers from the server }; export type DownloadProgressCallbackResult = { - jobId: number; // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; // The download jobId, required if one wishes to cancel the download. See `stopDownload`. contentLength: number; // The total size in bytes of the download resource bytesWritten: number; // The number of bytes written to the file so far }; export type DownloadResult = { - jobId: number; // The download job ID, required if one wishes to cancel the download. See `stopDownload`. + jobId: number; // The download jobId, required if one wishes to cancel the download. See `stopDownload`. statusCode: number; // The HTTP status code bytesWritten: number; // The number of bytes written to the file }; +export type DownloadFileResult = { + jobId: number; + promise: Promise; +}; + export type FSInfoResult = { totalSpace: number; // The total amount of storage space on the device (in bytes). freeSpace: number; // The amount of available storage space on the device (in bytes).