1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.DeterministicUuidRegistry = void 0;
|
4 | class DeterministicUuidRegistry {
|
5 | static get(str, inc = 0) {
|
6 | const id = inc ? this.hashCode(`${str}_${inc}`) : this.hashCode(str);
|
7 | if (this.registry.has(id)) {
|
8 | return this.get(str, inc + 1);
|
9 | }
|
10 | this.registry.set(id, true);
|
11 | return id;
|
12 | }
|
13 | static clear() {
|
14 | this.registry.clear();
|
15 | }
|
16 | static hashCode(s) {
|
17 | let h = 0;
|
18 | for (let i = 0; i < s.length; i++)
|
19 | h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;
|
20 | return h.toString();
|
21 | }
|
22 | }
|
23 | exports.DeterministicUuidRegistry = DeterministicUuidRegistry;
|
24 | DeterministicUuidRegistry.registry = new Map();
|