UNPKG

755 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const number_allocator_1 = require("number-allocator");
4class UniqueMessageIdProvider {
5 constructor() {
6 this.numberAllocator = new number_allocator_1.NumberAllocator(1, 65535);
7 }
8 allocate() {
9 this.lastId = this.numberAllocator.alloc();
10 return this.lastId;
11 }
12 getLastAllocated() {
13 return this.lastId;
14 }
15 register(messageId) {
16 return this.numberAllocator.use(messageId);
17 }
18 deallocate(messageId) {
19 this.numberAllocator.free(messageId);
20 }
21 clear() {
22 this.numberAllocator.clear();
23 }
24}
25exports.default = UniqueMessageIdProvider;
26//# sourceMappingURL=unique-message-id-provider.js.map
\No newline at end of file