UNPKG

@hugoalh/fnv

Version:

A module to get the non-cryptographic hash of the data with algorithm Fowler-Noll-Vo (FNV).

61 lines 1.9 kB
export type FNVVariant = "0" | "1" | "1a"; export type FNVBitsSize = 32 | 64 | 128 | 256 | 512 | 1024; export type FNVAcceptDataType = string | Uint8Array | Uint16Array | Uint32Array; /** * Get the non-cryptographic hash of the data with algorithm Fowler-Noll-Vo (FNV). */ export declare class FNV { #private; get [Symbol.toStringTag](): string; /** * Initialize. * @param {FNVVariant} variant Variant of the FNV. * @param {FNVBitsSize} size Bits size of the FNV. * @param {FNVAcceptDataType} [data] Data. Can append later via the method {@linkcode FNV.update} and {@linkcode FNV.updateFromStream}. */ constructor(variant: FNVVariant, size: FNVBitsSize, data?: FNVAcceptDataType); /** * Whether the instance is freezed. * @returns {boolean} */ get freezed(): boolean; /** * Bits size of the FNV. * @returns {FNVBitsSize} */ get size(): FNVBitsSize; /** * Variant of the FNV. * @returns {FNVVariant} */ get variant(): FNVVariant; /** * Freeze the instance to prevent any further update. * @returns {this} */ freeze(): this; /** * Get the non-cryptographic hash of the data, in Uint8Array. * @returns {Uint8Array} */ hash(): Uint8Array; /** * Get the non-cryptographic hash of the data, in hexadecimal with padding. * @returns {string} */ hashHex(): string; /** * Append data. * @param {FNVAcceptDataType} data Data. * @returns {this} */ update(data: FNVAcceptDataType): this; /** * Append data from the readable stream. * @param {ReadableStream<FNVAcceptDataType>} stream Data from the readable stream. * @returns {Promise<this>} */ updateFromStream(stream: ReadableStream<FNVAcceptDataType>): Promise<this>; } export default FNV; //# sourceMappingURL=base.d.ts.map