@ahouse/json5-utilities
v0.4.1
Published
Utility functions for the JSON5 package when running on Node JS.
Downloads
6
Maintainers
Readme
@ahouse/json5-utilities
Utility functions for the JSON5 package, when running on Node JS. Separated from @ahouse/object-utilities in order to remove dependencies from that project.
Installation
Note: This is a JavaScript library, it needs to be added as a dependency to a Node JS project in order to be useful.
npm install @ahouse/json5-utilites
Usage
readFileAsJSON5
Read a file (asynchronously) and parse it as JSON5.
import { readFileAsJSON5 } from '@ahouse/json5-utilities';
import path from 'path';
// Parse 'file.json5' from within the source directory:
readFileAsJSON5(path.join(__dirname, 'file.json5')).then(parsedObject => {
// Use the parsed data here...
});
// Or, using await (must be within an async function):
async function myFunc() {
const parsedObject = await readFileAsJSON5(path.join(__dirname, 'file.json5'));
// Use the parsed data here...
}
Contributing
See contributing.md
.