@jk2908/cxx 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cyrb53.ts +16 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jk2908/cxx",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "author": "Jerome Kenway",
6
6
  "repository": {
package/src/cyrb53.ts CHANGED
@@ -1,19 +1,20 @@
1
1
  // cyrb53 (c) 2018 bryc (github.com/bryc)
2
2
  // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
3
+
3
4
  export function cyrb53(str: string, seed = 0) {
4
- let h1 = 0xdeadbeef ^ seed
5
- let h2 = 0x41c6ce57 ^ seed
6
-
7
- for (let i = 0, ch: number; i < str.length; i++) {
8
- ch = str.charCodeAt(i)
9
- h1 = Math.imul(h1 ^ ch, 2654435761)
10
- h2 = Math.imul(h2 ^ ch, 1597334677)
11
- }
5
+ let h1 = 0xdeadbeef ^ seed
6
+ let h2 = 0x41c6ce57 ^ seed
7
+
8
+ for (let i = 0, ch: number; i < str.length; i++) {
9
+ ch = str.charCodeAt(i)
10
+ h1 = Math.imul(h1 ^ ch, 2654435761)
11
+ h2 = Math.imul(h2 ^ ch, 1597334677)
12
+ }
13
+
14
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)
15
+ h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)
16
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)
17
+ h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)
12
18
 
13
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)
14
- h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)
15
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)
16
- h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)
17
-
18
- return 4294967296 * (2097151 & h2) + (h1 >>> 0)
19
- };
19
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0)
20
+ }