@1n/file-hash
Version:
Get the hash-sum of a given file, with low memory usage, even on huge file
13 lines (10 loc) • 622 B
TypeScript
type HashAlgorithm = 'md5' | 'sha1' | 'sha256' | 'sha512';
interface HashOptions<Async extends boolean = boolean> {
algorithm?: HashAlgorithm;
async?: Async;
}
declare function hashSync(path: string, algorithm?: HashAlgorithm | HashOptions<false>): string;
declare function hashAsync(path: string, algorithm?: HashAlgorithm | HashOptions<true>): Promise<string>;
declare function hash(path: string, options: HashOptions<true>): Promise<string>;
declare function hash(path: string, options?: HashOptions<false> | HashAlgorithm): string;
export { type HashAlgorithm, type HashOptions, hash, hashAsync, hashSync };