Make CircularArray class self-contained and an independant module.
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 23 Nov 2020 20:55:03 +0000 (21:55 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 23 Nov 2020 20:55:03 +0000 (21:55 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/assets/configs-aws
src/utils/CircularArray.ts
src/utils/Constants.ts

index b042164ef7144070be0fe1af2ce310bc512803aa..c08cc2beb3cbed8907a2f1c84ea7bc698131714c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b042164ef7144070be0fe1af2ce310bc512803aa
+Subproject commit c08cc2beb3cbed8907a2f1c84ea7bc698131714c
index 12aa2b18c7c8c853804d0c6d812506a84090aa62..319b6924e4494b6ca83c55ee5d4cc576a27f5d67 100644 (file)
@@ -1,11 +1,11 @@
-import Constants from './Constants';
 
 export default class CircularArray<T> extends Array<T> {
   public size: number;
+  private readonly MAXIMUM_CIRCULAR_ARRAY_SIZE = 2000;
 
-  constructor(size: number = Constants.MAXIMUM_MEASUREMENTS_NUMBER) {
+  constructor(size?: number) {
     super();
-    this.size = size;
+    this.size = size && size <= this.MAXIMUM_CIRCULAR_ARRAY_SIZE ? size : this.MAXIMUM_CIRCULAR_ARRAY_SIZE;
   }
 
   push(...items: T[]): number {
index 56652b374e5ff0c301218c1eea7cb8d683274c92..eab54ea5fe962be57997184ff6997d96d96780c5 100644 (file)
@@ -50,7 +50,5 @@ export default class Constants {
   static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // Ms
   static readonly CHARGING_STATION_ATG_WAIT_TIME = 2000; // Ms
 
-  static readonly MAXIMUM_MEASUREMENTS_NUMBER = 2000;
-
   static readonly TRANSACTION_DEFAULT_IDTAG = '00000000';
 }