From 7b5cf59b9979f0da70af0f0ba7dd07c743ec851d Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 12 Feb 2021 14:36:10 +0100 Subject: [PATCH] fix types --- .../static-pages/ciphering/ciphering.component.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts b/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts index e29193fa..639d1fa0 100644 --- a/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts +++ b/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts @@ -25,7 +25,7 @@ export class CipheringComponent implements OnInit { public prem: number; public dico: string[]; public separatedCouples: any[]; - public codingMatrice: string = '2 3 5 8'; + public codingMatrice = '2 3 5 8'; private cipheredTextCIL: string; constructor() { @@ -193,8 +193,12 @@ export class CipheringComponent implements OnInit { * on entre une définition de matrice en écrivant 4 nombres dans un input * @param stringMatrix */ - convertStringToMatrix(stringMatrix: string) { - return stringMatrix.replace(',', ' ').replace(' ', ' ').slice(' '); + convertStringToMatrix(stringMatrix: string): number[] { + return stringMatrix + .replace(',', ' ') + .replace(' ', ' ') + .split(' ') + .map((elem) => parseInt(elem)); } /** @@ -281,8 +285,8 @@ export class CipheringComponent implements OnInit { } getEntropy(s) { - let sum = 0, - len = s.length; + let sum = 0; + const len = s.length; this.process(s, (k, f) => { const p = f / len; sum -= (p * Math.log(p)) / Math.log(2);