From 574febb4a88bfe3bc45cb03c5730c43e86276ccb Mon Sep 17 00:00:00 2001 From: vun Date: Sat, 5 Jan 2019 06:23:53 +0800 Subject: [PATCH 1/2] Add RNFetchblob.fs.hash function to type definition --- index.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.d.ts b/index.d.ts index 881a5adfd..7ecda3143 100644 --- a/index.d.ts +++ b/index.d.ts @@ -293,6 +293,7 @@ export interface Net { removeCookies(domain?: string): Promise; } +type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512"; export interface FS { RNFetchBlobSession: RNFetchBlobSession; @@ -316,6 +317,14 @@ export interface FS { ls(path: string): Promise; + /** + * Read the file from the given path and calculate a cryptographic hash sum over its contents. + * + * @param path Path to the file + * @param algorithm The hash algorithm to use + */ + hash(path: string, algorithm: HashAlgorithm); + /** * Create file stream from file at `path`. * @param path The file path. From b48f0e786231fdd34d5c7b7b272e60e5708ed82f Mon Sep 17 00:00:00 2001 From: vun Date: Sat, 5 Jan 2019 06:42:15 +0800 Subject: [PATCH 2/2] Added return type for RNFetchblob.fs.hash typedef --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 7ecda3143..f80157723 100644 --- a/index.d.ts +++ b/index.d.ts @@ -323,7 +323,7 @@ export interface FS { * @param path Path to the file * @param algorithm The hash algorithm to use */ - hash(path: string, algorithm: HashAlgorithm); + hash(path: string, algorithm: HashAlgorithm): Promise; /** * Create file stream from file at `path`.