fixparser-common 9.2.3-df68ad37 → 9.3.0-bb19a1db

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,175 +1,2 @@
1
- // src/MessageBuffer.ts
2
- var MessageBuffer = class {
3
- /**
4
- * A number representing the next expected message sequence number.
5
- * @private
6
- */
7
- nextMsgSeqNum = 1;
8
- /**
9
- * An array holding the items in the buffer.
10
- * @private
11
- */
12
- buffer = [];
13
- /**
14
- * The maximum capacity of the buffer.
15
- * @private
16
- */
17
- maxBufferSize;
18
- constructor(maxBufferSize = 2500) {
19
- this.maxBufferSize = maxBufferSize;
20
- }
21
- /**
22
- * Adds a new item to the buffer.
23
- * If the buffer is full, the oldest item is removed to make space for the new one.
24
- *
25
- * @param {T} item - The item to add to the buffer.
26
- * @returns {void}
27
- */
28
- add(item) {
29
- if (this.buffer.length === this.maxBufferSize) {
30
- this.buffer.pop();
31
- }
32
- this.buffer.unshift(item);
33
- }
34
- /**
35
- * Retrieves an item from the buffer by its sequence number (or any other identifier).
36
- *
37
- * @param {number} msgSequence - The sequence number of the item to retrieve.
38
- * @returns {T | undefined} The item if found, or `undefined` if not found.
39
- */
40
- getByMsgSequence(msgSequence) {
41
- const index = this.buffer.findIndex((item) => item.messageSequence === msgSequence);
42
- if (index > -1) {
43
- return this.buffer[index];
44
- }
45
- return void 0;
46
- }
47
- /**
48
- * Removes an item from the buffer by its sequence number.
49
- *
50
- * @param {number} msgSequence - The sequence number of the item to remove.
51
- * @returns {void}
52
- */
53
- remove(msgSequence) {
54
- const index = this.buffer.findIndex((item) => item.messageSequence === msgSequence);
55
- if (index > -1) {
56
- this.buffer.splice(index, 1);
57
- }
58
- }
59
- /**
60
- * Updates an item in the buffer.
61
- *
62
- * @param {number} msgSequence - The sequence number of the item to update.
63
- * @param {T} item - The updated item.
64
- * @returns {boolean} - Returns `true` if the item was updated successfully, `false` otherwise.
65
- */
66
- update(msgSequence, item) {
67
- const index = this.buffer.findIndex(
68
- (existingItem) => existingItem.messageSequence === msgSequence
69
- );
70
- if (index > -1) {
71
- this.buffer[index] = item;
72
- return true;
73
- }
74
- return false;
75
- }
76
- /**
77
- * Retrieves all items from the buffer.
78
- *
79
- * @returns {T[]} - An array of all items in the buffer.
80
- */
81
- getAll() {
82
- return this.buffer;
83
- }
84
- /**
85
- * Checks if an item with a given sequence number exists in the buffer.
86
- *
87
- * @param {number} msgSequence - The sequence number of the item to check.
88
- * @returns {boolean} - `true` if the item exists, `false` otherwise.
89
- */
90
- exists(msgSequence) {
91
- return this.buffer.some((item) => item.messageSequence === msgSequence);
92
- }
93
- /**
94
- * Gets the current size of the buffer (the number of items it contains).
95
- *
96
- * @returns {number} The number of items currently in the buffer.
97
- */
98
- size() {
99
- return this.buffer.length;
100
- }
101
- /**
102
- * Resizes the buffer's capacity.
103
- *
104
- * @param {number} newCapacity - The new maximum capacity for the buffer.
105
- * @returns {void}
106
- */
107
- resize(newCapacity) {
108
- this.maxBufferSize = newCapacity;
109
- if (this.buffer.length > this.maxBufferSize) {
110
- this.buffer = this.buffer.slice(0, this.maxBufferSize);
111
- }
112
- }
113
- /**
114
- * Clears all items from the buffer.
115
- *
116
- * @returns {void}
117
- */
118
- clear() {
119
- this.buffer = [];
120
- }
121
- /**
122
- * Gets the maximum capacity of the buffer.
123
- *
124
- * @returns {number} The maximum number of items the buffer can hold.
125
- */
126
- getCapacity() {
127
- return this.maxBufferSize;
128
- }
129
- /**
130
- * Set the next message sequence number.
131
- *
132
- * @param nextMsgSeqNum - The next message sequence number.
133
- * @returns {number} - The next message sequence number.
134
- */
135
- setNextMsgSeqNum(nextMsgSeqNum) {
136
- if (nextMsgSeqNum <= 0) {
137
- throw new Error("Message sequence number must be positive.");
138
- }
139
- this.nextMsgSeqNum = nextMsgSeqNum;
140
- return this.nextMsgSeqNum;
141
- }
142
- /**
143
- * Get the next message sequence number.
144
- *
145
- * @returns {number} - The next message sequence number.
146
- */
147
- getNextMsgSeqNum() {
148
- return this.nextMsgSeqNum;
149
- }
150
- };
151
-
152
- // src/uuidv4.ts
153
- var randomIterator = 0;
154
- var timeBasedRandom = (min, max) => {
155
- const timeNow = Date.now() % 1e3;
156
- randomIterator++;
157
- let x = timeNow ^ randomIterator;
158
- x ^= x << 21;
159
- x ^= x >>> 35;
160
- x ^= x << 4;
161
- const timeBasedRandom2 = Math.abs(x % (max - min + 1));
162
- return min + timeBasedRandom2;
163
- };
164
- var uuidv4 = () => {
165
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
166
- const r = timeBasedRandom(0, 15);
167
- const v = c === "x" ? r : r & 3 | 8;
168
- return v.toString(16);
169
- });
170
- };
171
- export {
172
- MessageBuffer,
173
- uuidv4
174
- };
1
+ var i=class{nextMsgSeqNum=1;buffer=[];maxBufferSize;constructor(e=2500){this.maxBufferSize=e}add(e){this.buffer.length===this.maxBufferSize&&this.buffer.pop(),this.buffer.unshift(e)}getByMsgSequence(e){let t=this.buffer.findIndex(r=>r.messageSequence===e);if(t>-1)return this.buffer[t]}remove(e){let t=this.buffer.findIndex(r=>r.messageSequence===e);t>-1&&this.buffer.splice(t,1)}update(e,t){let r=this.buffer.findIndex(s=>s.messageSequence===e);return r>-1?(this.buffer[r]=t,!0):!1}getAll(){return this.buffer}exists(e){return this.buffer.some(t=>t.messageSequence===e)}size(){return this.buffer.length}resize(e){this.maxBufferSize=e,this.buffer.length>this.maxBufferSize&&(this.buffer=this.buffer.slice(0,this.maxBufferSize))}clear(){this.buffer=[]}getCapacity(){return this.maxBufferSize}setNextMsgSeqNum(e){if(e<=0)throw new Error("Message sequence number must be positive.");return this.nextMsgSeqNum=e,this.nextMsgSeqNum}getNextMsgSeqNum(){return this.nextMsgSeqNum}};var n=0,f=(u,e)=>{let t=Date.now()%1e3;n++;let r=t^n;r^=r<<21,r^=r>>>35,r^=r<<4;let s=Math.abs(r%(e-u+1));return u+s},x=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,u=>{let e=f(0,15);return(u==="x"?e:e&3|8).toString(16)});export{i as MessageBuffer,x as uuidv4};
175
2
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/MessageBuffer.ts", "../../src/uuidv4.ts"],
4
4
  "sourcesContent": ["import type { IMessageStore } from './IMessageStore';\n\n/**\n * A buffer that stores items of type `T` up to a specified maximum size.\n * Implements the IMessageStore interface for generic types.\n */\nexport class MessageBuffer<T> implements IMessageStore<T> {\n /**\n * A number representing the next expected message sequence number.\n * @private\n */\n private nextMsgSeqNum = 1;\n\n /**\n * An array holding the items in the buffer.\n * @private\n */\n private buffer: T[] = [];\n\n /**\n * The maximum capacity of the buffer.\n * @private\n */\n private maxBufferSize: number;\n\n constructor(maxBufferSize = 2500) {\n this.maxBufferSize = maxBufferSize;\n }\n\n /**\n * Adds a new item to the buffer.\n * If the buffer is full, the oldest item is removed to make space for the new one.\n *\n * @param {T} item - The item to add to the buffer.\n * @returns {void}\n */\n public add(item: T): void {\n if (this.buffer.length === this.maxBufferSize) {\n this.buffer.pop();\n }\n this.buffer.unshift(item);\n }\n\n /**\n * Retrieves an item from the buffer by its sequence number (or any other identifier).\n *\n * @param {number} msgSequence - The sequence number of the item to retrieve.\n * @returns {T | undefined} The item if found, or `undefined` if not found.\n */\n public getByMsgSequence(msgSequence: number): T | undefined {\n const index: number = this.buffer.findIndex((item: any) => item.messageSequence === msgSequence);\n if (index > -1) {\n return this.buffer[index];\n }\n return undefined;\n }\n\n /**\n * Removes an item from the buffer by its sequence number.\n *\n * @param {number} msgSequence - The sequence number of the item to remove.\n * @returns {void}\n */\n public remove(msgSequence: number): void {\n const index: number = this.buffer.findIndex((item: any) => item.messageSequence === msgSequence);\n if (index > -1) {\n this.buffer.splice(index, 1);\n }\n }\n\n /**\n * Updates an item in the buffer.\n *\n * @param {number} msgSequence - The sequence number of the item to update.\n * @param {T} item - The updated item.\n * @returns {boolean} - Returns `true` if the item was updated successfully, `false` otherwise.\n */\n public update(msgSequence: number, item: T): boolean {\n const index: number = this.buffer.findIndex(\n (existingItem: any) => existingItem.messageSequence === msgSequence,\n );\n if (index > -1) {\n this.buffer[index] = item;\n return true;\n }\n return false;\n }\n\n /**\n * Retrieves all items from the buffer.\n *\n * @returns {T[]} - An array of all items in the buffer.\n */\n public getAll(): T[] {\n return this.buffer;\n }\n\n /**\n * Checks if an item with a given sequence number exists in the buffer.\n *\n * @param {number} msgSequence - The sequence number of the item to check.\n * @returns {boolean} - `true` if the item exists, `false` otherwise.\n */\n public exists(msgSequence: number): boolean {\n return this.buffer.some((item: any) => item.messageSequence === msgSequence);\n }\n\n /**\n * Gets the current size of the buffer (the number of items it contains).\n *\n * @returns {number} The number of items currently in the buffer.\n */\n public size(): number {\n return this.buffer.length;\n }\n\n /**\n * Resizes the buffer's capacity.\n *\n * @param {number} newCapacity - The new maximum capacity for the buffer.\n * @returns {void}\n */\n public resize(newCapacity: number): void {\n this.maxBufferSize = newCapacity;\n // If the buffer is larger than the new capacity, trim it.\n if (this.buffer.length > this.maxBufferSize) {\n this.buffer = this.buffer.slice(0, this.maxBufferSize);\n }\n }\n\n /**\n * Clears all items from the buffer.\n *\n * @returns {void}\n */\n public clear(): void {\n this.buffer = [];\n }\n\n /**\n * Gets the maximum capacity of the buffer.\n *\n * @returns {number} The maximum number of items the buffer can hold.\n */\n public getCapacity(): number {\n return this.maxBufferSize;\n }\n\n /**\n * Set the next message sequence number.\n *\n * @param nextMsgSeqNum - The next message sequence number.\n * @returns {number} - The next message sequence number.\n */\n public setNextMsgSeqNum(nextMsgSeqNum: number): number {\n if (nextMsgSeqNum <= 0) {\n throw new Error('Message sequence number must be positive.');\n }\n this.nextMsgSeqNum = nextMsgSeqNum;\n return this.nextMsgSeqNum;\n }\n\n /**\n * Get the next message sequence number.\n *\n * @returns {number} - The next message sequence number.\n */\n public getNextMsgSeqNum(): number {\n return this.nextMsgSeqNum;\n }\n}\n", "let randomIterator = 0;\nconst timeBasedRandom = (min: number, max: number): number => {\n const timeNow = Date.now() % 1000;\n randomIterator++;\n let x = timeNow ^ randomIterator;\n x ^= x << 21;\n x ^= x >>> 35;\n x ^= x << 4;\n const timeBasedRandom = Math.abs(x % (max - min + 1));\n return min + timeBasedRandom;\n};\n\nexport const uuidv4 = (): string => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = timeBasedRandom(0, 15);\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n};\n"],
5
- "mappings": ";AAMO,IAAM,gBAAN,MAAmD;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9C,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhB,SAAc,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMf;AAAA,EAER,YAAY,gBAAgB,MAAM;AAC9B,SAAK,gBAAgB;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,IAAI,MAAe;AACtB,QAAI,KAAK,OAAO,WAAW,KAAK,eAAe;AAC3C,WAAK,OAAO,IAAI;AAAA,IACpB;AACA,SAAK,OAAO,QAAQ,IAAI;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,iBAAiB,aAAoC;AACxD,UAAM,QAAgB,KAAK,OAAO,UAAU,CAAC,SAAc,KAAK,oBAAoB,WAAW;AAC/F,QAAI,QAAQ,IAAI;AACZ,aAAO,KAAK,OAAO,KAAK;AAAA,IAC5B;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,OAAO,aAA2B;AACrC,UAAM,QAAgB,KAAK,OAAO,UAAU,CAAC,SAAc,KAAK,oBAAoB,WAAW;AAC/F,QAAI,QAAQ,IAAI;AACZ,WAAK,OAAO,OAAO,OAAO,CAAC;AAAA,I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O,OAAOC,EAA8B,CACxC,OAAO,KAAK,OAAO,KAAMD,GAAcA,EAAK,kBAAoBC,CAAW,CAC/E,CAOO,MAAe,CAClB,OAAO,KAAK,OAAO,MACvB,CAQO,OAAOG,EAA2B,CACrC,KAAK,cAAgBA,EAEjB,KAAK,OAAO,OAAS,KAAK,gBAC1B,KAAK,OAAS,KAAK,OAAO,MAAM,EAAG,KAAK,aAAa,EAE7D,CAOO,OAAc,CACjB,KAAK,OAAS,CAAC,CACnB,CAOO,aAAsB,CACzB,OAAO,KAAK,aAChB,CAQO,iBAAiBC,EAA+B,CACnD,GAAIA,GAAiB,EACjB,MAAM,IAAI,MAAM,2CAA2C,EAE/D,YAAK,cAAgBA,EACd,KAAK,aAChB,CAOO,kBAA2B,CAC9B,OAAO,KAAK,aAChB,CACJ,EC1KA,IAAIC,EAAiB,EACfC,EAAkB,CAACC,EAAaC,IAAwB,CAC1D,IAAMC,EAAU,KAAK,IAAI,EAAI,IAC7BJ,IACA,IAAIK,EAAID,EAAUJ,EAClBK,GAAKA,GAAK,GACVA,GAAKA,IAAM,GACXA,GAAKA,GAAK,EACV,IAAMJ,EAAkB,KAAK,IAAII,GAAKF,EAAMD,EAAM,EAAE,EACpD,OAAOA,EAAMD,CACjB,EAEaK,EAAS,IACX,uCAAuC,QAAQ,QAAUC,GAAM,CAClE,IAAMC,EAAIP,EAAgB,EAAG,EAAE,EAE/B,OADUM,IAAM,IAAMC,EAAKA,EAAI,EAAO,GAC7B,SAAS,EAAE,CACxB,CAAC",
6
+ "names": ["MessageBuffer", "maxBufferSize", "item", "msgSequence", "index", "existingItem", "newCapacity", "nextMsgSeqNum", "randomIterator", "timeBasedRandom", "min", "max", "timeNow", "x", "uuidv4", "c", "r"]
7
7
  }
@@ -1,175 +1,2 @@
1
- // src/MessageBuffer.ts
2
- var MessageBuffer = class {
3
- /**
4
- * A number representing the next expected message sequence number.
5
- * @private
6
- */
7
- nextMsgSeqNum = 1;
8
- /**
9
- * An array holding the items in the buffer.
10
- * @private
11
- */
12
- buffer = [];
13
- /**
14
- * The maximum capacity of the buffer.
15
- * @private
16
- */
17
- maxBufferSize;
18
- constructor(maxBufferSize = 2500) {
19
- this.maxBufferSize = maxBufferSize;
20
- }
21
- /**
22
- * Adds a new item to the buffer.
23
- * If the buffer is full, the oldest item is removed to make space for the new one.
24
- *
25
- * @param {T} item - The item to add to the buffer.
26
- * @returns {void}
27
- */
28
- add(item) {
29
- if (this.buffer.length === this.maxBufferSize) {
30
- this.buffer.pop();
31
- }
32
- this.buffer.unshift(item);
33
- }
34
- /**
35
- * Retrieves an item from the buffer by its sequence number (or any other identifier).
36
- *
37
- * @param {number} msgSequence - The sequence number of the item to retrieve.
38
- * @returns {T | undefined} The item if found, or `undefined` if not found.
39
- */
40
- getByMsgSequence(msgSequence) {
41
- const index = this.buffer.findIndex((item) => item.messageSequence === msgSequence);
42
- if (index > -1) {
43
- return this.buffer[index];
44
- }
45
- return void 0;
46
- }
47
- /**
48
- * Removes an item from the buffer by its sequence number.
49
- *
50
- * @param {number} msgSequence - The sequence number of the item to remove.
51
- * @returns {void}
52
- */
53
- remove(msgSequence) {
54
- const index = this.buffer.findIndex((item) => item.messageSequence === msgSequence);
55
- if (index > -1) {
56
- this.buffer.splice(index, 1);
57
- }
58
- }
59
- /**
60
- * Updates an item in the buffer.
61
- *
62
- * @param {number} msgSequence - The sequence number of the item to update.
63
- * @param {T} item - The updated item.
64
- * @returns {boolean} - Returns `true` if the item was updated successfully, `false` otherwise.
65
- */
66
- update(msgSequence, item) {
67
- const index = this.buffer.findIndex(
68
- (existingItem) => existingItem.messageSequence === msgSequence
69
- );
70
- if (index > -1) {
71
- this.buffer[index] = item;
72
- return true;
73
- }
74
- return false;
75
- }
76
- /**
77
- * Retrieves all items from the buffer.
78
- *
79
- * @returns {T[]} - An array of all items in the buffer.
80
- */
81
- getAll() {
82
- return this.buffer;
83
- }
84
- /**
85
- * Checks if an item with a given sequence number exists in the buffer.
86
- *
87
- * @param {number} msgSequence - The sequence number of the item to check.
88
- * @returns {boolean} - `true` if the item exists, `false` otherwise.
89
- */
90
- exists(msgSequence) {
91
- return this.buffer.some((item) => item.messageSequence === msgSequence);
92
- }
93
- /**
94
- * Gets the current size of the buffer (the number of items it contains).
95
- *
96
- * @returns {number} The number of items currently in the buffer.
97
- */
98
- size() {
99
- return this.buffer.length;
100
- }
101
- /**
102
- * Resizes the buffer's capacity.
103
- *
104
- * @param {number} newCapacity - The new maximum capacity for the buffer.
105
- * @returns {void}
106
- */
107
- resize(newCapacity) {
108
- this.maxBufferSize = newCapacity;
109
- if (this.buffer.length > this.maxBufferSize) {
110
- this.buffer = this.buffer.slice(0, this.maxBufferSize);
111
- }
112
- }
113
- /**
114
- * Clears all items from the buffer.
115
- *
116
- * @returns {void}
117
- */
118
- clear() {
119
- this.buffer = [];
120
- }
121
- /**
122
- * Gets the maximum capacity of the buffer.
123
- *
124
- * @returns {number} The maximum number of items the buffer can hold.
125
- */
126
- getCapacity() {
127
- return this.maxBufferSize;
128
- }
129
- /**
130
- * Set the next message sequence number.
131
- *
132
- * @param nextMsgSeqNum - The next message sequence number.
133
- * @returns {number} - The next message sequence number.
134
- */
135
- setNextMsgSeqNum(nextMsgSeqNum) {
136
- if (nextMsgSeqNum <= 0) {
137
- throw new Error("Message sequence number must be positive.");
138
- }
139
- this.nextMsgSeqNum = nextMsgSeqNum;
140
- return this.nextMsgSeqNum;
141
- }
142
- /**
143
- * Get the next message sequence number.
144
- *
145
- * @returns {number} - The next message sequence number.
146
- */
147
- getNextMsgSeqNum() {
148
- return this.nextMsgSeqNum;
149
- }
150
- };
151
-
152
- // src/uuidv4.ts
153
- var randomIterator = 0;
154
- var timeBasedRandom = (min, max) => {
155
- const timeNow = Date.now() % 1e3;
156
- randomIterator++;
157
- let x = timeNow ^ randomIterator;
158
- x ^= x << 21;
159
- x ^= x >>> 35;
160
- x ^= x << 4;
161
- const timeBasedRandom2 = Math.abs(x % (max - min + 1));
162
- return min + timeBasedRandom2;
163
- };
164
- var uuidv4 = () => {
165
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
166
- const r = timeBasedRandom(0, 15);
167
- const v = c === "x" ? r : r & 3 | 8;
168
- return v.toString(16);
169
- });
170
- };
171
- export {
172
- MessageBuffer,
173
- uuidv4
174
- };
1
+ var i=class{nextMsgSeqNum=1;buffer=[];maxBufferSize;constructor(e=2500){this.maxBufferSize=e}add(e){this.buffer.length===this.maxBufferSize&&this.buffer.pop(),this.buffer.unshift(e)}getByMsgSequence(e){let t=this.buffer.findIndex(r=>r.messageSequence===e);if(t>-1)return this.buffer[t]}remove(e){let t=this.buffer.findIndex(r=>r.messageSequence===e);t>-1&&this.buffer.splice(t,1)}update(e,t){let r=this.buffer.findIndex(s=>s.messageSequence===e);return r>-1?(this.buffer[r]=t,!0):!1}getAll(){return this.buffer}exists(e){return this.buffer.some(t=>t.messageSequence===e)}size(){return this.buffer.length}resize(e){this.maxBufferSize=e,this.buffer.length>this.maxBufferSize&&(this.buffer=this.buffer.slice(0,this.maxBufferSize))}clear(){this.buffer=[]}getCapacity(){return this.maxBufferSize}setNextMsgSeqNum(e){if(e<=0)throw new Error("Message sequence number must be positive.");return this.nextMsgSeqNum=e,this.nextMsgSeqNum}getNextMsgSeqNum(){return this.nextMsgSeqNum}};var n=0,f=(u,e)=>{let t=Date.now()%1e3;n++;let r=t^n;r^=r<<21,r^=r>>>35,r^=r<<4;let s=Math.abs(r%(e-u+1));return u+s},x=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,u=>{let e=f(0,15);return(u==="x"?e:e&3|8).toString(16)});export{i as MessageBuffer,x as uuidv4};
175
2
  //# sourceMappingURL=index.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/MessageBuffer.ts", "../../src/uuidv4.ts"],
4
4
  "sourcesContent": ["import type { IMessageStore } from './IMessageStore';\n\n/**\n * A buffer that stores items of type `T` up to a specified maximum size.\n * Implements the IMessageStore interface for generic types.\n */\nexport class MessageBuffer<T> implements IMessageStore<T> {\n /**\n * A number representing the next expected message sequence number.\n * @private\n */\n private nextMsgSeqNum = 1;\n\n /**\n * An array holding the items in the buffer.\n * @private\n */\n private buffer: T[] = [];\n\n /**\n * The maximum capacity of the buffer.\n * @private\n */\n private maxBufferSize: number;\n\n constructor(maxBufferSize = 2500) {\n this.maxBufferSize = maxBufferSize;\n }\n\n /**\n * Adds a new item to the buffer.\n * If the buffer is full, the oldest item is removed to make space for the new one.\n *\n * @param {T} item - The item to add to the buffer.\n * @returns {void}\n */\n public add(item: T): void {\n if (this.buffer.length === this.maxBufferSize) {\n this.buffer.pop();\n }\n this.buffer.unshift(item);\n }\n\n /**\n * Retrieves an item from the buffer by its sequence number (or any other identifier).\n *\n * @param {number} msgSequence - The sequence number of the item to retrieve.\n * @returns {T | undefined} The item if found, or `undefined` if not found.\n */\n public getByMsgSequence(msgSequence: number): T | undefined {\n const index: number = this.buffer.findIndex((item: any) => item.messageSequence === msgSequence);\n if (index > -1) {\n return this.buffer[index];\n }\n return undefined;\n }\n\n /**\n * Removes an item from the buffer by its sequence number.\n *\n * @param {number} msgSequence - The sequence number of the item to remove.\n * @returns {void}\n */\n public remove(msgSequence: number): void {\n const index: number = this.buffer.findIndex((item: any) => item.messageSequence === msgSequence);\n if (index > -1) {\n this.buffer.splice(index, 1);\n }\n }\n\n /**\n * Updates an item in the buffer.\n *\n * @param {number} msgSequence - The sequence number of the item to update.\n * @param {T} item - The updated item.\n * @returns {boolean} - Returns `true` if the item was updated successfully, `false` otherwise.\n */\n public update(msgSequence: number, item: T): boolean {\n const index: number = this.buffer.findIndex(\n (existingItem: any) => existingItem.messageSequence === msgSequence,\n );\n if (index > -1) {\n this.buffer[index] = item;\n return true;\n }\n return false;\n }\n\n /**\n * Retrieves all items from the buffer.\n *\n * @returns {T[]} - An array of all items in the buffer.\n */\n public getAll(): T[] {\n return this.buffer;\n }\n\n /**\n * Checks if an item with a given sequence number exists in the buffer.\n *\n * @param {number} msgSequence - The sequence number of the item to check.\n * @returns {boolean} - `true` if the item exists, `false` otherwise.\n */\n public exists(msgSequence: number): boolean {\n return this.buffer.some((item: any) => item.messageSequence === msgSequence);\n }\n\n /**\n * Gets the current size of the buffer (the number of items it contains).\n *\n * @returns {number} The number of items currently in the buffer.\n */\n public size(): number {\n return this.buffer.length;\n }\n\n /**\n * Resizes the buffer's capacity.\n *\n * @param {number} newCapacity - The new maximum capacity for the buffer.\n * @returns {void}\n */\n public resize(newCapacity: number): void {\n this.maxBufferSize = newCapacity;\n // If the buffer is larger than the new capacity, trim it.\n if (this.buffer.length > this.maxBufferSize) {\n this.buffer = this.buffer.slice(0, this.maxBufferSize);\n }\n }\n\n /**\n * Clears all items from the buffer.\n *\n * @returns {void}\n */\n public clear(): void {\n this.buffer = [];\n }\n\n /**\n * Gets the maximum capacity of the buffer.\n *\n * @returns {number} The maximum number of items the buffer can hold.\n */\n public getCapacity(): number {\n return this.maxBufferSize;\n }\n\n /**\n * Set the next message sequence number.\n *\n * @param nextMsgSeqNum - The next message sequence number.\n * @returns {number} - The next message sequence number.\n */\n public setNextMsgSeqNum(nextMsgSeqNum: number): number {\n if (nextMsgSeqNum <= 0) {\n throw new Error('Message sequence number must be positive.');\n }\n this.nextMsgSeqNum = nextMsgSeqNum;\n return this.nextMsgSeqNum;\n }\n\n /**\n * Get the next message sequence number.\n *\n * @returns {number} - The next message sequence number.\n */\n public getNextMsgSeqNum(): number {\n return this.nextMsgSeqNum;\n }\n}\n", "let randomIterator = 0;\nconst timeBasedRandom = (min: number, max: number): number => {\n const timeNow = Date.now() % 1000;\n randomIterator++;\n let x = timeNow ^ randomIterator;\n x ^= x << 21;\n x ^= x >>> 35;\n x ^= x << 4;\n const timeBasedRandom = Math.abs(x % (max - min + 1));\n return min + timeBasedRandom;\n};\n\nexport const uuidv4 = (): string => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxx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Ac,CACjB,KAAK,OAAS,CAAC,CACnB,CAOO,aAAsB,CACzB,OAAO,KAAK,aAChB,CAQO,iBAAiBC,EAA+B,CACnD,GAAIA,GAAiB,EACjB,MAAM,IAAI,MAAM,2CAA2C,EAE/D,YAAK,cAAgBA,EACd,KAAK,aAChB,CAOO,kBAA2B,CAC9B,OAAO,KAAK,aAChB,CACJ,EC1KA,IAAIC,EAAiB,EACfC,EAAkB,CAACC,EAAaC,IAAwB,CAC1D,IAAMC,EAAU,KAAK,IAAI,EAAI,IAC7BJ,IACA,IAAIK,EAAID,EAAUJ,EAClBK,GAAKA,GAAK,GACVA,GAAKA,IAAM,GACXA,GAAKA,GAAK,EACV,IAAMJ,EAAkB,KAAK,IAAII,GAAKF,EAAMD,EAAM,EAAE,EACpD,OAAOA,EAAMD,CACjB,EAEaK,EAAS,IACX,uCAAuC,QAAQ,QAAUC,GAAM,CAClE,IAAMC,EAAIP,EAAgB,EAAG,EAAE,EAE/B,OADUM,IAAM,IAAMC,EAAKA,EAAI,EAAO,GAC7B,SAAS,EAAE,CACxB,CAAC",
6
+ "names": ["MessageBuffer", "maxBufferSize", "item", "msgSequence", "index", "existingItem", "newCapacity", "nextMsgSeqNum", "randomIterator", "timeBasedRandom", "min", "max", "timeNow", "x", "uuidv4", "c", "r"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fixparser-common",
3
- "version": "9.2.3-df68ad37",
3
+ "version": "9.3.0-bb19a1db",
4
4
  "description": "FIXParser shared codebase",
5
5
  "files": [
6
6
  "./build/",