UNPKG

asset-hash

Version:

Very fast asset hashing function for using e.g. during front-end deployments.

32 lines (31 loc) 1.06 kB
/// <reference types="node" /> import { DigestOptions, SupportedEncoding } from "./encode"; import { HashAlgorithm, initHashClasses } from "./hash"; export declare const DEFAULT_ALGORITHM: string; export declare const DEFAULT_ENCODING = "base52"; export declare const DEFAULT_MAX_LENGTH = 8; export declare type HashOptions = DigestOptions & { algorithm?: HashAlgorithm; }; export declare class Hasher { private hasher; private algorithm; private encoding; private maxLength; constructor(options?: HashOptions); update(data: string | Buffer): Hasher; digest(encoding?: SupportedEncoding, maxLength?: number): string; } /** * Get hash from file * * @param fileName Filename of file to hash */ export declare function getHash(fileName: string, options?: HashOptions): Promise<string>; /** * Get new filename based upon hash and extension of file * * @param fileName Filename of file to hash */ export declare function getHashedName(fileName: string, options?: HashOptions): Promise<string>; export { initHashClasses };