source: trip-planner-front/node_modules/yaml/dist/index.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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