key-value-file
Version:
A simple key/value file parser/writer
25 lines • 843 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseString = exports.parseFile = void 0;
const tokenize_1 = require("./tokenize");
const keyvalue_1 = require("./keyvalue");
const keyvaluefile_1 = require("./keyvaluefile");
const fs_1 = require("./fs");
/**
* Create a {@link KeyValueFile} instance from the file of `path`
*/
async function parseFile(path) {
if (!(await (0, fs_1.exists)(path))) {
throw new Error(`ENOENT, no such file or directory '${path}'`);
}
return keyvaluefile_1.KeyValueFile.create(path);
}
exports.parseFile = parseFile;
/**
* Create a {@link KeyValue} instance from the string `data`
*/
function parseString(data) {
return new keyvalue_1.KeyValue((0, tokenize_1.tokenize)(data));
}
exports.parseString = parseString;
//# sourceMappingURL=methods.js.map