UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

28 lines (24 loc) 837 B
'use strict'; const utils = require('@visulima/path/utils'); const parseJson = require('./parseJson-5geAXtlm.cjs'); const readFileSync = require('./readFileSync-B3NTOR-W.cjs'); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); function readJsonSync(path, reviver, options) { if (typeof reviver === "object") { options = reviver; reviver = void 0; } const content = readFileSync(path, { buffer: true, encoding: void 0 }); let data = new TextDecoder().decode(content); const { beforeParse, color } = options ?? {}; if (typeof beforeParse === "function") { data = beforeParse(data); } return parseJson(data, reviver, utils.toPath(path), { color }); } __name(readJsonSync, "readJsonSync"); module.exports = readJsonSync;