Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
node-read-yaml
Advanced tools
Read and parse a YAML file. A wrapper of js-yaml read file directly.
Read and parse a YAML file. A wrapper of js-yaml
read file directly.
const read = require("node-read-yaml");
const doc = read.sync(filename);
console.log(doc);
same as
const fs = require("fs");
const yaml = require("js-yaml");
const doc = yaml.safeLoad(fs.readFileSync(filename, "utf8"));
console.log(doc);
npm install node-read-yaml
Read a YAML file and parse content as JSON. Returns either a plain object, an array, a string or undefined, or throws YAMLException on error. By default, does not support regexps, functions and undefined. This method is safe for untrusted data. more
options:
multi
(default: false) - If true, then reads file as multi-document and returns an array.onWarning
(default: null) - function to call on warning messages.
Loader will call this function with an instance of YAMLException
for each warning.schema
(default: DEFAULT_SAFE_SCHEMA
) - specifies a schema to use.
FAILSAFE_SCHEMA
- only strings, arrays and plain objects:
http://www.yaml.org/spec/1.2/spec.html#id2802346JSON_SCHEMA
- all JSON-supported types:
http://www.yaml.org/spec/1.2/spec.html#id2803231CORE_SCHEMA
- same as JSON_SCHEMA
:
http://www.yaml.org/spec/1.2/spec.html#id2804923DEFAULT_SAFE_SCHEMA
- all supported YAML types, without unsafe ones
(!!js/undefined
, !!js/regexp
and !!js/function
):
http://yaml.org/type/DEFAULT_FULL_SCHEMA
- all supported YAML types.json
(default: false) - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.asynchronously read a file
const read = require("node-read-yaml");
read("config.yml")
.then((doc) => console.log(doc))
.catch((err) => console.error(err));
wrapper of require('js-yaml').safeLoad
asynchronously read multi-document file
const read = require("node-read-yaml");
read("config.yml", { multi: true })
.then((arr) => arr.forEach((doc) => console.log(doc)))
.catch((err) => console.error(err));
wrapper of require('js-yaml').safeLoadAll
synchronously read a file
const readSync = require("node-read-yaml").sync;
try {
const doc = readSync("config.yml");
console.log(doc);
} catch (err) {
console.log(err);
}
wrapper of require('js-yaml').safeLoad
synchronously read multi-document file
const readSync = require("node-read-yaml").sync;
try {
const arr = readSync("config.yml", { multi: true });
arr.forEach((doc) => console.log(doc));
} catch (err) {
console.log(err);
}
wrapper of require('js-yaml').safeLoadAll
require('js-yaml').YAMLException
Copyright (c) 2019 dailyrandomphoto. Licensed under the MIT license.
FAQs
Read and parse a YAML file. A wrapper of js-yaml read file directly.
We found that node-read-yaml demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.