UNPKG

@stryke/fs

Version:

A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.

56 lines (54 loc) 2.04 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('./_virtual/_rolldown/runtime.cjs'); const require_read_file = require('./read-file.cjs'); const require_write_file = require('./write-file.cjs'); let smol_toml = require("smol-toml"); smol_toml = require_runtime.__toESM(smol_toml, 1); //#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 = require_read_file.readFileSync(path); return smol_toml.default.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 require_read_file.readFile(path); return smol_toml.default.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 require_write_file.writeFileSync(path, smol_toml.default.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 require_write_file.writeFile(path, smol_toml.default.stringify(data, options)); } //#endregion exports.readTomlFile = readTomlFile; exports.readTomlFileSync = readTomlFileSync; exports.writeTomlFile = writeTomlFile; exports.writeTomlFileSync = writeTomlFileSync;