Files
morten-olsen.github.io/bin/resources/file/index.ts
Morten Olsen 9b1a067d56 init
2023-03-27 10:46:18 +02:00

20 lines
366 B
TypeScript

import { readFile } from "fs/promises";
import { Observable } from "../../observable";
import { watch } from "fs";
type FileOptions = {
path: string;
};
const createFile = ({ path }: FileOptions) => {
const file = new Observable(async () => readFile(path, "utf-8"));
watch(path, () => {
file.recreate();
});
return file;
};
export { createFile };