How to use yamljs

Comprehensive yamljs code examples:

How to use yamljs.default:

9
10
11
12
13
14
15
16
17
18
const types_1 = require("./impl/types");
const path_1 = __importDefault(require("path"));
const body_parser_1 = __importDefault(require("body-parser"));
const index_1 = __importDefault(require("./abstract/index"));
dotenv_1.default.config({ path: path_1.default.resolve(__dirname, "../server.env") });
const swaggerDocument = yamljs_1.default.load(path_1.default.resolve(__dirname, "../openapi.yaml"));
let impl = new types_1.apiImpl();
var options = {
    swaggerOptions: {
        url: "/api-docs/swagger.json",

How to use yamljs.parseFile:

41
42
43
44
45
46
47
48
49
50
 * @param {string} filepath 
 */
RoutesManager.prototype.readRoutesFromFile = function(filepath){
    let routes;
    try{
        routes = YAML.parseFile(filepath);
    }catch(e){
        logger.log.error( filepath + " is an invalid Yaml file or have syntax issues.");
        logger.log.error( e);
    }

How to use yamljs.stringify:

90
91
92
93
94
95
96
97
98
99
  var xml = builder.buildObject(JSON.parse(data));
  done(null, xml);
};

var convertJsonToYml = function(data, options, done) {
  var results = YAML.stringify(JSON.parse(data), options.inline, options.indent);
  done(null, results);
};

var convertJsonToPlist = function(data, options, done) {

How to use yamljs.parse:

89
90
91
92
93
94
95
96
97
98
});

front_matter = front_matter.join('\n');
post = post.join('\n');

metadata = yaml.parse(front_matter);

return _.extend({}, metadata, {
    postBody: marked(post),
    title: metadata.title,

How to use yamljs.load:

5
6
7
8
9
10
11
12
13
14
15
16
const { event } = require('../misc/misc.js')
const { hex2Dec, hex2Ascii, hasData, getAmsTime } = require('../misc/util.js')
const { formatISO } = require('date-fns')


// Load broker and topics preferences from config file
const config = yaml.load(configFile);
const debug = config.DEBUG;


// Aidon constants
const METER_VERSION = "020209060101000281FF0A0B"; // 22