From: Jérôme Benoit Date: Fri, 20 Nov 2020 08:22:39 +0000 (+0100) Subject: Finish circular array implementation. X-Git-Tag: v1.0.1-0~189 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c70ff58d5ec605bff39e24b77c2bc1e43834b914;p=e-mobility-charging-stations-simulator.git Finish circular array implementation. Signed-off-by: Jérôme Benoit --- diff --git a/package-lock.json b/package-lock.json index 064f931c..2cb919f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10647,9 +10647,9 @@ } }, "typescript": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.2.tgz", - "integrity": "sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz", + "integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==", "dev": true }, "ultron": { diff --git a/package.json b/package.json index 67b3d25f..c4ade427 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,6 @@ "npm-check": "^5.9.2", "rimraf": "^3.0.2", "ts-node-dev": "^1.0.0", - "typescript": "^4.1.2" + "typescript": "^4.0.5" } } diff --git a/src/utils/CircularArray.ts b/src/utils/CircularArray.ts index 434a8f49..12aa2b18 100644 --- a/src/utils/CircularArray.ts +++ b/src/utils/CircularArray.ts @@ -21,4 +21,16 @@ export default class CircularArray extends Array { } return super.unshift(...items); } + + concat(...items: (T|ConcatArray)[]): T[] { + if (this.length + items.length > this.size) { + super.splice(0, (this.length + items.length) - this.size); + } + return super.concat(items as T[]); + } + + splice(start: number, deleteCount?: number, ...items: T[]): T[] { + this.push(...items); + return super.splice(start, deleteCount); + } }