UNPKG

@thi.ng/file-io

Version:

Assorted file I/O utils (w/ logging support) for NodeJS/Bun

35 lines 1.32 kB
import type { TypedArray } from "@thi.ng/api"; import type { ILogger } from "@thi.ng/logger"; import type { Readable } from "node:stream"; export type HashAlgo = "gost-mac" | "md4" | "md5" | "md_gost94" | "ripemd160" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512" | "streebog256" | "streebog512" | "whirlpool"; /** * Creates a readable stream for given file and computes its hash digest using * {@link streamHash}. * * @param path * @param logger * @param algo */ export declare const fileHash: (path: string, logger?: ILogger, algo?: HashAlgo) => Promise<string>; /** * Computes hash digest from given stream using chosen hash algorithm (default: * "sha256"). If `logger` is given, the hash will be logged too. * * @remarks * Also see {@link fileHash} and {@link bufferHash}. * * @param src * @param logger * @param algo */ export declare const streamHash: (src: Readable, logger?: ILogger, algo?: HashAlgo) => Promise<string>; /** * Computes hash digest from given string or buffer using chosen hash algorithm * (default: "sha256"). If `logger` is given, the hash will be logged too. * * @param src * @param logger * @param algo */ export declare const bufferHash: (src: TypedArray | Buffer | DataView | string, logger?: ILogger, algo?: HashAlgo) => string; //# sourceMappingURL=hash.d.ts.map