hoffmation-base 3.4.8 → 3.4.9

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.
@@ -16,10 +16,15 @@ class RingStorage {
16
16
  }
17
17
  readAmount(amount) {
18
18
  const result = [];
19
- amount = Math.max(amount, this.maxSize);
19
+ // Never return more than requested, and never more than the ring holds.
20
+ amount = Math.min(amount, this.maxSize);
20
21
  let pos = this.pointer;
21
22
  while (amount > 0) {
22
- result.push(this.storage[pos]);
23
+ const entry = this.storage[pos];
24
+ // Slots not written yet must not surface as undefined entries in a T[].
25
+ if (entry !== undefined) {
26
+ result.push(entry);
27
+ }
23
28
  // Um negative Modulo zu umgehen.
24
29
  pos = (((pos - 1) % this.maxSize) + this.maxSize) % this.maxSize;
25
30
  amount--;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hoffmation-base",
3
3
  "description": "Base Libraries and functions for own Hoffmation projects",
4
- "version": "3.4.8",
4
+ "version": "3.4.9",
5
5
  "files": [
6
6
  "lib/**/*"
7
7
  ],