MCPcopy Create free account
hub / github.com/immutable-js/immutable-js / hashNumber

Function hashNumber

src/Hash.ts:55–68  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

53
54// Compress arbitrarily large numbers into smi hashes.
55function hashNumber(n: number): number {
56 if (n !== n || n === Infinity) {
57 return 0;
58 }
59 let hash = n | 0;
60 if (hash !== n) {
61 hash ^= n * 0xffffffff;
62 }
63 while (n > 0xffffffff) {
64 n /= 0xffffffff;
65 hash ^= n;
66 }
67 return smi(hash);
68}
69
70function cachedHashString(string: string): number {
71 let hashed = stringHashCache[string];

Callers 1

hashFunction · 0.85

Calls 1

smiFunction · 0.90

Tested by

no test coverage detected