Added card generation speed tests (part 2)

ref #14
This commit is contained in:
Nicolai Ort 2021-02-09 19:40:02 +01:00
parent 03c7d590d0
commit d38923c4ad

View File

@ -56,11 +56,11 @@ function idToEan13(id): string {
while (id.length < 12) { id = '0' + id; } while (id.length < 12) { id = '0' + id; }
let total = 0; let total = 0;
this.id.split('').forEach((letter, index) => { id.split('').forEach((letter, index) => {
total += parseInt(letter, 10) * multiply[index % 2]; total += parseInt(letter, 10) * multiply[index % 2];
}); });
const checkSum = (Math.ceil(total / 10) * 10) - total; const checkSum = (Math.ceil(total / 10) * 10) - total;
return this.id + checkSum.toString(); return id + checkSum.toString();
} }
async function postContracts(runners: Runner[]): Promise<Measurement> { async function postContracts(runners: Runner[]): Promise<Measurement> {