Empty string handling fixes
[e-mobility-charging-stations-simulator.git] / src / utils / CircularArray.ts
index 93dacdb0ee8d421f592ff6b05e31ef1b23b9acc4..5fdeeaad1f7e57c2dae60d0c6fe976d623c942bd 100644 (file)
@@ -1,6 +1,10 @@
-export const DEFAULT_CIRCULAR_ARRAY_SIZE = 2000;
+// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
-/** Array with a maximum length shifting items when full. */
+export const DEFAULT_CIRCULAR_ARRAY_SIZE = Number.MAX_SAFE_INTEGER;
+
+/**
+ * Array with a maximum length shifting items when full.
+ */
 export class CircularArray<T> extends Array<T> {
   public size: number;
 
@@ -30,9 +34,7 @@ export class CircularArray<T> extends Array<T> {
   }
 
   public concat(...items: (T | ConcatArray<T>)[]): CircularArray<T> {
-    const concatenatedCircularArray = super.concat(
-      items as T[]
-    ) as CircularArray<T>;
+    const concatenatedCircularArray = super.concat(items as T[]) as CircularArray<T>;
     concatenatedCircularArray.size = this.size;
     if (concatenatedCircularArray.length > concatenatedCircularArray.size) {
       concatenatedCircularArray.splice(
@@ -45,7 +47,7 @@ export class CircularArray<T> extends Array<T> {
 
   public splice(start: number, deleteCount?: number, ...items: T[]): T[] {
     let itemsRemoved: T[];
-    if (arguments.length >= 3 && typeof deleteCount !== 'undefined') {
+    if (arguments.length >= 3 && deleteCount !== undefined) {
       itemsRemoved = super.splice(start, deleteCount);
       // FIXME: that makes the items insert not in place
       this.push(...items);