Skip to content

Type Alias: ObjectHashOptions ​

ObjectHashOptions = object

The options of objectHash: the digest, and what the hash takes into account.

Properties ​

algorithm? ​

optional algorithm?: HashName | "passthrough"

The hash algorithm: a name of crypto.getHashes() ('md5', 'sha1', 'sha256', 'sha512'…), in any case, or 'passthrough' to get the serialization itself (to see what the hash depends on).

Default ​

ts
'sha1'

encoding? ​

optional encoding?: "hex" | "binary" | "base64"

How the digest is written: 'hex', 'base64' or 'binary' (a Latin-1 string). 'buffer' is accepted too (returning a Buffer typed as a string). Ignored by the 'passthrough' algorithm.

Default ​

ts
'hex'

excludeKeys? ​

optional excludeKeys?: (key) => boolean

Leave out the object properties whose key it returns true for, at any depth ((key) => key === 'updatedAt').

Parameters ​

key ​

string

Returns ​

boolean

Default ​

ts
none (every key counts)

excludeValues? ​

optional excludeValues?: boolean

Whether only the keys count, not their values: two objects of the same shape get the same hash.

Default ​

ts
false

ignoreUnknown? ​

optional ignoreUnknown?: boolean

Whether a value of an unsupported type (a Promise, a WeakMap, a Blob) is hashed as its type name only, instead of throwing.

Default ​

ts
false

replacer? ​

optional replacer?: (value) => any

Replace each value before it is hashed, at any depth ((value) => value instanceof Date ? value.getTime() : value).

Parameters ​

value ​

any

Returns ​

any

Default ​

ts
none

respectFunctionNames? ​

optional respectFunctionNames?: boolean

Whether a function's name counts, besides its source code.

Default ​

ts
true

respectFunctionProperties? ​

optional respectFunctionProperties?: boolean

Whether the properties of a function count (its static members).

Default ​

ts
true

respectType? ​

optional respectType?: boolean

Whether an object's prototype and constructor count: with false, an instance and a plain object of the same properties get the same hash.

Default ​

ts
true

unorderedArrays? ​

optional unorderedArrays?: boolean

Whether the order of the array items does not count ([1, 2] and [2, 1] get the same hash).

Default ​

ts
false

unorderedObjects? ​

optional unorderedObjects?: boolean

Whether the order of the object keys does not count ({a, b} and {b, a} get the same hash).

Default ​

ts
true

unorderedSets? ​

optional unorderedSets?: boolean

Whether the insertion order of the Set and Map entries does not count.

Default ​

ts
true

Released under the MIT License.