diff --git a/src/services/check-string-in-file.js b/src/services/check-string-in-file.js new file mode 100644 index 0000000..40d950c --- /dev/null +++ b/src/services/check-string-in-file.js @@ -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; +} \ No newline at end of file