source: frontend/node_modules/yaml/dist/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.9 KB
Line 
1'use strict';
2
3var parseCst = require('./parse-cst.js');
4var Document$1 = require('./Document-a8d0fbf9.js');
5var Schema = require('./Schema-bcc6c2d7.js');
6var PlainValue = require('./PlainValue-516d5bc2.js');
7var warnings = require('./warnings-793925ce.js');
8require('./resolveSeq-95613e94.js');
9
10function createNode(value, wrapScalars = true, tag) {
11 if (tag === undefined && typeof wrapScalars === 'string') {
12 tag = wrapScalars;
13 wrapScalars = true;
14 }
15 const options = Object.assign({}, Document$1.Document.defaults[Document$1.defaultOptions.version], Document$1.defaultOptions);
16 const schema = new Schema.Schema(options);
17 return schema.createNode(value, wrapScalars, tag);
18}
19class Document extends Document$1.Document {
20 constructor(options) {
21 super(Object.assign({}, Document$1.defaultOptions, options));
22 }
23}
24function parseAllDocuments(src, options) {
25 const stream = [];
26 let prev;
27 for (const cstDoc of parseCst.parse(src)) {
28 const doc = new Document(options);
29 doc.parse(cstDoc, prev);
30 stream.push(doc);
31 prev = doc;
32 }
33 return stream;
34}
35function parseDocument(src, options) {
36 const cst = parseCst.parse(src);
37 const doc = new Document(options).parse(cst[0]);
38 if (cst.length > 1) {
39 const errMsg = 'Source contains multiple documents; please use YAML.parseAllDocuments()';
40 doc.errors.unshift(new PlainValue.YAMLSemanticError(cst[1], errMsg));
41 }
42 return doc;
43}
44function parse(src, options) {
45 const doc = parseDocument(src, options);
46 doc.warnings.forEach(warning => warnings.warn(warning));
47 if (doc.errors.length > 0) throw doc.errors[0];
48 return doc.toJSON();
49}
50function stringify(value, options) {
51 const doc = new Document(options);
52 doc.contents = value;
53 return String(doc);
54}
55const YAML = {
56 createNode,
57 defaultOptions: Document$1.defaultOptions,
58 Document,
59 parse,
60 parseAllDocuments,
61 parseCST: parseCst.parse,
62 parseDocument,
63 scalarOptions: Document$1.scalarOptions,
64 stringify
65};
66
67exports.YAML = YAML;
Note: See TracBrowser for help on using the repository browser.