@fcostarodrigo/files
v1.1.0
Published
Wrapper for node read and write files API,
Downloads
2
Readme
Files
Read and write files parsing and formatting according to file extension in the file path.
Install
npm i @fcostarodrigo/files
Features
- Parse file based on extension.
- Format files using prettier.
- Create missing folders when writing files.
Usage
import { writeFile, readFile, fileExist } from "@fcostarodrigo/files";
await writeFile("user.json", { id: 123 });
const user = await readFile("user.json");
user.id; // 123
await fileExist("user.json"); // true
Options
Pass an object with the following properties as the last argument.
extension
: Pretend the file has some extension.parse
: When reading a file, boolean to indicate if file should be parsed.defaultValue
: When reading a file, return default value if file doesn't existformat
: When writing a file, boolean to indicate if file should be formatted.