From 2a65196a0b1a8287fe0a38849b844d323cde75ac Mon Sep 17 00:00:00 2001 From: Tyler Fehr Date: Fri, 17 May 2024 16:44:06 -0400 Subject: [PATCH] more cleanup --- .gitignore | 3 ++- src/cvm.ts | 6 +++--- src/readfile.ts | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b512c09..0771922 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +/dist \ No newline at end of file diff --git a/src/cvm.ts b/src/cvm.ts index 51e338d..cbe50f2 100644 --- a/src/cvm.ts +++ b/src/cvm.ts @@ -12,7 +12,7 @@ export class CVM { this.probability = 1; } - processLine(...words: string[]): void { + processLine(words: string[]): void { for (const w of words) { const idxToRemove = this.buffer.findIndex((b) => b.toLowerCase() === w.toLowerCase()); @@ -35,12 +35,12 @@ export class CVM { } } - getBufferLength() { + getBufferLength(): number { return this.buffer.reduce((acc, curr) => curr !== '' ? acc + 1 : acc, 0); } clearApproxHalfBuffer(): void { - this.buffer = this.buffer.map((b) => Math.random() < this.probability ? b : ''); + this.buffer = this.buffer.map((b) => Math.random() < 0.5 ? b : ''); } calculateFinalResult(): number { diff --git a/src/readfile.ts b/src/readfile.ts index d39eedf..4d19eb2 100644 --- a/src/readfile.ts +++ b/src/readfile.ts @@ -18,7 +18,5 @@ export const getHandleReadLine = (cvm: CVM) => (line: string) => { const words = line.split(/\s+/); // remove all punctuation that would interfere with unique word count - cvm.processLine( - ...words.map(stripWordPunctuation) - ); + cvm.processLine(words.map(stripWordPunctuation)); };