@foal/core
Version:
Full-featured Node.js framework, with no complexity
19 lines (18 loc) • 559 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInFile = isInFile;
// std
const promises_1 = require("node:fs/promises");
/**
* Generate a function checking if a string is included in a text file.
*
* @export
* @param {string} path - The file path.
* @returns {(content: string) => Promise<boolean>} The generated function.
*/
function isInFile(path) {
return async (content) => {
const fileContent = await (0, promises_1.readFile)(path, 'utf8');
return fileContent.includes(content);
};
}