fix types

This commit is contained in:
Tykayn 2021-02-12 14:36:10 +01:00 committed by tykayn
parent 54ece76c7e
commit 7b5cf59b99

View File

@ -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);