UNPKG

yaml-server

Version:

A command line tool that creates a REST server from a YAML file that you specify

17 lines (16 loc) 377 B
const YAML = require('yaml'); module.exports = { toJson(content, dialect) { if (dialect === 'yaml') { const doc = YAML.parseDocument(content); json = doc.toJSON(); return json; } return JSON.parse(content); // just return JSON }, transform(content, dialect) { if (dialect === 'yaml') { return YAML.stringify(content); } } }