Browse Source

Merge pull request #276 from vunyunt/master

Add RNFetchblob.fs.hash function to type definition
Travis Nuttall 5 years ago
parent
commit
6e2234b8aa
No account linked to committer's email address
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      index.d.ts

+ 9
- 0
index.d.ts View File

294
     removeCookies(domain?: string): Promise<null>;
294
     removeCookies(domain?: string): Promise<null>;
295
 }
295
 }
296
 
296
 
297
+type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
297
 export interface FS {
298
 export interface FS {
298
     RNFetchBlobSession: RNFetchBlobSession;
299
     RNFetchBlobSession: RNFetchBlobSession;
299
 
300
 
317
 
318
 
318
     ls(path: string): Promise<string[]>;
319
     ls(path: string): Promise<string[]>;
319
 
320
 
321
+    /**
322
+     * Read the file from the given path and calculate a cryptographic hash sum over its contents.
323
+     *
324
+     * @param path Path to the file
325
+     * @param algorithm The hash algorithm to use
326
+     */
327
+    hash(path: string, algorithm: HashAlgorithm): Promise<string>;
328
+
320
     /**
329
     /**
321
      * Create file stream from file at `path`.
330
      * Create file stream from file at `path`.
322
      * @param  path   The file path.
331
      * @param  path   The file path.