@rbxts/hash 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rbxts/hash
|
|
2
2
|
|
|
3
|
-
[](https://github.com/R-unic/hash/actions/workflows)
|
|
4
|
+
[](https://coveralls.io/github/R-unic/hash)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Utility for computing and combining hash codes.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { Hash } from "@rbxts/hash";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class User {
|
|
13
|
+
public constructor(
|
|
14
|
+
public readonly name: string,
|
|
15
|
+
public readonly age: number
|
|
16
|
+
) { }
|
|
17
|
+
|
|
18
|
+
public hashCode(): number {
|
|
19
|
+
return Hash.combine(this.name, this.age);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const bob = new User("Bob", 20);
|
|
24
|
+
const alice = new User("Alice", 21);
|
|
25
|
+
print(bob.hashCode() === bob.hashCode()); // true
|
|
26
|
+
print(bob.hashCode() === alice.hashCode()); // false
|
|
27
|
+
```
|