2
2
3
3
export interface HashOptions {
4
4
/**
5
- *
5
+ * Function to determine if a key should be excluded from hashing.
6
+ * @optional
7
+ * @param key - The key to check for exclusion.
8
+ * @returns {boolean } - Returns true to exclude the key from hashing.
6
9
*/
7
10
excludeKeys ?: ( ( key : string ) => boolean ) | undefined ;
11
+
8
12
/**
9
- * hash object keys, values ignored
13
+ * Specifies whether to exclude values from hashing, so that only the object keys are hashed.
14
+ * @optional
10
15
*/
11
16
excludeValues ?: boolean | undefined ;
17
+
12
18
/**
13
- * ignore unknown object types
19
+ * Specifies whether to ignore objects of unknown type (not directly serialisable) when hashing.
20
+ * @optional
21
+ * @default false
14
22
*/
15
23
ignoreUnknown ?: boolean | undefined ;
24
+
16
25
/**
17
- * optional function that replaces values before hashing
26
+ * A function that replaces values before they are hashed, which can be used to customise the hashing process.
27
+ * @optional
28
+ * @param value - The current value to be hashed.
29
+ * @returns {any } - The value to use for hashing instead.
18
30
*/
19
31
replacer ?: ( ( value : any ) => any ) | undefined ;
32
+
20
33
/**
21
- * consider 'name' property of functions for hashing
34
+ * Specifies whether the 'name' property of functions should be taken into account when hashing.
35
+ * @optional
36
+ * @default false
22
37
*/
23
38
respectFunctionNames ?: boolean | undefined ;
39
+
24
40
/**
25
- * consider function properties when hashing
41
+ * Specifies whether properties of functions should be taken into account when hashing.
42
+ * @optional
43
+ * @default false
26
44
*/
27
45
respectFunctionProperties ?: boolean | undefined ;
46
+
28
47
/**
29
- * Respect special properties (prototype, letructor) when hashing to distinguish between types
48
+ * Specifies whether to include type-specific properties such as prototype or constructor in the hash to distinguish between types.
49
+ * @optional
50
+ * @default false
30
51
*/
31
52
respectType ?: boolean | undefined ;
53
+
32
54
/**
33
- * Sort all arrays before hashing
55
+ * Specifies whether arrays should be sorted before hashing to ensure consistent order.
56
+ * @optional
57
+ * @default false
34
58
*/
35
59
unorderedArrays ?: boolean | undefined ;
60
+
36
61
/**
37
- * Sort `Set` and `Map` instances before hashing
62
+ * Specifies whether Set and Map instances should be sorted by key before hashing to ensure consistent order.
63
+ * @optional
64
+ * @default true
38
65
*/
39
66
unorderedObjects ?: boolean | undefined ;
67
+
40
68
/**
41
- * Sort `Set` and `Map` instances before hashing
69
+ * Specifies whether the elements of `Set' and keys of `Map' should be sorted before hashing to ensure consistent order.
70
+ * @optional
71
+ * @default false
42
72
*/
43
73
unorderedSets ?: boolean | undefined ;
44
74
}
@@ -60,7 +90,7 @@ const defaults: HashOptions = Object.freeze({
60
90
/**
61
91
* Serialize any JS value into a stable, hashable string
62
92
* @param {object } object value to hash
63
- * @param {HashOptions } options hashing options
93
+ * @param {HashOptions } options hashing options. See { @link HashOptions}.
64
94
* @return {string } serialized value
65
95
* @api public
66
96
*/
0 commit comments