You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Copied from https://github.com/emotion-js/emotion/blob/master/packages/hash/src/index.js
2
-
3
-
constmurmur2=(str)=>{
4
-
// 'm' and 'r' are mixing constants generated offline.
5
-
// They're not really 'magic', they just happen to work well.
6
-
7
-
// const m = 0x5bd1e995;
8
-
// const r = 24;
9
-
10
-
// Initialize the hash
11
-
12
-
varh=0;
13
-
14
-
// Mix 4 bytes at a time into the hash
15
-
16
-
vark,
17
-
i=0,
18
-
len=str.length;
19
-
for(;len>=4;++i,len-=4){
20
-
k=
21
-
(str.charCodeAt(i)&0xff)|
22
-
((str.charCodeAt(++i)&0xff)<<8)|
23
-
((str.charCodeAt(++i)&0xff)<<16)|
24
-
((str.charCodeAt(++i)&0xff)<<24);
25
-
26
-
k=
27
-
/* Math.imul(k, m): */
28
-
(k&0xffff)*0x5bd1e995+(((k>>>16)*0xe995)<<16);
29
-
k^=/* k >>> r: */k>>>24;
30
-
31
-
h=
32
-
/* Math.imul(k, m): */
33
-
((k&0xffff)*0x5bd1e995+(((k>>>16)*0xe995)<<16))^
34
-
/* Math.imul(h, m): */
35
-
((h&0xffff)*0x5bd1e995+(((h>>>16)*0xe995)<<16));
36
-
}
37
-
38
-
// Handle the last few bytes of the input array
39
-
40
-
switch(len){
41
-
case3:
42
-
h^=(str.charCodeAt(i+2)&0xff)<<16;
43
-
case2:
44
-
h^=(str.charCodeAt(i+1)&0xff)<<8;
45
-
case1:
46
-
h^=str.charCodeAt(i)&0xff;
47
-
h=
48
-
/* Math.imul(h, m): */
49
-
(h&0xffff)*0x5bd1e995+(((h>>>16)*0xe995)<<16);
50
-
}
51
-
52
-
// Do a few final mixes of the hash to ensure the last few
53
-
// bytes are well-incorporated.
54
-
55
-
h^=h>>>13;
56
-
h=
57
-
/* Math.imul(h, m): */
58
-
(h&0xffff)*0x5bd1e995+(((h>>>16)*0xe995)<<16);
59
-
60
-
return((h^(h>>>15))>>>0).toString(36);
61
-
}
62
-
63
-
// Copied from https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/utils/hash.js
64
-
1
+
// Copied from https://github.com/styled-components/styled-components/blob/3ee575eddf804e4bf460f1cadb5890db7ae2f5cf/packages/styled-components/src/utils/hash.ts#L6
65
2
constSEED=5381;
66
3
67
4
// When we have separate strings it's useful to run a progressive
@@ -78,11 +15,8 @@ const phash = (h, x) => {
78
15
};
79
16
80
17
// This is a djb2 hashing function
81
-
consthash=(x)=>{
18
+
consthash=x=>{
82
19
returnphash(SEED,x);
83
20
};
84
21
85
-
// switch between readable vs faster & smaller classnames depending on environment
0 commit comments