ag-common 0.0.364 → 0.0.366
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateNewPK = exports.hashCode = void 0;
|
|
3
|
+
exports.generateNewPK = exports.hashCode = exports.hashCodeInt = void 0;
|
|
4
4
|
/* eslint-disable no-bitwise */
|
|
5
|
-
const
|
|
5
|
+
const hashCodeInt = (str, seed = 0) => {
|
|
6
6
|
if (!str) {
|
|
7
|
-
return
|
|
7
|
+
return 0;
|
|
8
8
|
}
|
|
9
9
|
let h1 = 0xdeadbeef ^ seed;
|
|
10
10
|
let h2 = 0x41c6ce57 ^ seed;
|
|
@@ -20,8 +20,10 @@ const hashCode = (str, seed = 0) => {
|
|
|
20
20
|
Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
|
|
21
21
|
Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
22
22
|
const ret = 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
23
|
-
return ret
|
|
23
|
+
return ret;
|
|
24
24
|
};
|
|
25
|
+
exports.hashCodeInt = hashCodeInt;
|
|
26
|
+
const hashCode = (str, seed = 0) => (0, exports.hashCodeInt)(str, seed).toString();
|
|
25
27
|
exports.hashCode = hashCode;
|
|
26
28
|
const generateNewPK = () => (0, exports.hashCode)(new Date().getTime().toString());
|
|
27
29
|
exports.generateNewPK = generateNewPK;
|