@geek/jsonc
Advanced tools
Comparing version 1.0.5 to 1.0.6
15
jsonc.js
const jsonc = {}; | ||
const _ = require(`lodash`); | ||
const fs = require(`fs-extra`); | ||
module.exports = jsonc; | ||
@@ -21,2 +23,15 @@ | ||
jsonc.readJsonc = async (file, options = {}) => { | ||
const content = await fs.readFile(file, `utf8`); | ||
const errors = []; | ||
const { allowTrailingComma, allowEmptyContent, disallowComments } = options; | ||
const json = jsonc.parse(content, errors, { allowTrailingComma, allowEmptyContent, disallowComments }); | ||
if (errors.length && options.throwErrors) { | ||
throw errors[0]; | ||
} | ||
return json; | ||
}; | ||
{ | ||
"name": "@geek/jsonc", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "JSONC and JSON utilities for JavaScript with Node.js", | ||
@@ -5,0 +5,0 @@ "main": "jsonc.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10486
115
7