@stryke/fs
Version:
A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.
51 lines (49 loc) • 1.67 kB
JavaScript
import { readFile, readFileSync } from "./read-file.mjs";
import { writeFile, writeFileSync } from "./write-file.mjs";
import TOML from "smol-toml";
//#region src/toml.ts
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param options - TOML parse options
* @returns Object the TOML content of the file represents
*/
function readTomlFileSync(path, options) {
const content = readFileSync(path);
return TOML.parse(content, options);
}
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param options - TOML parse options
* @returns Object the TOML content of the file represents
*/
async function readTomlFile(path, options) {
const content = await readFile(path);
return TOML.parse(content, options);
}
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param data - data which should be serialized/formatted to TOML and written to the file
* @param options - TOML parse options
*/
function writeTomlFileSync(path, data, options) {
return writeFileSync(path, TOML.stringify(data, options));
}
/**
* Reads a TOML file and returns the object the TOML content represents.
*
* @param path - A path to a file.
* @param data - data which should be serialized/formatted to TOML and written to the file
* @param options - TOML parse options
*/
async function writeTomlFile(path, data, options) {
return writeFile(path, TOML.stringify(data, options));
}
//#endregion
export { readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync };
//# sourceMappingURL=toml.mjs.map