DefaultHasher

hashing~ DefaultHasher

Built in hash function.

This is currently based on the xxhashjs library and should optimally be supplied with an 8-byte seed produces an 8-byte long hash, but these parameters may be changed in the future.

Version history

  • 1.9.0 Initial implementation

Constructor

new DefaultHasher(seed, opts)

Source:
Implements:
  • Hasher
  • Shallowclone
  • Deepclone
Parameters:
Name Type Description
seed Uint8Array

– Op­tional; should be 8 bytes long. Will be pad­ded with zer­oes on the right if too short and com­pressed by hash­ing with the de­fault seed if longer.

opts Object

– Op­tional

Properties
Name Type Description
allowReuse Boolean

– De­fault: false; if this is true di­gest() can be called mul­tiple times.

Methods

(static) fromSeed(seed) → {DefaultHasher}

Source:

Ver­sion his­tory

  • 1.9.0 Ini­tial im­ple­ment­a­tion
Parameters:
Name Type Description
seed Uint8Array
Returns:
Type
DefaultHasher

(static) new() → {DefaultHasher}

Source:

Ver­sion his­tory

  • 1.9.0 Ini­tial im­ple­ment­a­tion
Returns:
Type
DefaultHasher

(static) withOpts(opts) → {DefaultHasher}

Source:

Ver­sion his­tory

  • 1.9.0 Ini­tial im­ple­ment­a­tion
Parameters:
Name Type Description
opts Object
Properties
Name Type Description
seed Uint8Array
allowReuse Boolean
Returns:
Type
DefaultHasher

buildHasher()

Source:
Implements:

Most tree-like struc­tures are hashed dir­ectly into the main hasher; but in some cases this is not pos­sible; e.g. or­der in­de­pend­ent hash­ing – used in as­so­ci­at­ive con­tain­ers – re­quire the cal­cu­la­tion of in­ter­me­di­ate hash val­ues. For these cases hash­ers must provide the build­Hasher prop­erty.

It must be a prop­erty (or a method with bound this).

Ver­sion his­tory

  • 1.9.0 Ini­tial im­ple­ment­a­tion
Returns:

Hasher

digest() → {Uint8Array}

Source:
Implements:

Pro­duce a hash value from all the data sup­plied with up­date(). This may throw an er­ror if di­gest() was called be­fore.

Ver­sion his­tory

  • 1.9.0 Ini­tial im­ple­ment­a­tion
Returns:
Type
Uint8Array

update(v) → {Hasher}

Source:
Implements:

Add some more data to the hasher.

This may throw an er­ror if di­gest() was called be­fore.

Ver­sion his­tory

  • 1.9.0 Ini­tial im­ple­ment­a­tion
Parameters:
Name Type Description
v *
Returns:

this, for chain­ing

Type
Hasher