UNPKG

767 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const long_1 = tslib_1.__importDefault(require("long"));
5class RandomIntGenerator {
6 // static generate () {
7 // return Math.floor(Math.random() * (Math.pow(2, 32) + 1))
8 // }
9 static getAttemptId() {
10 const sysTime = long_1.default.fromNumber(Date.now()).shiftLeft(22);
11 const randomBit = long_1.default.fromNumber(RandomIntGenerator.generate() & 4194303).and(long_1.default.MAX_VALUE);
12 return sysTime.or(randomBit);
13 }
14 static generate() {
15 return Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER));
16 }
17}
18exports.default = RandomIntGenerator;
19//# sourceMappingURL=RandomIntGenerator.js.map
\No newline at end of file