lib/transcode.js
function stringYAML2JSON (doc, compact = false) {
  if (!doc || typeof doc !== 'string') {
    throw new TypeError('Argument must be a string or object, and not empty: ' + doc)
  }

  let obj = yaml.safeLoad(doc)

  if (!obj || typeof obj !== 'object') {
    throw new TypeError('Argument must be in yaml format: ' + doc)
  }

  return JSON.stringify(obj, undefined, compact ? undefined : 2)
}
function stringYAML2JSON (doc, compact = false) {
  if (!doc || typeof doc !== 'string') {
    throw new TypeError('Argument must be a string or object, and not empty: ' + doc)
  }

  let obj = yaml.safeLoad(doc)

  if (!obj || typeof obj !== 'object') {
    throw new TypeError('Argument must be in yaml format: ' + doc)
  }

  return JSON.stringify(obj, undefined, compact ? undefined : 2)
}
function stringYAML2JSON ( doc , compact = false ) { if ( ! doc || typeof doc !== 'string' ) { throw new TypeError ( 'Argument must be a string or object, and not empty: ' + doc ) } let obj = yaml . safeLoad ( doc ) if ( ! obj || typeof obj !== 'object' ) { throw new TypeError ( 'Argument must be in yaml format: ' + doc ) } return JSON . stringify ( obj , undefined , compact ? undefined : 2 ) }
Transcode YAML to JSON string.

@param {string} doc
@param {boolean} [compact]
@return {string}
@api public
Transcode YAML to JSON string .