Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IMurHasher

A common interface to all of the murmur hash incremental utilities.

Hierarchy

  • IMurHasher

Implemented by

Index

Properties

SERIAL_BYTE_LENGTH

SERIAL_BYTE_LENGTH: number

Size in bytes of the serialized hasher.

endianness

endianness: Endianness

Digest byte order.

isBusy

isBusy: boolean

True if asynchronous update is in progress.

When this property is true, trying to update, calculate digest, serialize or copy state will result in an error thrown from the related method.

total

total: number

The total (modulo 2^32) bytes of data provided so far.

Methods

copy

  • Copies the internal state onto the target utility.

    This method does not alter target endianness.

    Parameters

    • target: IMurHasher

      a different instance of a MurmurHash utility of the same type.

    Returns IMurHasher

    target.

digest

  • digest(output: Buffer, offset?: number, length?: number): Buffer
  • digest(outputType?: OutputType): number | string | Buffer
  • Generates the murmur hash of all of the data provided so far.

    The order of bytes written to a Buffer or encoded string depends on endianness property.

    Parameters

    • output: Buffer

      a Buffer object to write hash bytes to; the same object will be returned.

    • Optional offset: number

      start writing into the output at offset byte; negative offset starts from the end of the output buffer.

    • Optional length: number

      a number of bytes to write from calculated hash; negative length starts from the end of the hash; if absolute value of length is larger than the size of a calculated hash, bytes are written only up to the hash size.

    Returns Buffer

    murmur hash.

  • Generates the murmur hash of all of the data provided so far.

    If outputType is not provided a new Buffer instance is returned.

    The order of bytes written to a Buffer or encoded string depends on endianness property.

    Parameters

    • Optional outputType: OutputType

      indicates the form and encoding of the returned hash.

    Returns number | string | Buffer

    murmur hash.

serialize

  • serialize(output: Buffer, offset?: number): Buffer
  • serialize(): string
  • Serializes the internal state of the murmur hash utility instance into the provided Buffer.

    When output has not enough space for the serialized data at the given offset it throws an Error. You may consult the required byte length reading constant: SERIAL_BYTE_LENGTH

    Parameters

    • output: Buffer

      a Buffer to write serialized state to.

    • Optional offset: number

      offset at output.

    Returns Buffer

  • Serializes the internal state of the murmur hash utility instance.

    The serial is generated as a base64 encoded string.

    Returns string

toJSON

  • toJSON(): any
  • Serializes the internal state of the murmur hash utility instance

    The returned type depends on the implementation.

    Returns any

update

  • update(data: string | Buffer, encoding: Encoding, callback: function): void
  • update(data: string | Buffer, callback: function): void
  • update(data: string | Buffer, encoding?: Encoding): this
  • Updates a internal state with the given data asynchronously.

    If data is a Buffer then encoding is being ignored.

    The hash will be updated asynchronously using libuv worker queue.

    Parameters

    • data: string | Buffer

      a chunk of data to calculate hash from.

    • encoding: Encoding

      of the data provided as a string.

    • callback: function

      will be called when asynchronous operation completes.

        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns void

  • Updates a internal state with the given data asynchronously.

    If the data is a string, an encoding of "utf8" is assumed.

    The hash will be updated asynchronously using libuv worker queue.

    Parameters

    • data: string | Buffer

      a chunk of data to calculate hash from.

    • callback: function

      will be called when asynchronous operation completes.

        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns void

  • Updates a internal state with the given data.

    If the data is a string and encoding is not explicitly provided, an encoding of "utf8" is being assumed.

    Parameters

    • data: string | Buffer

      a chunk of data to calculate hash from.

    • Optional encoding: Encoding

      of the data provided as a string.

    Returns this

Generated using TypeDoc