Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerfehr committed May 17, 2024
1 parent 5978163 commit 2a65196
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
/dist
6 changes: 3 additions & 3 deletions src/cvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/readfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

0 comments on commit 2a65196

Please sign in to comment.