1.1.1 • Published 6 months ago

@fcostarodrigo/files v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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

The last argument is an object with extra options.

  • extension: Treat the file as if it has a specific extension.
  • parse: Boolean that indicates if the file should be parsed when reading a file.
  • defaultValue: Return default value if file doesn't exist When reading a file.
  • format: Boolean that indicates if the file should be formatted when writing a file.

Available formats

Changelog

Changelog

License

MIT License

1.1.1

6 months ago

1.1.0

1 year ago

1.0.0

2 years ago