Skip to content

Commit

Permalink
feat: add function to search
Browse files Browse the repository at this point in the history
  • Loading branch information
adantoscano committed Oct 10, 2023
1 parent aade715 commit 24d9256
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/services/check-string-in-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as fs from 'fs';
import * as readline from 'readline';

export default async function(stringToCheck, filePath) {
const reader = readline.createInterface({ input: fs.createReadStream(filePath) });
let exists = false;

for await (const line of reader) {
console.log(line);
if(line===stringToCheck) {
exists = line===stringToCheck
break;
}
}

return exists;
}

0 comments on commit 24d9256

Please # to comment.