UnorderedHasher

hashing~ UnorderedHasher

Hash function adapter so that the order of .update() calls doesn't matter.

Version history

  • 1.9.0 Initial implementation

Constructor

new UnorderedHasher(buildHasher, opts)

Source:
Implements:
  • Hasher
  • Shallowclone
  • Deepclone
Parameters:
Name Type Description
buildHasher function

Func­tion that pro­duces an in­stance of the in­ner build­Hasher. De­faults to de­fault­Build­Hasher(). You could use seeded­Build­Hasher or ran­dom­Build­Hasher too.

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) fromBuildHasher(seed) → {UnorderedHasher}

Source:

Ver­sion his­tory

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

(static) new() → {UnorderedHasher}

Source:

Ver­sion his­tory

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

(static) withOpts(opts) → {UnorderedHasher}

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
buildHasher function
allowReuse Boolean
Returns:
Type
UnorderedHasher

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