Tabnine Logo For Javascript
js-yaml
Code IndexAdd Tabnine to your IDE (free)

How to use js-yaml

Best JavaScript code snippets using js-yaml(Showing top 15 results out of 522)

origin: lando/lando

/*
 * Helper to load landofile
 */
const loadLandoFile = file => {
 try {
  return yaml.safeLoad(fs.readFileSync(file));
 } catch (e) {
  throw new Error(`There was a problem with parsing ${file}. Ensure it is valid YAML! ${e}`);
 }
}
origin: lando/lando

_(files)
 // Filter if file exists
 .filter(fs.existsSync)
 // Start collecting
 .reduce((a, file) => exports.merge(a, yaml.safeLoad(fs.readFileSync(file))), {})
origin: airtap/airtap

function toYAML (value) {
 return yaml.safeDump(value, { noRefs: true }).trim()
}
origin: lando/lando

load(data) {
  return yaml.load(data, {schema: this.PLATFORM_SCHEMA});
 }
origin: lando/lando

_(files)
 .filter(file => fs.existsSync(file))
 .map(file => yaml.safeLoad(fs.readFileSync(file)))
 .thru(data => _.merge({}, ...data))
 .thru(data => {
  // Set the php version
  // @TODO: what is the best version here?
  data.php = _.toString(_.get(data, 'php_version', '5.6'));
  // Set the webroot
  data.webroot = (_.get(data, 'web_docroot', false)) ? 'web' : '.';
  // Set the drush version
  data.drush = _.toString(_.get(data, 'drush_version', '8'));
  // if drush version is less than 8, use 8 anyway
  if (data.drush < 8) data.drush = 8;
  // return
  return data;
 })
 .value()
origin: lando/lando

/**
  * Dumps an object to a YAML file
  *
  * @since 3.0.0
  * @alias lando.yaml.dump
  * @param {String} file The path to the file to be loaded
  * @param {Object} data The object to dump
  * @return {String} Flename
  */
 dump(file, data = {}) {
  // Make sure we have a place to store these files
  mkdirp.sync(path.dirname(file));
  // Remove any properties that might be bad and dump
  data = JSON.parse(JSON.stringify(data));
  // And dump
  fs.writeFileSync(file, yaml.safeDump(data));
  // Log and return filename
  return file;
 }
origin: DavidAnson/markdownlint

/**
 * Parses YAML text.
 *
 * @param {string} yaml YAML to parse.
 * @returns {Object} Object representation.
 */
function yamlParse(yaml) {
 return jsYaml.safeLoad(yaml);
}
origin: lando/lando

this.ArchiveYamlType = new yaml.Type('!archive', {
 kind: 'scalar',
 resolve: data => {
this.IncludeYamlType = new yaml.Type('!include', {
 kind: 'mapping',
 resolve: data => {
this.PLATFORM_SCHEMA = yaml.Schema.create([this.ArchiveYamlType, this.IncludeYamlType]);
origin: airtap/airtap

function readYAML (fp) {
 try {
  return yaml.safeLoad(fs.readFileSync(fp, 'utf8'))
 } catch (err) {
  if (err.code !== 'ENOENT') fail(err)
 }
}
origin: lando/lando

/**
  * Loads a yaml object from a file.
  *
  * @since 3.0.0
  * @alias lando.yaml.load
  * @param {String} file The path to the file to be loaded
  * @return {Object} The loaded object
  * @example
  * // Add a string to the cache
  * const thing = lando.yaml.load('/tmp/myfile.yml');
  */
 load(file) {
  try {
   return yaml.safeLoad(fs.readFileSync(file));
  } catch (e) {
   this.log.error('Problem parsing %s with %s', file, e.message);
  }
 }
origin: alibaba/dawn

function stringify(obj) {
 return yaml.safeDump(obj);
}
origin: godaddy/kubernetes-client

function loadKubeconfig (cfgPath) {
 let cfgPaths

 if (!cfgPath) {
  cfgPaths = defaultConfigPaths()
 } else if (Array.isArray(cfgPath)) {
  cfgPaths = cfgPath
 } else {
  cfgPaths = [cfgPath]
 }

 const configs = cfgPaths.map(cfgPath => {
  const config = yaml.safeLoad(fs.readFileSync(cfgPath))
  return mapCertificates(cfgPath, config)
 })

 return merge.all(configs)
}
origin: binci/binci

const getConfig = () => yaml.safeLoad(fs.readFileSync(configPath, 'utf8'))
origin: airtap/airtap

function toYAML (value) {
 return yaml.safeDump(value, { noRefs: true }).trim()
}
origin: alibaba/dawn

function parse(text) {
 return yaml.safeLoad(text, 'utf8');
}
js-yaml(npm)

JSDoc

YAML 1.2 parser and serializer

Most used js-yaml functions

  • safeLoad
  • safeDump
  • load
  • dump
  • YAMLException
  • Schema,
  • Schema.create,
  • Type,
  • default,
  • safeLoadAll

Popular in JavaScript

  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • path
  • handlebars
    Handlebars provides the power necessary to let you build semantic templates effectively with no frustration
  • request
    Simplified HTTP request client.
  • mime-types
    The ultimate javascript content-type utility.
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • moment
    Parse, validate, manipulate, and display dates
  • chalk
    Terminal string styling done right
  • ms
    Tiny millisecond conversion utility
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now