opal 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/lib/opal/cli.rb +9 -1
- data/lib/opal/cli_options.rb +12 -3
- data/lib/opal/cli_runners/nodejs.rb +3 -2
- data/lib/opal/version.rb +1 -1
- data/opal/corelib/kernel.rb +7 -0
- data/opal/corelib/runtime.js +4 -0
- data/spec/lib/cli_spec.rb +16 -0
- data/stdlib/nodejs.rb +1 -2
- data/stdlib/nodejs/{process.rb → kernel.rb} +7 -4
- data/stdlib/nodejs/node_modules/.bin/js-yaml +140 -0
- data/stdlib/nodejs/node_modules/glob/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/README.md +357 -0
- data/stdlib/nodejs/node_modules/glob/common.js +177 -0
- data/stdlib/nodejs/node_modules/glob/glob.js +649 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/.eslintrc +17 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/README.md +37 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/inflight.js +44 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md +36 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +52 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js +33 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/package.json +61 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/test.js +97 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/LICENSE +16 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/README.md +42 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/inherits.js +1 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/package.json +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/test.js +25 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/.npmignore +1 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/.travis.yml +4 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/LICENSE +23 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/README.md +216 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/benchmark.js +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/browser.js +1181 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/minimatch.js +845 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +2 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml +3 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +121 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +4 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +73 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +4 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +83 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +75 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js +32 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt +1075 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt +182 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js +9 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js +10 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh +24 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js +16 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js +10 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js +13 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js +7 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js +50 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/package.json +60 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/basic.js +399 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/brace-expand.js +45 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/defaults.js +274 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/LICENSE +27 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/README.md +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +52 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/once.js +21 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/package.json +60 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/test/once.js +23 -0
- data/stdlib/nodejs/node_modules/glob/package.json +72 -0
- data/stdlib/nodejs/node_modules/glob/sync.js +409 -0
- data/stdlib/nodejs/node_modules/js-yaml/HISTORY.md +277 -0
- data/stdlib/nodejs/node_modules/js-yaml/LICENSE +21 -0
- data/stdlib/nodejs/node_modules/js-yaml/README.md +288 -0
- data/stdlib/nodejs/node_modules/js-yaml/bin/js-yaml.js +140 -0
- data/stdlib/nodejs/node_modules/js-yaml/bower.json +23 -0
- data/stdlib/nodejs/node_modules/js-yaml/dist/js-yaml.js +3666 -0
- data/stdlib/nodejs/node_modules/js-yaml/dist/js-yaml.min.js +3 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.js +102 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.yml +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.js +31 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.json +22 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.js +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.yml +197 -0
- data/stdlib/nodejs/node_modules/js-yaml/index.js +7 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml.js +39 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js +62 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/dumper.js +554 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/exception.js +25 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/loader.js +1581 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/mark.js +78 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema.js +103 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/binary.js +133 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/bool.js +37 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/float.js +110 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/int.js +183 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/function.js +85 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +84 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +27 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/null.js +36 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js +56 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/pairs.js +61 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/set.js +33 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +98 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esparse +117 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esvalidate +177 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/HISTORY.md +115 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/LICENSE +21 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/README.md +239 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/arguments.js +36 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/choice.js +22 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/constants.js +59 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/help.js +13 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/nargs.js +33 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/parents.js +28 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js +23 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js +49 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sum.js +35 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js +270 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/index.js +1 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action.js +146 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append.js +55 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append/constant.js +47 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/count.js +40 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/help.js +48 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store.js +50 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/constant.js +43 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/false.js +27 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/true.js +26 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/subparsers.js +148 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/version.js +50 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action_container.js +481 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argparse.js +14 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/error.js +50 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/exclusive.js +54 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/group.js +75 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument_parser.js +1168 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/const.js +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/added_formatters.js +88 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/formatter.js +798 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/namespace.js +77 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.npmignore +2 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.travis.yml +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown +825 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/bower.json +33 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/component.json +11 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/foo.js +10 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/gulpfile.js +26 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/lib/underscore.string.js +673 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/libpeerconnection.log +0 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json +107 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE +23 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md +22 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json +69 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore-min.js +6 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore.js +1415 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/package.json +62 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/README.md +73 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esparse.js +117 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esvalidate.js +177 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/esprima.js +3908 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/package.json +69 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/compat.js +239 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/reflect.js +422 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/run.js +66 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/runner.js +387 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/test.js +20238 -0
- data/stdlib/nodejs/node_modules/js-yaml/package.json +83 -0
- data/{package.json → stdlib/nodejs/package.json} +0 -3
- data/stdlib/phantomjs.rb +1 -6
- data/tasks/testing.rake +1 -4
- metadata +191 -6
- data/stdlib/nodejs/runtime.rb +0 -26
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
|
7
|
+
// stdlib
|
8
|
+
var fs = require('fs');
|
9
|
+
|
10
|
+
|
11
|
+
// 3rd-party
|
12
|
+
var argparse = require('argparse');
|
13
|
+
|
14
|
+
|
15
|
+
// internal
|
16
|
+
var yaml = require('..');
|
17
|
+
|
18
|
+
|
19
|
+
////////////////////////////////////////////////////////////////////////////////
|
20
|
+
|
21
|
+
|
22
|
+
var cli = new argparse.ArgumentParser({
|
23
|
+
prog: 'js-yaml',
|
24
|
+
version: require('../package.json').version,
|
25
|
+
addHelp: true
|
26
|
+
});
|
27
|
+
|
28
|
+
|
29
|
+
cli.addArgument(['-c', '--compact'], {
|
30
|
+
help: 'Display errors in compact mode',
|
31
|
+
action: 'storeTrue'
|
32
|
+
});
|
33
|
+
|
34
|
+
|
35
|
+
// deprecated (not needed after we removed output colors)
|
36
|
+
// option suppressed, but not completely removed for compatibility
|
37
|
+
cli.addArgument(['-j', '--to-json'], {
|
38
|
+
help: argparse.Const.SUPPRESS,
|
39
|
+
dest: 'json',
|
40
|
+
action: 'storeTrue'
|
41
|
+
});
|
42
|
+
|
43
|
+
|
44
|
+
cli.addArgument(['-t', '--trace'], {
|
45
|
+
help: 'Show stack trace on error',
|
46
|
+
action: 'storeTrue'
|
47
|
+
});
|
48
|
+
|
49
|
+
cli.addArgument(['file'], {
|
50
|
+
help: 'File to read, utf-8 encoded without BOM',
|
51
|
+
nargs: '?',
|
52
|
+
defaultValue: '-'
|
53
|
+
});
|
54
|
+
|
55
|
+
|
56
|
+
////////////////////////////////////////////////////////////////////////////////
|
57
|
+
|
58
|
+
|
59
|
+
var options = cli.parseArgs();
|
60
|
+
|
61
|
+
|
62
|
+
////////////////////////////////////////////////////////////////////////////////
|
63
|
+
|
64
|
+
function readFile(filename, encoding, callback) {
|
65
|
+
if (options.file === '-') {
|
66
|
+
// read from stdin
|
67
|
+
|
68
|
+
var chunks = [];
|
69
|
+
|
70
|
+
process.stdin.on('data', function(chunk) {
|
71
|
+
chunks.push(chunk);
|
72
|
+
});
|
73
|
+
|
74
|
+
process.stdin.on('end', function() {
|
75
|
+
return callback(null, Buffer.concat(chunks).toString(encoding));
|
76
|
+
});
|
77
|
+
} else {
|
78
|
+
fs.readFile(filename, encoding, callback);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
readFile(options.file, 'utf8', function (error, input) {
|
83
|
+
var output, isYaml;
|
84
|
+
|
85
|
+
if (error) {
|
86
|
+
if ('ENOENT' === error.code) {
|
87
|
+
console.error('File not found: ' + options.file);
|
88
|
+
process.exit(2);
|
89
|
+
}
|
90
|
+
|
91
|
+
console.error(
|
92
|
+
options.trace && error.stack ||
|
93
|
+
error.message ||
|
94
|
+
String(error));
|
95
|
+
|
96
|
+
process.exit(1);
|
97
|
+
}
|
98
|
+
|
99
|
+
try {
|
100
|
+
output = JSON.parse(input);
|
101
|
+
isYaml = false;
|
102
|
+
} catch (error) {
|
103
|
+
if (error instanceof SyntaxError) {
|
104
|
+
try {
|
105
|
+
output = [];
|
106
|
+
yaml.loadAll(input, function (doc) { output.push(doc); }, {});
|
107
|
+
isYaml = true;
|
108
|
+
|
109
|
+
if (0 === output.length) {
|
110
|
+
output = null;
|
111
|
+
} else if (1 === output.length) {
|
112
|
+
output = output[0];
|
113
|
+
}
|
114
|
+
} catch (error) {
|
115
|
+
if (options.trace && error.stack) {
|
116
|
+
console.error(error.stack);
|
117
|
+
} else {
|
118
|
+
console.error(error.toString(options.compact));
|
119
|
+
}
|
120
|
+
|
121
|
+
process.exit(1);
|
122
|
+
}
|
123
|
+
} else {
|
124
|
+
console.error(
|
125
|
+
options.trace && error.stack ||
|
126
|
+
error.message ||
|
127
|
+
String(error));
|
128
|
+
|
129
|
+
process.exit(1);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
if (isYaml) {
|
134
|
+
console.log(JSON.stringify(output, null, ' '));
|
135
|
+
} else {
|
136
|
+
console.log(yaml.dump(output));
|
137
|
+
}
|
138
|
+
|
139
|
+
process.exit(0);
|
140
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
{
|
3
|
+
"name": "js-yaml",
|
4
|
+
"main": "dist/js-yaml.js",
|
5
|
+
"homepage": "https://github.com/nodeca/js-yaml",
|
6
|
+
"authors": [ "Dervus Grim <dervus.grim@gmail.com>",
|
7
|
+
"Vitaly Puzrin <vitaly@rcdesign.ru>",
|
8
|
+
"Aleksey V Zapparov <ixti@member.fsf.org>",
|
9
|
+
"Martin Grenfell <martin.grenfell@gmail.com>" ],
|
10
|
+
"description": "YAML 1.2 parser and serializer",
|
11
|
+
"keywords": ["yaml", "parser", "serializer", "pyyaml"],
|
12
|
+
"license": "MIT",
|
13
|
+
"ignore": [
|
14
|
+
"**/.*",
|
15
|
+
"node_modules",
|
16
|
+
"benchmark",
|
17
|
+
"bower_components",
|
18
|
+
"test",
|
19
|
+
"Makefile",
|
20
|
+
"index*",
|
21
|
+
"package.json"
|
22
|
+
]
|
23
|
+
}
|
@@ -0,0 +1,3666 @@
|
|
1
|
+
/* js-yaml 3.2.6 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
|
5
|
+
var loader = require('./js-yaml/loader');
|
6
|
+
var dumper = require('./js-yaml/dumper');
|
7
|
+
|
8
|
+
|
9
|
+
function deprecated(name) {
|
10
|
+
return function () {
|
11
|
+
throw new Error('Function ' + name + ' is deprecated and cannot be used.');
|
12
|
+
};
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
module.exports.Type = require('./js-yaml/type');
|
17
|
+
module.exports.Schema = require('./js-yaml/schema');
|
18
|
+
module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
|
19
|
+
module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
|
20
|
+
module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
|
21
|
+
module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
22
|
+
module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
|
23
|
+
module.exports.load = loader.load;
|
24
|
+
module.exports.loadAll = loader.loadAll;
|
25
|
+
module.exports.safeLoad = loader.safeLoad;
|
26
|
+
module.exports.safeLoadAll = loader.safeLoadAll;
|
27
|
+
module.exports.dump = dumper.dump;
|
28
|
+
module.exports.safeDump = dumper.safeDump;
|
29
|
+
module.exports.YAMLException = require('./js-yaml/exception');
|
30
|
+
|
31
|
+
// Deprecared schema names from JS-YAML 2.0.x
|
32
|
+
module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
|
33
|
+
module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
34
|
+
module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
|
35
|
+
|
36
|
+
// Deprecated functions from JS-YAML 1.x.x
|
37
|
+
module.exports.scan = deprecated('scan');
|
38
|
+
module.exports.parse = deprecated('parse');
|
39
|
+
module.exports.compose = deprecated('compose');
|
40
|
+
module.exports.addConstructor = deprecated('addConstructor');
|
41
|
+
|
42
|
+
},{"./js-yaml/dumper":3,"./js-yaml/exception":4,"./js-yaml/loader":5,"./js-yaml/schema":7,"./js-yaml/schema/core":8,"./js-yaml/schema/default_full":9,"./js-yaml/schema/default_safe":10,"./js-yaml/schema/failsafe":11,"./js-yaml/schema/json":12,"./js-yaml/type":13}],2:[function(require,module,exports){
|
43
|
+
'use strict';
|
44
|
+
|
45
|
+
|
46
|
+
function isNothing(subject) {
|
47
|
+
return (undefined === subject) || (null === subject);
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
function isObject(subject) {
|
52
|
+
return ('object' === typeof subject) && (null !== subject);
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
function toArray(sequence) {
|
57
|
+
if (Array.isArray(sequence)) {
|
58
|
+
return sequence;
|
59
|
+
} else if (isNothing(sequence)) {
|
60
|
+
return [];
|
61
|
+
} else {
|
62
|
+
return [ sequence ];
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
function extend(target, source) {
|
68
|
+
var index, length, key, sourceKeys;
|
69
|
+
|
70
|
+
if (source) {
|
71
|
+
sourceKeys = Object.keys(source);
|
72
|
+
|
73
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
74
|
+
key = sourceKeys[index];
|
75
|
+
target[key] = source[key];
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return target;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
function repeat(string, count) {
|
84
|
+
var result = '', cycle;
|
85
|
+
|
86
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
87
|
+
result += string;
|
88
|
+
}
|
89
|
+
|
90
|
+
return result;
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
function isNegativeZero(number) {
|
95
|
+
return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
module.exports.isNothing = isNothing;
|
100
|
+
module.exports.isObject = isObject;
|
101
|
+
module.exports.toArray = toArray;
|
102
|
+
module.exports.repeat = repeat;
|
103
|
+
module.exports.isNegativeZero = isNegativeZero;
|
104
|
+
module.exports.extend = extend;
|
105
|
+
|
106
|
+
},{}],3:[function(require,module,exports){
|
107
|
+
'use strict';
|
108
|
+
|
109
|
+
|
110
|
+
var common = require('./common');
|
111
|
+
var YAMLException = require('./exception');
|
112
|
+
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
113
|
+
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
114
|
+
|
115
|
+
|
116
|
+
var _toString = Object.prototype.toString;
|
117
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
118
|
+
|
119
|
+
|
120
|
+
var CHAR_TAB = 0x09; /* Tab */
|
121
|
+
var CHAR_LINE_FEED = 0x0A; /* LF */
|
122
|
+
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
123
|
+
var CHAR_SPACE = 0x20; /* Space */
|
124
|
+
var CHAR_EXCLAMATION = 0x21; /* ! */
|
125
|
+
var CHAR_DOUBLE_QUOTE = 0x22; /* " */
|
126
|
+
var CHAR_SHARP = 0x23; /* # */
|
127
|
+
var CHAR_PERCENT = 0x25; /* % */
|
128
|
+
var CHAR_AMPERSAND = 0x26; /* & */
|
129
|
+
var CHAR_SINGLE_QUOTE = 0x27; /* ' */
|
130
|
+
var CHAR_ASTERISK = 0x2A; /* * */
|
131
|
+
var CHAR_COMMA = 0x2C; /* , */
|
132
|
+
var CHAR_MINUS = 0x2D; /* - */
|
133
|
+
var CHAR_COLON = 0x3A; /* : */
|
134
|
+
var CHAR_GREATER_THAN = 0x3E; /* > */
|
135
|
+
var CHAR_QUESTION = 0x3F; /* ? */
|
136
|
+
var CHAR_COMMERCIAL_AT = 0x40; /* @ */
|
137
|
+
var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
|
138
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
|
139
|
+
var CHAR_GRAVE_ACCENT = 0x60; /* ` */
|
140
|
+
var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
141
|
+
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
142
|
+
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
143
|
+
|
144
|
+
|
145
|
+
var ESCAPE_SEQUENCES = {};
|
146
|
+
|
147
|
+
ESCAPE_SEQUENCES[0x00] = '\\0';
|
148
|
+
ESCAPE_SEQUENCES[0x07] = '\\a';
|
149
|
+
ESCAPE_SEQUENCES[0x08] = '\\b';
|
150
|
+
ESCAPE_SEQUENCES[0x09] = '\\t';
|
151
|
+
ESCAPE_SEQUENCES[0x0A] = '\\n';
|
152
|
+
ESCAPE_SEQUENCES[0x0B] = '\\v';
|
153
|
+
ESCAPE_SEQUENCES[0x0C] = '\\f';
|
154
|
+
ESCAPE_SEQUENCES[0x0D] = '\\r';
|
155
|
+
ESCAPE_SEQUENCES[0x1B] = '\\e';
|
156
|
+
ESCAPE_SEQUENCES[0x22] = '\\"';
|
157
|
+
ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
158
|
+
ESCAPE_SEQUENCES[0x85] = '\\N';
|
159
|
+
ESCAPE_SEQUENCES[0xA0] = '\\_';
|
160
|
+
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
161
|
+
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
162
|
+
|
163
|
+
|
164
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
165
|
+
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
166
|
+
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
167
|
+
];
|
168
|
+
|
169
|
+
|
170
|
+
function compileStyleMap(schema, map) {
|
171
|
+
var result, keys, index, length, tag, style, type;
|
172
|
+
|
173
|
+
if (null === map) {
|
174
|
+
return {};
|
175
|
+
}
|
176
|
+
|
177
|
+
result = {};
|
178
|
+
keys = Object.keys(map);
|
179
|
+
|
180
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
181
|
+
tag = keys[index];
|
182
|
+
style = String(map[tag]);
|
183
|
+
|
184
|
+
if ('!!' === tag.slice(0, 2)) {
|
185
|
+
tag = 'tag:yaml.org,2002:' + tag.slice(2);
|
186
|
+
}
|
187
|
+
|
188
|
+
type = schema.compiledTypeMap[tag];
|
189
|
+
|
190
|
+
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
191
|
+
style = type.styleAliases[style];
|
192
|
+
}
|
193
|
+
|
194
|
+
result[tag] = style;
|
195
|
+
}
|
196
|
+
|
197
|
+
return result;
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
function encodeHex(character) {
|
202
|
+
var string, handle, length;
|
203
|
+
|
204
|
+
string = character.toString(16).toUpperCase();
|
205
|
+
|
206
|
+
if (character <= 0xFF) {
|
207
|
+
handle = 'x';
|
208
|
+
length = 2;
|
209
|
+
} else if (character <= 0xFFFF) {
|
210
|
+
handle = 'u';
|
211
|
+
length = 4;
|
212
|
+
} else if (character <= 0xFFFFFFFF) {
|
213
|
+
handle = 'U';
|
214
|
+
length = 8;
|
215
|
+
} else {
|
216
|
+
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
|
217
|
+
}
|
218
|
+
|
219
|
+
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
function State(options) {
|
224
|
+
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
225
|
+
this.indent = Math.max(1, (options['indent'] || 2));
|
226
|
+
this.skipInvalid = options['skipInvalid'] || false;
|
227
|
+
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
228
|
+
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
229
|
+
|
230
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
231
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
232
|
+
|
233
|
+
this.tag = null;
|
234
|
+
this.result = '';
|
235
|
+
|
236
|
+
this.duplicates = [];
|
237
|
+
this.usedDuplicates = null;
|
238
|
+
}
|
239
|
+
|
240
|
+
|
241
|
+
function generateNextLine(state, level) {
|
242
|
+
return '\n' + common.repeat(' ', state.indent * level);
|
243
|
+
}
|
244
|
+
|
245
|
+
function testImplicitResolving(state, str) {
|
246
|
+
var index, length, type;
|
247
|
+
|
248
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
249
|
+
type = state.implicitTypes[index];
|
250
|
+
|
251
|
+
if (type.resolve(str)) {
|
252
|
+
return true;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
return false;
|
257
|
+
}
|
258
|
+
|
259
|
+
function writeScalar(state, object) {
|
260
|
+
var isQuoted, checkpoint, position, length, character, first;
|
261
|
+
|
262
|
+
state.dump = '';
|
263
|
+
isQuoted = false;
|
264
|
+
checkpoint = 0;
|
265
|
+
first = object.charCodeAt(0) || 0;
|
266
|
+
|
267
|
+
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
268
|
+
// Ensure compatibility with YAML 1.0/1.1 loaders.
|
269
|
+
isQuoted = true;
|
270
|
+
} else if (0 === object.length) {
|
271
|
+
// Quote empty string
|
272
|
+
isQuoted = true;
|
273
|
+
} else if (CHAR_SPACE === first ||
|
274
|
+
CHAR_SPACE === object.charCodeAt(object.length - 1)) {
|
275
|
+
isQuoted = true;
|
276
|
+
} else if (CHAR_MINUS === first ||
|
277
|
+
CHAR_QUESTION === first) {
|
278
|
+
// Don't check second symbol for simplicity
|
279
|
+
isQuoted = true;
|
280
|
+
}
|
281
|
+
|
282
|
+
for (position = 0, length = object.length; position < length; position += 1) {
|
283
|
+
character = object.charCodeAt(position);
|
284
|
+
|
285
|
+
if (!isQuoted) {
|
286
|
+
if (CHAR_TAB === character ||
|
287
|
+
CHAR_LINE_FEED === character ||
|
288
|
+
CHAR_CARRIAGE_RETURN === character ||
|
289
|
+
CHAR_COMMA === character ||
|
290
|
+
CHAR_LEFT_SQUARE_BRACKET === character ||
|
291
|
+
CHAR_RIGHT_SQUARE_BRACKET === character ||
|
292
|
+
CHAR_LEFT_CURLY_BRACKET === character ||
|
293
|
+
CHAR_RIGHT_CURLY_BRACKET === character ||
|
294
|
+
CHAR_SHARP === character ||
|
295
|
+
CHAR_AMPERSAND === character ||
|
296
|
+
CHAR_ASTERISK === character ||
|
297
|
+
CHAR_EXCLAMATION === character ||
|
298
|
+
CHAR_VERTICAL_LINE === character ||
|
299
|
+
CHAR_GREATER_THAN === character ||
|
300
|
+
CHAR_SINGLE_QUOTE === character ||
|
301
|
+
CHAR_DOUBLE_QUOTE === character ||
|
302
|
+
CHAR_PERCENT === character ||
|
303
|
+
CHAR_COMMERCIAL_AT === character ||
|
304
|
+
CHAR_COLON === character ||
|
305
|
+
CHAR_GRAVE_ACCENT === character) {
|
306
|
+
isQuoted = true;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
if (ESCAPE_SEQUENCES[character] ||
|
311
|
+
!((0x00020 <= character && character <= 0x00007E) ||
|
312
|
+
(0x00085 === character) ||
|
313
|
+
(0x000A0 <= character && character <= 0x00D7FF) ||
|
314
|
+
(0x0E000 <= character && character <= 0x00FFFD) ||
|
315
|
+
(0x10000 <= character && character <= 0x10FFFF))) {
|
316
|
+
state.dump += object.slice(checkpoint, position);
|
317
|
+
state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
|
318
|
+
checkpoint = position + 1;
|
319
|
+
isQuoted = true;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
if (checkpoint < position) {
|
324
|
+
state.dump += object.slice(checkpoint, position);
|
325
|
+
}
|
326
|
+
|
327
|
+
if (!isQuoted && testImplicitResolving(state, state.dump)) {
|
328
|
+
isQuoted = true;
|
329
|
+
}
|
330
|
+
|
331
|
+
if (isQuoted) {
|
332
|
+
state.dump = '"' + state.dump + '"';
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
function writeFlowSequence(state, level, object) {
|
337
|
+
var _result = '',
|
338
|
+
_tag = state.tag,
|
339
|
+
index,
|
340
|
+
length;
|
341
|
+
|
342
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
343
|
+
// Write only valid elements.
|
344
|
+
if (writeNode(state, level, object[index], false, false)) {
|
345
|
+
if (0 !== index) {
|
346
|
+
_result += ', ';
|
347
|
+
}
|
348
|
+
_result += state.dump;
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
state.tag = _tag;
|
353
|
+
state.dump = '[' + _result + ']';
|
354
|
+
}
|
355
|
+
|
356
|
+
function writeBlockSequence(state, level, object, compact) {
|
357
|
+
var _result = '',
|
358
|
+
_tag = state.tag,
|
359
|
+
index,
|
360
|
+
length;
|
361
|
+
|
362
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
363
|
+
// Write only valid elements.
|
364
|
+
if (writeNode(state, level + 1, object[index], true, true)) {
|
365
|
+
if (!compact || 0 !== index) {
|
366
|
+
_result += generateNextLine(state, level);
|
367
|
+
}
|
368
|
+
_result += '- ' + state.dump;
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
state.tag = _tag;
|
373
|
+
state.dump = _result || '[]'; // Empty sequence if no valid values.
|
374
|
+
}
|
375
|
+
|
376
|
+
function writeFlowMapping(state, level, object) {
|
377
|
+
var _result = '',
|
378
|
+
_tag = state.tag,
|
379
|
+
objectKeyList = Object.keys(object),
|
380
|
+
index,
|
381
|
+
length,
|
382
|
+
objectKey,
|
383
|
+
objectValue,
|
384
|
+
pairBuffer;
|
385
|
+
|
386
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
387
|
+
pairBuffer = '';
|
388
|
+
|
389
|
+
if (0 !== index) {
|
390
|
+
pairBuffer += ', ';
|
391
|
+
}
|
392
|
+
|
393
|
+
objectKey = objectKeyList[index];
|
394
|
+
objectValue = object[objectKey];
|
395
|
+
|
396
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
397
|
+
continue; // Skip this pair because of invalid key;
|
398
|
+
}
|
399
|
+
|
400
|
+
if (state.dump.length > 1024) {
|
401
|
+
pairBuffer += '? ';
|
402
|
+
}
|
403
|
+
|
404
|
+
pairBuffer += state.dump + ': ';
|
405
|
+
|
406
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
407
|
+
continue; // Skip this pair because of invalid value.
|
408
|
+
}
|
409
|
+
|
410
|
+
pairBuffer += state.dump;
|
411
|
+
|
412
|
+
// Both key and value are valid.
|
413
|
+
_result += pairBuffer;
|
414
|
+
}
|
415
|
+
|
416
|
+
state.tag = _tag;
|
417
|
+
state.dump = '{' + _result + '}';
|
418
|
+
}
|
419
|
+
|
420
|
+
function writeBlockMapping(state, level, object, compact) {
|
421
|
+
var _result = '',
|
422
|
+
_tag = state.tag,
|
423
|
+
objectKeyList = Object.keys(object),
|
424
|
+
index,
|
425
|
+
length,
|
426
|
+
objectKey,
|
427
|
+
objectValue,
|
428
|
+
explicitPair,
|
429
|
+
pairBuffer;
|
430
|
+
|
431
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
432
|
+
pairBuffer = '';
|
433
|
+
|
434
|
+
if (!compact || 0 !== index) {
|
435
|
+
pairBuffer += generateNextLine(state, level);
|
436
|
+
}
|
437
|
+
|
438
|
+
objectKey = objectKeyList[index];
|
439
|
+
objectValue = object[objectKey];
|
440
|
+
|
441
|
+
if (!writeNode(state, level + 1, objectKey, true, true)) {
|
442
|
+
continue; // Skip this pair because of invalid key.
|
443
|
+
}
|
444
|
+
|
445
|
+
explicitPair = (null !== state.tag && '?' !== state.tag) ||
|
446
|
+
(state.dump && state.dump.length > 1024);
|
447
|
+
|
448
|
+
if (explicitPair) {
|
449
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
450
|
+
pairBuffer += '?';
|
451
|
+
} else {
|
452
|
+
pairBuffer += '? ';
|
453
|
+
}
|
454
|
+
}
|
455
|
+
|
456
|
+
pairBuffer += state.dump;
|
457
|
+
|
458
|
+
if (explicitPair) {
|
459
|
+
pairBuffer += generateNextLine(state, level);
|
460
|
+
}
|
461
|
+
|
462
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
463
|
+
continue; // Skip this pair because of invalid value.
|
464
|
+
}
|
465
|
+
|
466
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
467
|
+
pairBuffer += ':';
|
468
|
+
} else {
|
469
|
+
pairBuffer += ': ';
|
470
|
+
}
|
471
|
+
|
472
|
+
pairBuffer += state.dump;
|
473
|
+
|
474
|
+
// Both key and value are valid.
|
475
|
+
_result += pairBuffer;
|
476
|
+
}
|
477
|
+
|
478
|
+
state.tag = _tag;
|
479
|
+
state.dump = _result || '{}'; // Empty mapping if no valid pairs.
|
480
|
+
}
|
481
|
+
|
482
|
+
function detectType(state, object, explicit) {
|
483
|
+
var _result, typeList, index, length, type, style;
|
484
|
+
|
485
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
486
|
+
|
487
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
488
|
+
type = typeList[index];
|
489
|
+
|
490
|
+
if ((type.instanceOf || type.predicate) &&
|
491
|
+
(!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) &&
|
492
|
+
(!type.predicate || type.predicate(object))) {
|
493
|
+
|
494
|
+
state.tag = explicit ? type.tag : '?';
|
495
|
+
|
496
|
+
if (type.represent) {
|
497
|
+
style = state.styleMap[type.tag] || type.defaultStyle;
|
498
|
+
|
499
|
+
if ('[object Function]' === _toString.call(type.represent)) {
|
500
|
+
_result = type.represent(object, style);
|
501
|
+
} else if (_hasOwnProperty.call(type.represent, style)) {
|
502
|
+
_result = type.represent[style](object, style);
|
503
|
+
} else {
|
504
|
+
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
|
505
|
+
}
|
506
|
+
|
507
|
+
state.dump = _result;
|
508
|
+
}
|
509
|
+
|
510
|
+
return true;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
return false;
|
515
|
+
}
|
516
|
+
|
517
|
+
// Serializes `object` and writes it to global `result`.
|
518
|
+
// Returns true on success, or false on invalid object.
|
519
|
+
//
|
520
|
+
function writeNode(state, level, object, block, compact) {
|
521
|
+
state.tag = null;
|
522
|
+
state.dump = object;
|
523
|
+
|
524
|
+
if (!detectType(state, object, false)) {
|
525
|
+
detectType(state, object, true);
|
526
|
+
}
|
527
|
+
|
528
|
+
var type = _toString.call(state.dump);
|
529
|
+
|
530
|
+
if (block) {
|
531
|
+
block = (0 > state.flowLevel || state.flowLevel > level);
|
532
|
+
}
|
533
|
+
|
534
|
+
if ((null !== state.tag && '?' !== state.tag) || (2 !== state.indent && level > 0)) {
|
535
|
+
compact = false;
|
536
|
+
}
|
537
|
+
|
538
|
+
var objectOrArray = '[object Object]' === type || '[object Array]' === type,
|
539
|
+
duplicateIndex,
|
540
|
+
duplicate;
|
541
|
+
|
542
|
+
if (objectOrArray) {
|
543
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
544
|
+
duplicate = duplicateIndex !== -1;
|
545
|
+
}
|
546
|
+
|
547
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
548
|
+
state.dump = '*ref_' + duplicateIndex;
|
549
|
+
} else {
|
550
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
551
|
+
state.usedDuplicates[duplicateIndex] = true;
|
552
|
+
}
|
553
|
+
if ('[object Object]' === type) {
|
554
|
+
if (block && (0 !== Object.keys(state.dump).length)) {
|
555
|
+
writeBlockMapping(state, level, state.dump, compact);
|
556
|
+
if (duplicate) {
|
557
|
+
state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
|
558
|
+
}
|
559
|
+
} else {
|
560
|
+
writeFlowMapping(state, level, state.dump);
|
561
|
+
if (duplicate) {
|
562
|
+
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
563
|
+
}
|
564
|
+
}
|
565
|
+
} else if ('[object Array]' === type) {
|
566
|
+
if (block && (0 !== state.dump.length)) {
|
567
|
+
writeBlockSequence(state, level, state.dump, compact);
|
568
|
+
if (duplicate) {
|
569
|
+
state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
|
570
|
+
}
|
571
|
+
} else {
|
572
|
+
writeFlowSequence(state, level, state.dump);
|
573
|
+
if (duplicate) {
|
574
|
+
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
575
|
+
}
|
576
|
+
}
|
577
|
+
} else if ('[object String]' === type) {
|
578
|
+
if ('?' !== state.tag) {
|
579
|
+
writeScalar(state, state.dump);
|
580
|
+
}
|
581
|
+
} else if (state.skipInvalid) {
|
582
|
+
return false;
|
583
|
+
} else {
|
584
|
+
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
585
|
+
}
|
586
|
+
|
587
|
+
if (null !== state.tag && '?' !== state.tag) {
|
588
|
+
state.dump = '!<' + state.tag + '> ' + state.dump;
|
589
|
+
}
|
590
|
+
}
|
591
|
+
|
592
|
+
return true;
|
593
|
+
}
|
594
|
+
|
595
|
+
function getDuplicateReferences(object, state) {
|
596
|
+
var objects = [],
|
597
|
+
duplicatesIndexes = [],
|
598
|
+
index,
|
599
|
+
length;
|
600
|
+
|
601
|
+
inspectNode(object, objects, duplicatesIndexes);
|
602
|
+
|
603
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
604
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
605
|
+
}
|
606
|
+
state.usedDuplicates = new Array(length);
|
607
|
+
}
|
608
|
+
|
609
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
610
|
+
var type = _toString.call(object),
|
611
|
+
objectKeyList,
|
612
|
+
index,
|
613
|
+
length;
|
614
|
+
|
615
|
+
if (null !== object && 'object' === typeof object) {
|
616
|
+
index = objects.indexOf(object);
|
617
|
+
if (-1 !== index) {
|
618
|
+
if (-1 === duplicatesIndexes.indexOf(index)) {
|
619
|
+
duplicatesIndexes.push(index);
|
620
|
+
}
|
621
|
+
} else {
|
622
|
+
objects.push(object);
|
623
|
+
|
624
|
+
if(Array.isArray(object)) {
|
625
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
626
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
627
|
+
}
|
628
|
+
} else {
|
629
|
+
objectKeyList = Object.keys(object);
|
630
|
+
|
631
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
632
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
633
|
+
}
|
634
|
+
}
|
635
|
+
}
|
636
|
+
}
|
637
|
+
}
|
638
|
+
|
639
|
+
function dump(input, options) {
|
640
|
+
options = options || {};
|
641
|
+
|
642
|
+
var state = new State(options);
|
643
|
+
|
644
|
+
getDuplicateReferences(input, state);
|
645
|
+
|
646
|
+
if (writeNode(state, 0, input, true, true)) {
|
647
|
+
return state.dump + '\n';
|
648
|
+
} else {
|
649
|
+
return '';
|
650
|
+
}
|
651
|
+
}
|
652
|
+
|
653
|
+
|
654
|
+
function safeDump(input, options) {
|
655
|
+
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
656
|
+
}
|
657
|
+
|
658
|
+
|
659
|
+
module.exports.dump = dump;
|
660
|
+
module.exports.safeDump = safeDump;
|
661
|
+
|
662
|
+
},{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
|
663
|
+
'use strict';
|
664
|
+
|
665
|
+
|
666
|
+
function YAMLException(reason, mark) {
|
667
|
+
this.name = 'YAMLException';
|
668
|
+
this.reason = reason;
|
669
|
+
this.mark = mark;
|
670
|
+
this.message = this.toString(false);
|
671
|
+
}
|
672
|
+
|
673
|
+
|
674
|
+
YAMLException.prototype.toString = function toString(compact) {
|
675
|
+
var result;
|
676
|
+
|
677
|
+
result = 'JS-YAML: ' + (this.reason || '(unknown reason)');
|
678
|
+
|
679
|
+
if (!compact && this.mark) {
|
680
|
+
result += ' ' + this.mark.toString();
|
681
|
+
}
|
682
|
+
|
683
|
+
return result;
|
684
|
+
};
|
685
|
+
|
686
|
+
|
687
|
+
module.exports = YAMLException;
|
688
|
+
|
689
|
+
},{}],5:[function(require,module,exports){
|
690
|
+
'use strict';
|
691
|
+
|
692
|
+
|
693
|
+
var common = require('./common');
|
694
|
+
var YAMLException = require('./exception');
|
695
|
+
var Mark = require('./mark');
|
696
|
+
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
697
|
+
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
698
|
+
|
699
|
+
|
700
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
701
|
+
|
702
|
+
|
703
|
+
var CONTEXT_FLOW_IN = 1;
|
704
|
+
var CONTEXT_FLOW_OUT = 2;
|
705
|
+
var CONTEXT_BLOCK_IN = 3;
|
706
|
+
var CONTEXT_BLOCK_OUT = 4;
|
707
|
+
|
708
|
+
|
709
|
+
var CHOMPING_CLIP = 1;
|
710
|
+
var CHOMPING_STRIP = 2;
|
711
|
+
var CHOMPING_KEEP = 3;
|
712
|
+
|
713
|
+
|
714
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uD800-\uDFFF\uFFFE\uFFFF]/;
|
715
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
716
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
717
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
718
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
719
|
+
|
720
|
+
|
721
|
+
function is_EOL(c) {
|
722
|
+
return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
|
723
|
+
}
|
724
|
+
|
725
|
+
function is_WHITE_SPACE(c) {
|
726
|
+
return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
|
727
|
+
}
|
728
|
+
|
729
|
+
function is_WS_OR_EOL(c) {
|
730
|
+
return (c === 0x09/* Tab */) ||
|
731
|
+
(c === 0x20/* Space */) ||
|
732
|
+
(c === 0x0A/* LF */) ||
|
733
|
+
(c === 0x0D/* CR */);
|
734
|
+
}
|
735
|
+
|
736
|
+
function is_FLOW_INDICATOR(c) {
|
737
|
+
return 0x2C/* , */ === c ||
|
738
|
+
0x5B/* [ */ === c ||
|
739
|
+
0x5D/* ] */ === c ||
|
740
|
+
0x7B/* { */ === c ||
|
741
|
+
0x7D/* } */ === c;
|
742
|
+
}
|
743
|
+
|
744
|
+
function fromHexCode(c) {
|
745
|
+
var lc;
|
746
|
+
|
747
|
+
if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
|
748
|
+
return c - 0x30;
|
749
|
+
}
|
750
|
+
|
751
|
+
lc = c | 0x20;
|
752
|
+
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
753
|
+
return lc - 0x61 + 10;
|
754
|
+
}
|
755
|
+
|
756
|
+
return -1;
|
757
|
+
}
|
758
|
+
|
759
|
+
function escapedHexLen(c) {
|
760
|
+
if (c === 0x78/* x */) { return 2; }
|
761
|
+
if (c === 0x75/* u */) { return 4; }
|
762
|
+
if (c === 0x55/* U */) { return 8; }
|
763
|
+
return 0;
|
764
|
+
}
|
765
|
+
|
766
|
+
function fromDecimalCode(c) {
|
767
|
+
if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
|
768
|
+
return c - 0x30;
|
769
|
+
}
|
770
|
+
|
771
|
+
return -1;
|
772
|
+
}
|
773
|
+
|
774
|
+
function simpleEscapeSequence(c) {
|
775
|
+
return (c === 0x30/* 0 */) ? '\x00' :
|
776
|
+
(c === 0x61/* a */) ? '\x07' :
|
777
|
+
(c === 0x62/* b */) ? '\x08' :
|
778
|
+
(c === 0x74/* t */) ? '\x09' :
|
779
|
+
(c === 0x09/* Tab */) ? '\x09' :
|
780
|
+
(c === 0x6E/* n */) ? '\x0A' :
|
781
|
+
(c === 0x76/* v */) ? '\x0B' :
|
782
|
+
(c === 0x66/* f */) ? '\x0C' :
|
783
|
+
(c === 0x72/* r */) ? '\x0D' :
|
784
|
+
(c === 0x65/* e */) ? '\x1B' :
|
785
|
+
(c === 0x20/* Space */) ? ' ' :
|
786
|
+
(c === 0x22/* " */) ? '\x22' :
|
787
|
+
(c === 0x2F/* / */) ? '/' :
|
788
|
+
(c === 0x5C/* \ */) ? '\x5C' :
|
789
|
+
(c === 0x4E/* N */) ? '\x85' :
|
790
|
+
(c === 0x5F/* _ */) ? '\xA0' :
|
791
|
+
(c === 0x4C/* L */) ? '\u2028' :
|
792
|
+
(c === 0x50/* P */) ? '\u2029' : '';
|
793
|
+
}
|
794
|
+
|
795
|
+
function charFromCodepoint(c) {
|
796
|
+
if (c <= 0xFFFF) {
|
797
|
+
return String.fromCharCode(c);
|
798
|
+
} else {
|
799
|
+
// Encode UTF-16 surrogate pair
|
800
|
+
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
801
|
+
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
|
802
|
+
((c - 0x010000) & 0x03FF) + 0xDC00);
|
803
|
+
}
|
804
|
+
}
|
805
|
+
|
806
|
+
var simpleEscapeCheck = new Array(256); // integer, for fast access
|
807
|
+
var simpleEscapeMap = new Array(256);
|
808
|
+
for (var i = 0; i < 256; i++) {
|
809
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
810
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
811
|
+
}
|
812
|
+
|
813
|
+
|
814
|
+
function State(input, options) {
|
815
|
+
this.input = input;
|
816
|
+
|
817
|
+
this.filename = options['filename'] || null;
|
818
|
+
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
819
|
+
this.onWarning = options['onWarning'] || null;
|
820
|
+
this.legacy = options['legacy'] || false;
|
821
|
+
|
822
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
823
|
+
this.typeMap = this.schema.compiledTypeMap;
|
824
|
+
|
825
|
+
this.length = input.length;
|
826
|
+
this.position = 0;
|
827
|
+
this.line = 0;
|
828
|
+
this.lineStart = 0;
|
829
|
+
this.lineIndent = 0;
|
830
|
+
|
831
|
+
this.documents = [];
|
832
|
+
|
833
|
+
/*
|
834
|
+
this.version;
|
835
|
+
this.checkLineBreaks;
|
836
|
+
this.tagMap;
|
837
|
+
this.anchorMap;
|
838
|
+
this.tag;
|
839
|
+
this.anchor;
|
840
|
+
this.kind;
|
841
|
+
this.result;*/
|
842
|
+
|
843
|
+
}
|
844
|
+
|
845
|
+
|
846
|
+
function generateError(state, message) {
|
847
|
+
return new YAMLException(
|
848
|
+
message,
|
849
|
+
new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
|
850
|
+
}
|
851
|
+
|
852
|
+
function throwError(state, message) {
|
853
|
+
throw generateError(state, message);
|
854
|
+
}
|
855
|
+
|
856
|
+
function throwWarning(state, message) {
|
857
|
+
var error = generateError(state, message);
|
858
|
+
|
859
|
+
if (state.onWarning) {
|
860
|
+
state.onWarning.call(null, error);
|
861
|
+
} else {
|
862
|
+
throw error;
|
863
|
+
}
|
864
|
+
}
|
865
|
+
|
866
|
+
|
867
|
+
var directiveHandlers = {
|
868
|
+
|
869
|
+
'YAML': function handleYamlDirective(state, name, args) {
|
870
|
+
|
871
|
+
var match, major, minor;
|
872
|
+
|
873
|
+
if (null !== state.version) {
|
874
|
+
throwError(state, 'duplication of %YAML directive');
|
875
|
+
}
|
876
|
+
|
877
|
+
if (1 !== args.length) {
|
878
|
+
throwError(state, 'YAML directive accepts exactly one argument');
|
879
|
+
}
|
880
|
+
|
881
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
882
|
+
|
883
|
+
if (null === match) {
|
884
|
+
throwError(state, 'ill-formed argument of the YAML directive');
|
885
|
+
}
|
886
|
+
|
887
|
+
major = parseInt(match[1], 10);
|
888
|
+
minor = parseInt(match[2], 10);
|
889
|
+
|
890
|
+
if (1 !== major) {
|
891
|
+
throwError(state, 'unacceptable YAML version of the document');
|
892
|
+
}
|
893
|
+
|
894
|
+
state.version = args[0];
|
895
|
+
state.checkLineBreaks = (minor < 2);
|
896
|
+
|
897
|
+
if (1 !== minor && 2 !== minor) {
|
898
|
+
throwWarning(state, 'unsupported YAML version of the document');
|
899
|
+
}
|
900
|
+
},
|
901
|
+
|
902
|
+
'TAG': function handleTagDirective(state, name, args) {
|
903
|
+
|
904
|
+
var handle, prefix;
|
905
|
+
|
906
|
+
if (2 !== args.length) {
|
907
|
+
throwError(state, 'TAG directive accepts exactly two arguments');
|
908
|
+
}
|
909
|
+
|
910
|
+
handle = args[0];
|
911
|
+
prefix = args[1];
|
912
|
+
|
913
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
914
|
+
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
|
915
|
+
}
|
916
|
+
|
917
|
+
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
918
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
919
|
+
}
|
920
|
+
|
921
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
922
|
+
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
|
923
|
+
}
|
924
|
+
|
925
|
+
state.tagMap[handle] = prefix;
|
926
|
+
}
|
927
|
+
};
|
928
|
+
|
929
|
+
|
930
|
+
function captureSegment(state, start, end, checkJson) {
|
931
|
+
var _position, _length, _character, _result;
|
932
|
+
|
933
|
+
if (start < end) {
|
934
|
+
_result = state.input.slice(start, end);
|
935
|
+
|
936
|
+
if (checkJson) {
|
937
|
+
for (_position = 0, _length = _result.length;
|
938
|
+
_position < _length;
|
939
|
+
_position += 1) {
|
940
|
+
_character = _result.charCodeAt(_position);
|
941
|
+
if (!(0x09 === _character ||
|
942
|
+
0x20 <= _character && _character <= 0x10FFFF)) {
|
943
|
+
throwError(state, 'expected valid JSON character');
|
944
|
+
}
|
945
|
+
}
|
946
|
+
}
|
947
|
+
|
948
|
+
state.result += _result;
|
949
|
+
}
|
950
|
+
}
|
951
|
+
|
952
|
+
function mergeMappings(state, destination, source) {
|
953
|
+
var sourceKeys, key, index, quantity;
|
954
|
+
|
955
|
+
if (!common.isObject(source)) {
|
956
|
+
throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
|
957
|
+
}
|
958
|
+
|
959
|
+
sourceKeys = Object.keys(source);
|
960
|
+
|
961
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
962
|
+
key = sourceKeys[index];
|
963
|
+
|
964
|
+
if (!_hasOwnProperty.call(destination, key)) {
|
965
|
+
destination[key] = source[key];
|
966
|
+
}
|
967
|
+
}
|
968
|
+
}
|
969
|
+
|
970
|
+
function storeMappingPair(state, _result, keyTag, keyNode, valueNode) {
|
971
|
+
var index, quantity;
|
972
|
+
|
973
|
+
keyNode = String(keyNode);
|
974
|
+
|
975
|
+
if (null === _result) {
|
976
|
+
_result = {};
|
977
|
+
}
|
978
|
+
|
979
|
+
if ('tag:yaml.org,2002:merge' === keyTag) {
|
980
|
+
if (Array.isArray(valueNode)) {
|
981
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
982
|
+
mergeMappings(state, _result, valueNode[index]);
|
983
|
+
}
|
984
|
+
} else {
|
985
|
+
mergeMappings(state, _result, valueNode);
|
986
|
+
}
|
987
|
+
} else {
|
988
|
+
_result[keyNode] = valueNode;
|
989
|
+
}
|
990
|
+
|
991
|
+
return _result;
|
992
|
+
}
|
993
|
+
|
994
|
+
function readLineBreak(state) {
|
995
|
+
var ch;
|
996
|
+
|
997
|
+
ch = state.input.charCodeAt(state.position);
|
998
|
+
|
999
|
+
if (0x0A/* LF */ === ch) {
|
1000
|
+
state.position++;
|
1001
|
+
} else if (0x0D/* CR */ === ch) {
|
1002
|
+
state.position++;
|
1003
|
+
if (0x0A/* LF */ === state.input.charCodeAt(state.position)) {
|
1004
|
+
state.position++;
|
1005
|
+
}
|
1006
|
+
} else {
|
1007
|
+
throwError(state, 'a line break is expected');
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
state.line += 1;
|
1011
|
+
state.lineStart = state.position;
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
1015
|
+
var lineBreaks = 0,
|
1016
|
+
ch = state.input.charCodeAt(state.position);
|
1017
|
+
|
1018
|
+
while (0 !== ch) {
|
1019
|
+
while (is_WHITE_SPACE(ch)) {
|
1020
|
+
ch = state.input.charCodeAt(++state.position);
|
1021
|
+
}
|
1022
|
+
|
1023
|
+
if (allowComments && 0x23/* # */ === ch) {
|
1024
|
+
do {
|
1025
|
+
ch = state.input.charCodeAt(++state.position);
|
1026
|
+
} while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && 0 !== ch);
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
if (is_EOL(ch)) {
|
1030
|
+
readLineBreak(state);
|
1031
|
+
|
1032
|
+
ch = state.input.charCodeAt(state.position);
|
1033
|
+
lineBreaks++;
|
1034
|
+
state.lineIndent = 0;
|
1035
|
+
|
1036
|
+
while (0x20/* Space */ === ch) {
|
1037
|
+
state.lineIndent++;
|
1038
|
+
ch = state.input.charCodeAt(++state.position);
|
1039
|
+
}
|
1040
|
+
} else {
|
1041
|
+
break;
|
1042
|
+
}
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
|
1046
|
+
throwWarning(state, 'deficient indentation');
|
1047
|
+
}
|
1048
|
+
|
1049
|
+
return lineBreaks;
|
1050
|
+
}
|
1051
|
+
|
1052
|
+
function testDocumentSeparator(state) {
|
1053
|
+
var _position = state.position,
|
1054
|
+
ch;
|
1055
|
+
|
1056
|
+
ch = state.input.charCodeAt(_position);
|
1057
|
+
|
1058
|
+
// Condition state.position === state.lineStart is tested
|
1059
|
+
// in parent on each call, for efficiency. No needs to test here again.
|
1060
|
+
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
|
1061
|
+
state.input.charCodeAt(_position + 1) === ch &&
|
1062
|
+
state.input.charCodeAt(_position+ 2) === ch) {
|
1063
|
+
|
1064
|
+
_position += 3;
|
1065
|
+
|
1066
|
+
ch = state.input.charCodeAt(_position);
|
1067
|
+
|
1068
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
1069
|
+
return true;
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
return false;
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
function writeFoldedLines(state, count) {
|
1077
|
+
if (1 === count) {
|
1078
|
+
state.result += ' ';
|
1079
|
+
} else if (count > 1) {
|
1080
|
+
state.result += common.repeat('\n', count - 1);
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
|
1084
|
+
|
1085
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
1086
|
+
var preceding,
|
1087
|
+
following,
|
1088
|
+
captureStart,
|
1089
|
+
captureEnd,
|
1090
|
+
hasPendingContent,
|
1091
|
+
_line,
|
1092
|
+
_lineStart,
|
1093
|
+
_lineIndent,
|
1094
|
+
_kind = state.kind,
|
1095
|
+
_result = state.result,
|
1096
|
+
ch;
|
1097
|
+
|
1098
|
+
ch = state.input.charCodeAt(state.position);
|
1099
|
+
|
1100
|
+
if (is_WS_OR_EOL(ch) ||
|
1101
|
+
is_FLOW_INDICATOR(ch) ||
|
1102
|
+
0x23/* # */ === ch ||
|
1103
|
+
0x26/* & */ === ch ||
|
1104
|
+
0x2A/* * */ === ch ||
|
1105
|
+
0x21/* ! */ === ch ||
|
1106
|
+
0x7C/* | */ === ch ||
|
1107
|
+
0x3E/* > */ === ch ||
|
1108
|
+
0x27/* ' */ === ch ||
|
1109
|
+
0x22/* " */ === ch ||
|
1110
|
+
0x25/* % */ === ch ||
|
1111
|
+
0x40/* @ */ === ch ||
|
1112
|
+
0x60/* ` */ === ch) {
|
1113
|
+
return false;
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
if (0x3F/* ? */ === ch || 0x2D/* - */ === ch) {
|
1117
|
+
following = state.input.charCodeAt(state.position + 1);
|
1118
|
+
|
1119
|
+
if (is_WS_OR_EOL(following) ||
|
1120
|
+
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
1121
|
+
return false;
|
1122
|
+
}
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
state.kind = 'scalar';
|
1126
|
+
state.result = '';
|
1127
|
+
captureStart = captureEnd = state.position;
|
1128
|
+
hasPendingContent = false;
|
1129
|
+
|
1130
|
+
while (0 !== ch) {
|
1131
|
+
if (0x3A/* : */ === ch) {
|
1132
|
+
following = state.input.charCodeAt(state.position+1);
|
1133
|
+
|
1134
|
+
if (is_WS_OR_EOL(following) ||
|
1135
|
+
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
1136
|
+
break;
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
} else if (0x23/* # */ === ch) {
|
1140
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
1141
|
+
|
1142
|
+
if (is_WS_OR_EOL(preceding)) {
|
1143
|
+
break;
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
} else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
|
1147
|
+
withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
1148
|
+
break;
|
1149
|
+
|
1150
|
+
} else if (is_EOL(ch)) {
|
1151
|
+
_line = state.line;
|
1152
|
+
_lineStart = state.lineStart;
|
1153
|
+
_lineIndent = state.lineIndent;
|
1154
|
+
skipSeparationSpace(state, false, -1);
|
1155
|
+
|
1156
|
+
if (state.lineIndent >= nodeIndent) {
|
1157
|
+
hasPendingContent = true;
|
1158
|
+
ch = state.input.charCodeAt(state.position);
|
1159
|
+
continue;
|
1160
|
+
} else {
|
1161
|
+
state.position = captureEnd;
|
1162
|
+
state.line = _line;
|
1163
|
+
state.lineStart = _lineStart;
|
1164
|
+
state.lineIndent = _lineIndent;
|
1165
|
+
break;
|
1166
|
+
}
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
if (hasPendingContent) {
|
1170
|
+
captureSegment(state, captureStart, captureEnd, false);
|
1171
|
+
writeFoldedLines(state, state.line - _line);
|
1172
|
+
captureStart = captureEnd = state.position;
|
1173
|
+
hasPendingContent = false;
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
if (!is_WHITE_SPACE(ch)) {
|
1177
|
+
captureEnd = state.position + 1;
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
ch = state.input.charCodeAt(++state.position);
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
captureSegment(state, captureStart, captureEnd, false);
|
1184
|
+
|
1185
|
+
if (state.result) {
|
1186
|
+
return true;
|
1187
|
+
} else {
|
1188
|
+
state.kind = _kind;
|
1189
|
+
state.result = _result;
|
1190
|
+
return false;
|
1191
|
+
}
|
1192
|
+
}
|
1193
|
+
|
1194
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
1195
|
+
var ch,
|
1196
|
+
captureStart, captureEnd;
|
1197
|
+
|
1198
|
+
ch = state.input.charCodeAt(state.position);
|
1199
|
+
|
1200
|
+
if (0x27/* ' */ !== ch) {
|
1201
|
+
return false;
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
state.kind = 'scalar';
|
1205
|
+
state.result = '';
|
1206
|
+
state.position++;
|
1207
|
+
captureStart = captureEnd = state.position;
|
1208
|
+
|
1209
|
+
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
1210
|
+
if (0x27/* ' */ === ch) {
|
1211
|
+
captureSegment(state, captureStart, state.position, true);
|
1212
|
+
ch = state.input.charCodeAt(++state.position);
|
1213
|
+
|
1214
|
+
if (0x27/* ' */ === ch) {
|
1215
|
+
captureStart = captureEnd = state.position;
|
1216
|
+
state.position++;
|
1217
|
+
} else {
|
1218
|
+
return true;
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
} else if (is_EOL(ch)) {
|
1222
|
+
captureSegment(state, captureStart, captureEnd, true);
|
1223
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
1224
|
+
captureStart = captureEnd = state.position;
|
1225
|
+
|
1226
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
1227
|
+
throwError(state, 'unexpected end of the document within a single quoted scalar');
|
1228
|
+
|
1229
|
+
} else {
|
1230
|
+
state.position++;
|
1231
|
+
captureEnd = state.position;
|
1232
|
+
}
|
1233
|
+
}
|
1234
|
+
|
1235
|
+
throwError(state, 'unexpected end of the stream within a single quoted scalar');
|
1236
|
+
}
|
1237
|
+
|
1238
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
1239
|
+
var captureStart,
|
1240
|
+
captureEnd,
|
1241
|
+
hexLength,
|
1242
|
+
hexResult,
|
1243
|
+
tmp, tmpEsc,
|
1244
|
+
ch;
|
1245
|
+
|
1246
|
+
ch = state.input.charCodeAt(state.position);
|
1247
|
+
|
1248
|
+
if (0x22/* " */ !== ch) {
|
1249
|
+
return false;
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
state.kind = 'scalar';
|
1253
|
+
state.result = '';
|
1254
|
+
state.position++;
|
1255
|
+
captureStart = captureEnd = state.position;
|
1256
|
+
|
1257
|
+
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
1258
|
+
if (0x22/* " */ === ch) {
|
1259
|
+
captureSegment(state, captureStart, state.position, true);
|
1260
|
+
state.position++;
|
1261
|
+
return true;
|
1262
|
+
|
1263
|
+
} else if (0x5C/* \ */ === ch) {
|
1264
|
+
captureSegment(state, captureStart, state.position, true);
|
1265
|
+
ch = state.input.charCodeAt(++state.position);
|
1266
|
+
|
1267
|
+
if (is_EOL(ch)) {
|
1268
|
+
skipSeparationSpace(state, false, nodeIndent);
|
1269
|
+
|
1270
|
+
//TODO: rework to inline fn with no type cast?
|
1271
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
1272
|
+
state.result += simpleEscapeMap[ch];
|
1273
|
+
state.position++;
|
1274
|
+
|
1275
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
1276
|
+
hexLength = tmp;
|
1277
|
+
hexResult = 0;
|
1278
|
+
|
1279
|
+
for (; hexLength > 0; hexLength--) {
|
1280
|
+
ch = state.input.charCodeAt(++state.position);
|
1281
|
+
|
1282
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
1283
|
+
hexResult = (hexResult << 4) + tmp;
|
1284
|
+
|
1285
|
+
} else {
|
1286
|
+
throwError(state, 'expected hexadecimal character');
|
1287
|
+
}
|
1288
|
+
}
|
1289
|
+
|
1290
|
+
state.result += charFromCodepoint(hexResult);
|
1291
|
+
|
1292
|
+
state.position++;
|
1293
|
+
|
1294
|
+
} else {
|
1295
|
+
throwError(state, 'unknown escape sequence');
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
captureStart = captureEnd = state.position;
|
1299
|
+
|
1300
|
+
} else if (is_EOL(ch)) {
|
1301
|
+
captureSegment(state, captureStart, captureEnd, true);
|
1302
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
1303
|
+
captureStart = captureEnd = state.position;
|
1304
|
+
|
1305
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
1306
|
+
throwError(state, 'unexpected end of the document within a double quoted scalar');
|
1307
|
+
|
1308
|
+
} else {
|
1309
|
+
state.position++;
|
1310
|
+
captureEnd = state.position;
|
1311
|
+
}
|
1312
|
+
}
|
1313
|
+
|
1314
|
+
throwError(state, 'unexpected end of the stream within a double quoted scalar');
|
1315
|
+
}
|
1316
|
+
|
1317
|
+
function readFlowCollection(state, nodeIndent) {
|
1318
|
+
var readNext = true,
|
1319
|
+
_line,
|
1320
|
+
_tag = state.tag,
|
1321
|
+
_result,
|
1322
|
+
_anchor = state.anchor,
|
1323
|
+
following,
|
1324
|
+
terminator,
|
1325
|
+
isPair,
|
1326
|
+
isExplicitPair,
|
1327
|
+
isMapping,
|
1328
|
+
keyNode,
|
1329
|
+
keyTag,
|
1330
|
+
valueNode,
|
1331
|
+
ch;
|
1332
|
+
|
1333
|
+
ch = state.input.charCodeAt(state.position);
|
1334
|
+
|
1335
|
+
if (ch === 0x5B/* [ */) {
|
1336
|
+
terminator = 0x5D/* ] */;
|
1337
|
+
isMapping = false;
|
1338
|
+
_result = [];
|
1339
|
+
} else if (ch === 0x7B/* { */) {
|
1340
|
+
terminator = 0x7D/* } */;
|
1341
|
+
isMapping = true;
|
1342
|
+
_result = {};
|
1343
|
+
} else {
|
1344
|
+
return false;
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
if (null !== state.anchor) {
|
1348
|
+
state.anchorMap[state.anchor] = _result;
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
ch = state.input.charCodeAt(++state.position);
|
1352
|
+
|
1353
|
+
while (0 !== ch) {
|
1354
|
+
skipSeparationSpace(state, true, nodeIndent);
|
1355
|
+
|
1356
|
+
ch = state.input.charCodeAt(state.position);
|
1357
|
+
|
1358
|
+
if (ch === terminator) {
|
1359
|
+
state.position++;
|
1360
|
+
state.tag = _tag;
|
1361
|
+
state.anchor = _anchor;
|
1362
|
+
state.kind = isMapping ? 'mapping' : 'sequence';
|
1363
|
+
state.result = _result;
|
1364
|
+
return true;
|
1365
|
+
} else if (!readNext) {
|
1366
|
+
throwError(state, 'missed comma between flow collection entries');
|
1367
|
+
}
|
1368
|
+
|
1369
|
+
keyTag = keyNode = valueNode = null;
|
1370
|
+
isPair = isExplicitPair = false;
|
1371
|
+
|
1372
|
+
if (0x3F/* ? */ === ch) {
|
1373
|
+
following = state.input.charCodeAt(state.position + 1);
|
1374
|
+
|
1375
|
+
if (is_WS_OR_EOL(following)) {
|
1376
|
+
isPair = isExplicitPair = true;
|
1377
|
+
state.position++;
|
1378
|
+
skipSeparationSpace(state, true, nodeIndent);
|
1379
|
+
}
|
1380
|
+
}
|
1381
|
+
|
1382
|
+
_line = state.line;
|
1383
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
1384
|
+
keyTag = state.tag;
|
1385
|
+
keyNode = state.result;
|
1386
|
+
skipSeparationSpace(state, true, nodeIndent);
|
1387
|
+
|
1388
|
+
ch = state.input.charCodeAt(state.position);
|
1389
|
+
|
1390
|
+
if ((isExplicitPair || state.line === _line) && 0x3A/* : */ === ch) {
|
1391
|
+
isPair = true;
|
1392
|
+
ch = state.input.charCodeAt(++state.position);
|
1393
|
+
skipSeparationSpace(state, true, nodeIndent);
|
1394
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
1395
|
+
valueNode = state.result;
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
if (isMapping) {
|
1399
|
+
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
|
1400
|
+
} else if (isPair) {
|
1401
|
+
_result.push(storeMappingPair(state, null, keyTag, keyNode, valueNode));
|
1402
|
+
} else {
|
1403
|
+
_result.push(keyNode);
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
skipSeparationSpace(state, true, nodeIndent);
|
1407
|
+
|
1408
|
+
ch = state.input.charCodeAt(state.position);
|
1409
|
+
|
1410
|
+
if (0x2C/* , */ === ch) {
|
1411
|
+
readNext = true;
|
1412
|
+
ch = state.input.charCodeAt(++state.position);
|
1413
|
+
} else {
|
1414
|
+
readNext = false;
|
1415
|
+
}
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
throwError(state, 'unexpected end of the stream within a flow collection');
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
function readBlockScalar(state, nodeIndent) {
|
1422
|
+
var captureStart,
|
1423
|
+
folding,
|
1424
|
+
chomping = CHOMPING_CLIP,
|
1425
|
+
detectedIndent = false,
|
1426
|
+
textIndent = nodeIndent,
|
1427
|
+
emptyLines = 0,
|
1428
|
+
atMoreIndented = false,
|
1429
|
+
tmp,
|
1430
|
+
ch;
|
1431
|
+
|
1432
|
+
ch = state.input.charCodeAt(state.position);
|
1433
|
+
|
1434
|
+
if (ch === 0x7C/* | */) {
|
1435
|
+
folding = false;
|
1436
|
+
} else if (ch === 0x3E/* > */) {
|
1437
|
+
folding = true;
|
1438
|
+
} else {
|
1439
|
+
return false;
|
1440
|
+
}
|
1441
|
+
|
1442
|
+
state.kind = 'scalar';
|
1443
|
+
state.result = '';
|
1444
|
+
|
1445
|
+
while (0 !== ch) {
|
1446
|
+
ch = state.input.charCodeAt(++state.position);
|
1447
|
+
|
1448
|
+
if (0x2B/* + */ === ch || 0x2D/* - */ === ch) {
|
1449
|
+
if (CHOMPING_CLIP === chomping) {
|
1450
|
+
chomping = (0x2B/* + */ === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
|
1451
|
+
} else {
|
1452
|
+
throwError(state, 'repeat of a chomping mode identifier');
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
1456
|
+
if (tmp === 0) {
|
1457
|
+
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
|
1458
|
+
} else if (!detectedIndent) {
|
1459
|
+
textIndent = nodeIndent + tmp - 1;
|
1460
|
+
detectedIndent = true;
|
1461
|
+
} else {
|
1462
|
+
throwError(state, 'repeat of an indentation width identifier');
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
} else {
|
1466
|
+
break;
|
1467
|
+
}
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
if (is_WHITE_SPACE(ch)) {
|
1471
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
1472
|
+
while (is_WHITE_SPACE(ch));
|
1473
|
+
|
1474
|
+
if (0x23/* # */ === ch) {
|
1475
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
1476
|
+
while (!is_EOL(ch) && (0 !== ch));
|
1477
|
+
}
|
1478
|
+
}
|
1479
|
+
|
1480
|
+
while (0 !== ch) {
|
1481
|
+
readLineBreak(state);
|
1482
|
+
state.lineIndent = 0;
|
1483
|
+
|
1484
|
+
ch = state.input.charCodeAt(state.position);
|
1485
|
+
|
1486
|
+
while ((!detectedIndent || state.lineIndent < textIndent) &&
|
1487
|
+
(0x20/* Space */ === ch)) {
|
1488
|
+
state.lineIndent++;
|
1489
|
+
ch = state.input.charCodeAt(++state.position);
|
1490
|
+
}
|
1491
|
+
|
1492
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
1493
|
+
textIndent = state.lineIndent;
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
if (is_EOL(ch)) {
|
1497
|
+
emptyLines++;
|
1498
|
+
continue;
|
1499
|
+
}
|
1500
|
+
|
1501
|
+
// End of the scalar.
|
1502
|
+
if (state.lineIndent < textIndent) {
|
1503
|
+
|
1504
|
+
// Perform the chomping.
|
1505
|
+
if (chomping === CHOMPING_KEEP) {
|
1506
|
+
state.result += common.repeat('\n', emptyLines);
|
1507
|
+
} else if (chomping === CHOMPING_CLIP) {
|
1508
|
+
if (detectedIndent) { // i.e. only if the scalar is not empty.
|
1509
|
+
state.result += '\n';
|
1510
|
+
}
|
1511
|
+
}
|
1512
|
+
|
1513
|
+
// Break this `while` cycle and go to the funciton's epilogue.
|
1514
|
+
break;
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
// Folded style: use fancy rules to handle line breaks.
|
1518
|
+
if (folding) {
|
1519
|
+
|
1520
|
+
// Lines starting with white space characters (more-indented lines) are not folded.
|
1521
|
+
if (is_WHITE_SPACE(ch)) {
|
1522
|
+
atMoreIndented = true;
|
1523
|
+
state.result += common.repeat('\n', emptyLines + 1);
|
1524
|
+
|
1525
|
+
// End of more-indented block.
|
1526
|
+
} else if (atMoreIndented) {
|
1527
|
+
atMoreIndented = false;
|
1528
|
+
state.result += common.repeat('\n', emptyLines + 1);
|
1529
|
+
|
1530
|
+
// Just one line break - perceive as the same line.
|
1531
|
+
} else if (0 === emptyLines) {
|
1532
|
+
if (detectedIndent) { // i.e. only if we have already read some scalar content.
|
1533
|
+
state.result += ' ';
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
// Several line breaks - perceive as different lines.
|
1537
|
+
} else {
|
1538
|
+
state.result += common.repeat('\n', emptyLines);
|
1539
|
+
}
|
1540
|
+
|
1541
|
+
// Literal style: just add exact number of line breaks between content lines.
|
1542
|
+
} else {
|
1543
|
+
|
1544
|
+
// If current line isn't the first one - count line break from the last content line.
|
1545
|
+
if (detectedIndent) {
|
1546
|
+
state.result += common.repeat('\n', emptyLines + 1);
|
1547
|
+
|
1548
|
+
// In case of the first content line - count only empty lines.
|
1549
|
+
} else {
|
1550
|
+
state.result += common.repeat('\n', emptyLines);
|
1551
|
+
}
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
detectedIndent = true;
|
1555
|
+
emptyLines = 0;
|
1556
|
+
captureStart = state.position;
|
1557
|
+
|
1558
|
+
while (!is_EOL(ch) && (0 !== ch))
|
1559
|
+
{ ch = state.input.charCodeAt(++state.position); }
|
1560
|
+
|
1561
|
+
captureSegment(state, captureStart, state.position, false);
|
1562
|
+
}
|
1563
|
+
|
1564
|
+
return true;
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
function readBlockSequence(state, nodeIndent) {
|
1568
|
+
var _line,
|
1569
|
+
_tag = state.tag,
|
1570
|
+
_anchor = state.anchor,
|
1571
|
+
_result = [],
|
1572
|
+
following,
|
1573
|
+
detected = false,
|
1574
|
+
ch;
|
1575
|
+
|
1576
|
+
if (null !== state.anchor) {
|
1577
|
+
state.anchorMap[state.anchor] = _result;
|
1578
|
+
}
|
1579
|
+
|
1580
|
+
ch = state.input.charCodeAt(state.position);
|
1581
|
+
|
1582
|
+
while (0 !== ch) {
|
1583
|
+
|
1584
|
+
if (0x2D/* - */ !== ch) {
|
1585
|
+
break;
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
following = state.input.charCodeAt(state.position + 1);
|
1589
|
+
|
1590
|
+
if (!is_WS_OR_EOL(following)) {
|
1591
|
+
break;
|
1592
|
+
}
|
1593
|
+
|
1594
|
+
detected = true;
|
1595
|
+
state.position++;
|
1596
|
+
|
1597
|
+
if (skipSeparationSpace(state, true, -1)) {
|
1598
|
+
if (state.lineIndent <= nodeIndent) {
|
1599
|
+
_result.push(null);
|
1600
|
+
ch = state.input.charCodeAt(state.position);
|
1601
|
+
continue;
|
1602
|
+
}
|
1603
|
+
}
|
1604
|
+
|
1605
|
+
_line = state.line;
|
1606
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
1607
|
+
_result.push(state.result);
|
1608
|
+
skipSeparationSpace(state, true, -1);
|
1609
|
+
|
1610
|
+
ch = state.input.charCodeAt(state.position);
|
1611
|
+
|
1612
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
|
1613
|
+
throwError(state, 'bad indentation of a sequence entry');
|
1614
|
+
} else if (state.lineIndent < nodeIndent) {
|
1615
|
+
break;
|
1616
|
+
}
|
1617
|
+
}
|
1618
|
+
|
1619
|
+
if (detected) {
|
1620
|
+
state.tag = _tag;
|
1621
|
+
state.anchor = _anchor;
|
1622
|
+
state.kind = 'sequence';
|
1623
|
+
state.result = _result;
|
1624
|
+
return true;
|
1625
|
+
} else {
|
1626
|
+
return false;
|
1627
|
+
}
|
1628
|
+
}
|
1629
|
+
|
1630
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
1631
|
+
var following,
|
1632
|
+
allowCompact,
|
1633
|
+
_line,
|
1634
|
+
_tag = state.tag,
|
1635
|
+
_anchor = state.anchor,
|
1636
|
+
_result = {},
|
1637
|
+
keyTag = null,
|
1638
|
+
keyNode = null,
|
1639
|
+
valueNode = null,
|
1640
|
+
atExplicitKey = false,
|
1641
|
+
detected = false,
|
1642
|
+
ch;
|
1643
|
+
|
1644
|
+
if (null !== state.anchor) {
|
1645
|
+
state.anchorMap[state.anchor] = _result;
|
1646
|
+
}
|
1647
|
+
|
1648
|
+
ch = state.input.charCodeAt(state.position);
|
1649
|
+
|
1650
|
+
while (0 !== ch) {
|
1651
|
+
following = state.input.charCodeAt(state.position + 1);
|
1652
|
+
_line = state.line; // Save the current line.
|
1653
|
+
|
1654
|
+
//
|
1655
|
+
// Explicit notation case. There are two separate blocks:
|
1656
|
+
// first for the key (denoted by "?") and second for the value (denoted by ":")
|
1657
|
+
//
|
1658
|
+
if ((0x3F/* ? */ === ch || 0x3A/* : */ === ch) && is_WS_OR_EOL(following)) {
|
1659
|
+
|
1660
|
+
if (0x3F/* ? */ === ch) {
|
1661
|
+
if (atExplicitKey) {
|
1662
|
+
storeMappingPair(state, _result, keyTag, keyNode, null);
|
1663
|
+
keyTag = keyNode = valueNode = null;
|
1664
|
+
}
|
1665
|
+
|
1666
|
+
detected = true;
|
1667
|
+
atExplicitKey = true;
|
1668
|
+
allowCompact = true;
|
1669
|
+
|
1670
|
+
} else if (atExplicitKey) {
|
1671
|
+
// i.e. 0x3A/* : */ === character after the explicit key.
|
1672
|
+
atExplicitKey = false;
|
1673
|
+
allowCompact = true;
|
1674
|
+
|
1675
|
+
} else {
|
1676
|
+
throwError(state, 'incomplete explicit mapping pair; a key node is missed');
|
1677
|
+
}
|
1678
|
+
|
1679
|
+
state.position += 1;
|
1680
|
+
ch = following;
|
1681
|
+
|
1682
|
+
//
|
1683
|
+
// Implicit notation case. Flow-style node as the key first, then ":", and the value.
|
1684
|
+
//
|
1685
|
+
} else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
1686
|
+
|
1687
|
+
if (state.line === _line) {
|
1688
|
+
ch = state.input.charCodeAt(state.position);
|
1689
|
+
|
1690
|
+
while (is_WHITE_SPACE(ch)) {
|
1691
|
+
ch = state.input.charCodeAt(++state.position);
|
1692
|
+
}
|
1693
|
+
|
1694
|
+
if (0x3A/* : */ === ch) {
|
1695
|
+
ch = state.input.charCodeAt(++state.position);
|
1696
|
+
|
1697
|
+
if (!is_WS_OR_EOL(ch)) {
|
1698
|
+
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
|
1699
|
+
}
|
1700
|
+
|
1701
|
+
if (atExplicitKey) {
|
1702
|
+
storeMappingPair(state, _result, keyTag, keyNode, null);
|
1703
|
+
keyTag = keyNode = valueNode = null;
|
1704
|
+
}
|
1705
|
+
|
1706
|
+
detected = true;
|
1707
|
+
atExplicitKey = false;
|
1708
|
+
allowCompact = false;
|
1709
|
+
keyTag = state.tag;
|
1710
|
+
keyNode = state.result;
|
1711
|
+
|
1712
|
+
} else if (detected) {
|
1713
|
+
throwError(state, 'can not read an implicit mapping pair; a colon is missed');
|
1714
|
+
|
1715
|
+
} else {
|
1716
|
+
state.tag = _tag;
|
1717
|
+
state.anchor = _anchor;
|
1718
|
+
return true; // Keep the result of `composeNode`.
|
1719
|
+
}
|
1720
|
+
|
1721
|
+
} else if (detected) {
|
1722
|
+
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
|
1723
|
+
|
1724
|
+
} else {
|
1725
|
+
state.tag = _tag;
|
1726
|
+
state.anchor = _anchor;
|
1727
|
+
return true; // Keep the result of `composeNode`.
|
1728
|
+
}
|
1729
|
+
|
1730
|
+
} else {
|
1731
|
+
break; // Reading is done. Go to the epilogue.
|
1732
|
+
}
|
1733
|
+
|
1734
|
+
//
|
1735
|
+
// Common reading code for both explicit and implicit notations.
|
1736
|
+
//
|
1737
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
1738
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
1739
|
+
if (atExplicitKey) {
|
1740
|
+
keyNode = state.result;
|
1741
|
+
} else {
|
1742
|
+
valueNode = state.result;
|
1743
|
+
}
|
1744
|
+
}
|
1745
|
+
|
1746
|
+
if (!atExplicitKey) {
|
1747
|
+
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
|
1748
|
+
keyTag = keyNode = valueNode = null;
|
1749
|
+
}
|
1750
|
+
|
1751
|
+
skipSeparationSpace(state, true, -1);
|
1752
|
+
ch = state.input.charCodeAt(state.position);
|
1753
|
+
}
|
1754
|
+
|
1755
|
+
if (state.lineIndent > nodeIndent && (0 !== ch)) {
|
1756
|
+
throwError(state, 'bad indentation of a mapping entry');
|
1757
|
+
} else if (state.lineIndent < nodeIndent) {
|
1758
|
+
break;
|
1759
|
+
}
|
1760
|
+
}
|
1761
|
+
|
1762
|
+
//
|
1763
|
+
// Epilogue.
|
1764
|
+
//
|
1765
|
+
|
1766
|
+
// Special case: last mapping's node contains only the key in explicit notation.
|
1767
|
+
if (atExplicitKey) {
|
1768
|
+
storeMappingPair(state, _result, keyTag, keyNode, null);
|
1769
|
+
}
|
1770
|
+
|
1771
|
+
// Expose the resulting mapping.
|
1772
|
+
if (detected) {
|
1773
|
+
state.tag = _tag;
|
1774
|
+
state.anchor = _anchor;
|
1775
|
+
state.kind = 'mapping';
|
1776
|
+
state.result = _result;
|
1777
|
+
}
|
1778
|
+
|
1779
|
+
return detected;
|
1780
|
+
}
|
1781
|
+
|
1782
|
+
function readTagProperty(state) {
|
1783
|
+
var _position,
|
1784
|
+
isVerbatim = false,
|
1785
|
+
isNamed = false,
|
1786
|
+
tagHandle,
|
1787
|
+
tagName,
|
1788
|
+
ch;
|
1789
|
+
|
1790
|
+
ch = state.input.charCodeAt(state.position);
|
1791
|
+
|
1792
|
+
if (0x21/* ! */ !== ch) {
|
1793
|
+
return false;
|
1794
|
+
}
|
1795
|
+
|
1796
|
+
if (null !== state.tag) {
|
1797
|
+
throwError(state, 'duplication of a tag property');
|
1798
|
+
}
|
1799
|
+
|
1800
|
+
ch = state.input.charCodeAt(++state.position);
|
1801
|
+
|
1802
|
+
if (0x3C/* < */ === ch) {
|
1803
|
+
isVerbatim = true;
|
1804
|
+
ch = state.input.charCodeAt(++state.position);
|
1805
|
+
|
1806
|
+
} else if (0x21/* ! */ === ch) {
|
1807
|
+
isNamed = true;
|
1808
|
+
tagHandle = '!!';
|
1809
|
+
ch = state.input.charCodeAt(++state.position);
|
1810
|
+
|
1811
|
+
} else {
|
1812
|
+
tagHandle = '!';
|
1813
|
+
}
|
1814
|
+
|
1815
|
+
_position = state.position;
|
1816
|
+
|
1817
|
+
if (isVerbatim) {
|
1818
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
1819
|
+
while (0 !== ch && 0x3E/* > */ !== ch);
|
1820
|
+
|
1821
|
+
if (state.position < state.length) {
|
1822
|
+
tagName = state.input.slice(_position, state.position);
|
1823
|
+
ch = state.input.charCodeAt(++state.position);
|
1824
|
+
} else {
|
1825
|
+
throwError(state, 'unexpected end of the stream within a verbatim tag');
|
1826
|
+
}
|
1827
|
+
} else {
|
1828
|
+
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
1829
|
+
|
1830
|
+
if (0x21/* ! */ === ch) {
|
1831
|
+
if (!isNamed) {
|
1832
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
1833
|
+
|
1834
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
1835
|
+
throwError(state, 'named tag handle cannot contain such characters');
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
isNamed = true;
|
1839
|
+
_position = state.position + 1;
|
1840
|
+
} else {
|
1841
|
+
throwError(state, 'tag suffix cannot contain exclamation marks');
|
1842
|
+
}
|
1843
|
+
}
|
1844
|
+
|
1845
|
+
ch = state.input.charCodeAt(++state.position);
|
1846
|
+
}
|
1847
|
+
|
1848
|
+
tagName = state.input.slice(_position, state.position);
|
1849
|
+
|
1850
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
1851
|
+
throwError(state, 'tag suffix cannot contain flow indicator characters');
|
1852
|
+
}
|
1853
|
+
}
|
1854
|
+
|
1855
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
1856
|
+
throwError(state, 'tag name cannot contain such characters: ' + tagName);
|
1857
|
+
}
|
1858
|
+
|
1859
|
+
if (isVerbatim) {
|
1860
|
+
state.tag = tagName;
|
1861
|
+
|
1862
|
+
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
1863
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
1864
|
+
|
1865
|
+
} else if ('!' === tagHandle) {
|
1866
|
+
state.tag = '!' + tagName;
|
1867
|
+
|
1868
|
+
} else if ('!!' === tagHandle) {
|
1869
|
+
state.tag = 'tag:yaml.org,2002:' + tagName;
|
1870
|
+
|
1871
|
+
} else {
|
1872
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
1873
|
+
}
|
1874
|
+
|
1875
|
+
return true;
|
1876
|
+
}
|
1877
|
+
|
1878
|
+
function readAnchorProperty(state) {
|
1879
|
+
var _position,
|
1880
|
+
ch;
|
1881
|
+
|
1882
|
+
ch = state.input.charCodeAt(state.position);
|
1883
|
+
|
1884
|
+
if (0x26/* & */ !== ch) {
|
1885
|
+
return false;
|
1886
|
+
}
|
1887
|
+
|
1888
|
+
if (null !== state.anchor) {
|
1889
|
+
throwError(state, 'duplication of an anchor property');
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
ch = state.input.charCodeAt(++state.position);
|
1893
|
+
_position = state.position;
|
1894
|
+
|
1895
|
+
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
1896
|
+
ch = state.input.charCodeAt(++state.position);
|
1897
|
+
}
|
1898
|
+
|
1899
|
+
if (state.position === _position) {
|
1900
|
+
throwError(state, 'name of an anchor node must contain at least one character');
|
1901
|
+
}
|
1902
|
+
|
1903
|
+
state.anchor = state.input.slice(_position, state.position);
|
1904
|
+
return true;
|
1905
|
+
}
|
1906
|
+
|
1907
|
+
function readAlias(state) {
|
1908
|
+
var _position, alias,
|
1909
|
+
len = state.length,
|
1910
|
+
input = state.input,
|
1911
|
+
ch;
|
1912
|
+
|
1913
|
+
ch = state.input.charCodeAt(state.position);
|
1914
|
+
|
1915
|
+
if (0x2A/* * */ !== ch) {
|
1916
|
+
return false;
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
ch = state.input.charCodeAt(++state.position);
|
1920
|
+
_position = state.position;
|
1921
|
+
|
1922
|
+
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
1923
|
+
ch = state.input.charCodeAt(++state.position);
|
1924
|
+
}
|
1925
|
+
|
1926
|
+
if (state.position === _position) {
|
1927
|
+
throwError(state, 'name of an alias node must contain at least one character');
|
1928
|
+
}
|
1929
|
+
|
1930
|
+
alias = state.input.slice(_position, state.position);
|
1931
|
+
|
1932
|
+
if (!state.anchorMap.hasOwnProperty(alias)) {
|
1933
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
1934
|
+
}
|
1935
|
+
|
1936
|
+
state.result = state.anchorMap[alias];
|
1937
|
+
skipSeparationSpace(state, true, -1);
|
1938
|
+
return true;
|
1939
|
+
}
|
1940
|
+
|
1941
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
1942
|
+
var allowBlockStyles,
|
1943
|
+
allowBlockScalars,
|
1944
|
+
allowBlockCollections,
|
1945
|
+
indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
|
1946
|
+
atNewLine = false,
|
1947
|
+
hasContent = false,
|
1948
|
+
typeIndex,
|
1949
|
+
typeQuantity,
|
1950
|
+
type,
|
1951
|
+
flowIndent,
|
1952
|
+
blockIndent,
|
1953
|
+
_result;
|
1954
|
+
|
1955
|
+
state.tag = null;
|
1956
|
+
state.anchor = null;
|
1957
|
+
state.kind = null;
|
1958
|
+
state.result = null;
|
1959
|
+
|
1960
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections =
|
1961
|
+
CONTEXT_BLOCK_OUT === nodeContext ||
|
1962
|
+
CONTEXT_BLOCK_IN === nodeContext;
|
1963
|
+
|
1964
|
+
if (allowToSeek) {
|
1965
|
+
if (skipSeparationSpace(state, true, -1)) {
|
1966
|
+
atNewLine = true;
|
1967
|
+
|
1968
|
+
if (state.lineIndent > parentIndent) {
|
1969
|
+
indentStatus = 1;
|
1970
|
+
} else if (state.lineIndent === parentIndent) {
|
1971
|
+
indentStatus = 0;
|
1972
|
+
} else if (state.lineIndent < parentIndent) {
|
1973
|
+
indentStatus = -1;
|
1974
|
+
}
|
1975
|
+
}
|
1976
|
+
}
|
1977
|
+
|
1978
|
+
if (1 === indentStatus) {
|
1979
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
1980
|
+
if (skipSeparationSpace(state, true, -1)) {
|
1981
|
+
atNewLine = true;
|
1982
|
+
allowBlockCollections = allowBlockStyles;
|
1983
|
+
|
1984
|
+
if (state.lineIndent > parentIndent) {
|
1985
|
+
indentStatus = 1;
|
1986
|
+
} else if (state.lineIndent === parentIndent) {
|
1987
|
+
indentStatus = 0;
|
1988
|
+
} else if (state.lineIndent < parentIndent) {
|
1989
|
+
indentStatus = -1;
|
1990
|
+
}
|
1991
|
+
} else {
|
1992
|
+
allowBlockCollections = false;
|
1993
|
+
}
|
1994
|
+
}
|
1995
|
+
}
|
1996
|
+
|
1997
|
+
if (allowBlockCollections) {
|
1998
|
+
allowBlockCollections = atNewLine || allowCompact;
|
1999
|
+
}
|
2000
|
+
|
2001
|
+
if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
|
2002
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
2003
|
+
flowIndent = parentIndent;
|
2004
|
+
} else {
|
2005
|
+
flowIndent = parentIndent + 1;
|
2006
|
+
}
|
2007
|
+
|
2008
|
+
blockIndent = state.position - state.lineStart;
|
2009
|
+
|
2010
|
+
if (1 === indentStatus) {
|
2011
|
+
if (allowBlockCollections &&
|
2012
|
+
(readBlockSequence(state, blockIndent) ||
|
2013
|
+
readBlockMapping(state, blockIndent, flowIndent)) ||
|
2014
|
+
readFlowCollection(state, flowIndent)) {
|
2015
|
+
hasContent = true;
|
2016
|
+
} else {
|
2017
|
+
if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
|
2018
|
+
readSingleQuotedScalar(state, flowIndent) ||
|
2019
|
+
readDoubleQuotedScalar(state, flowIndent)) {
|
2020
|
+
hasContent = true;
|
2021
|
+
|
2022
|
+
} else if (readAlias(state)) {
|
2023
|
+
hasContent = true;
|
2024
|
+
|
2025
|
+
if (null !== state.tag || null !== state.anchor) {
|
2026
|
+
throwError(state, 'alias node should not have any properties');
|
2027
|
+
}
|
2028
|
+
|
2029
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
2030
|
+
hasContent = true;
|
2031
|
+
|
2032
|
+
if (null === state.tag) {
|
2033
|
+
state.tag = '?';
|
2034
|
+
}
|
2035
|
+
}
|
2036
|
+
|
2037
|
+
if (null !== state.anchor) {
|
2038
|
+
state.anchorMap[state.anchor] = state.result;
|
2039
|
+
}
|
2040
|
+
}
|
2041
|
+
} else if (0 === indentStatus) {
|
2042
|
+
// Special case: block sequences are allowed to have same indentation level as the parent.
|
2043
|
+
// http://www.yaml.org/spec/1.2/spec.html#id2799784
|
2044
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
2045
|
+
}
|
2046
|
+
}
|
2047
|
+
|
2048
|
+
if (null !== state.tag && '!' !== state.tag) {
|
2049
|
+
if ('?' === state.tag) {
|
2050
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
|
2051
|
+
typeIndex < typeQuantity;
|
2052
|
+
typeIndex += 1) {
|
2053
|
+
type = state.implicitTypes[typeIndex];
|
2054
|
+
|
2055
|
+
// Implicit resolving is not allowed for non-scalar types, and '?'
|
2056
|
+
// non-specific tag is only assigned to plain scalars. So, it isn't
|
2057
|
+
// needed to check for 'kind' conformity.
|
2058
|
+
|
2059
|
+
if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
|
2060
|
+
state.result = type.construct(state.result);
|
2061
|
+
state.tag = type.tag;
|
2062
|
+
if (null !== state.anchor) {
|
2063
|
+
state.anchorMap[state.anchor] = state.result;
|
2064
|
+
}
|
2065
|
+
break;
|
2066
|
+
}
|
2067
|
+
}
|
2068
|
+
} else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
|
2069
|
+
type = state.typeMap[state.tag];
|
2070
|
+
|
2071
|
+
if (null !== state.result && type.kind !== state.kind) {
|
2072
|
+
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
2073
|
+
}
|
2074
|
+
|
2075
|
+
if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
|
2076
|
+
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
|
2077
|
+
} else {
|
2078
|
+
state.result = type.construct(state.result);
|
2079
|
+
if (null !== state.anchor) {
|
2080
|
+
state.anchorMap[state.anchor] = state.result;
|
2081
|
+
}
|
2082
|
+
}
|
2083
|
+
} else {
|
2084
|
+
throwWarning(state, 'unknown tag !<' + state.tag + '>');
|
2085
|
+
}
|
2086
|
+
}
|
2087
|
+
|
2088
|
+
return null !== state.tag || null !== state.anchor || hasContent;
|
2089
|
+
}
|
2090
|
+
|
2091
|
+
function readDocument(state) {
|
2092
|
+
var documentStart = state.position,
|
2093
|
+
_position,
|
2094
|
+
directiveName,
|
2095
|
+
directiveArgs,
|
2096
|
+
hasDirectives = false,
|
2097
|
+
ch;
|
2098
|
+
|
2099
|
+
state.version = null;
|
2100
|
+
state.checkLineBreaks = state.legacy;
|
2101
|
+
state.tagMap = {};
|
2102
|
+
state.anchorMap = {};
|
2103
|
+
|
2104
|
+
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
2105
|
+
skipSeparationSpace(state, true, -1);
|
2106
|
+
|
2107
|
+
ch = state.input.charCodeAt(state.position);
|
2108
|
+
|
2109
|
+
if (state.lineIndent > 0 || 0x25/* % */ !== ch) {
|
2110
|
+
break;
|
2111
|
+
}
|
2112
|
+
|
2113
|
+
hasDirectives = true;
|
2114
|
+
ch = state.input.charCodeAt(++state.position);
|
2115
|
+
_position = state.position;
|
2116
|
+
|
2117
|
+
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
2118
|
+
ch = state.input.charCodeAt(++state.position);
|
2119
|
+
}
|
2120
|
+
|
2121
|
+
directiveName = state.input.slice(_position, state.position);
|
2122
|
+
directiveArgs = [];
|
2123
|
+
|
2124
|
+
if (directiveName.length < 1) {
|
2125
|
+
throwError(state, 'directive name must not be less than one character in length');
|
2126
|
+
}
|
2127
|
+
|
2128
|
+
while (0 !== ch) {
|
2129
|
+
while (is_WHITE_SPACE(ch)) {
|
2130
|
+
ch = state.input.charCodeAt(++state.position);
|
2131
|
+
}
|
2132
|
+
|
2133
|
+
if (0x23/* # */ === ch) {
|
2134
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
2135
|
+
while (0 !== ch && !is_EOL(ch));
|
2136
|
+
break;
|
2137
|
+
}
|
2138
|
+
|
2139
|
+
if (is_EOL(ch)) {
|
2140
|
+
break;
|
2141
|
+
}
|
2142
|
+
|
2143
|
+
_position = state.position;
|
2144
|
+
|
2145
|
+
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
2146
|
+
ch = state.input.charCodeAt(++state.position);
|
2147
|
+
}
|
2148
|
+
|
2149
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
2150
|
+
}
|
2151
|
+
|
2152
|
+
if (0 !== ch) {
|
2153
|
+
readLineBreak(state);
|
2154
|
+
}
|
2155
|
+
|
2156
|
+
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
2157
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
2158
|
+
} else {
|
2159
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
2160
|
+
}
|
2161
|
+
}
|
2162
|
+
|
2163
|
+
skipSeparationSpace(state, true, -1);
|
2164
|
+
|
2165
|
+
if (0 === state.lineIndent &&
|
2166
|
+
0x2D/* - */ === state.input.charCodeAt(state.position) &&
|
2167
|
+
0x2D/* - */ === state.input.charCodeAt(state.position + 1) &&
|
2168
|
+
0x2D/* - */ === state.input.charCodeAt(state.position + 2)) {
|
2169
|
+
state.position += 3;
|
2170
|
+
skipSeparationSpace(state, true, -1);
|
2171
|
+
|
2172
|
+
} else if (hasDirectives) {
|
2173
|
+
throwError(state, 'directives end mark is expected');
|
2174
|
+
}
|
2175
|
+
|
2176
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
2177
|
+
skipSeparationSpace(state, true, -1);
|
2178
|
+
|
2179
|
+
if (state.checkLineBreaks &&
|
2180
|
+
PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
2181
|
+
throwWarning(state, 'non-ASCII line breaks are interpreted as content');
|
2182
|
+
}
|
2183
|
+
|
2184
|
+
state.documents.push(state.result);
|
2185
|
+
|
2186
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
2187
|
+
|
2188
|
+
if (0x2E/* . */ === state.input.charCodeAt(state.position)) {
|
2189
|
+
state.position += 3;
|
2190
|
+
skipSeparationSpace(state, true, -1);
|
2191
|
+
}
|
2192
|
+
return;
|
2193
|
+
}
|
2194
|
+
|
2195
|
+
if (state.position < (state.length - 1)) {
|
2196
|
+
throwError(state, 'end of the stream or a document separator is expected');
|
2197
|
+
} else {
|
2198
|
+
return;
|
2199
|
+
}
|
2200
|
+
}
|
2201
|
+
|
2202
|
+
|
2203
|
+
function loadDocuments(input, options) {
|
2204
|
+
input = String(input);
|
2205
|
+
options = options || {};
|
2206
|
+
|
2207
|
+
if (0 !== input.length &&
|
2208
|
+
0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
|
2209
|
+
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
|
2210
|
+
input += '\n';
|
2211
|
+
}
|
2212
|
+
|
2213
|
+
var state = new State(input, options);
|
2214
|
+
|
2215
|
+
if (PATTERN_NON_PRINTABLE.test(state.input)) {
|
2216
|
+
throwError(state, 'the stream contains non-printable characters');
|
2217
|
+
}
|
2218
|
+
|
2219
|
+
// Use 0 as string terminator. That significantly simplifies bounds check.
|
2220
|
+
state.input += '\0';
|
2221
|
+
|
2222
|
+
while (0x20/* Space */ === state.input.charCodeAt(state.position)) {
|
2223
|
+
state.lineIndent += 1;
|
2224
|
+
state.position += 1;
|
2225
|
+
}
|
2226
|
+
|
2227
|
+
while (state.position < (state.length - 1)) {
|
2228
|
+
readDocument(state);
|
2229
|
+
}
|
2230
|
+
|
2231
|
+
return state.documents;
|
2232
|
+
}
|
2233
|
+
|
2234
|
+
|
2235
|
+
function loadAll(input, iterator, options) {
|
2236
|
+
var documents = loadDocuments(input, options), index, length;
|
2237
|
+
|
2238
|
+
for (index = 0, length = documents.length; index < length; index += 1) {
|
2239
|
+
iterator(documents[index]);
|
2240
|
+
}
|
2241
|
+
}
|
2242
|
+
|
2243
|
+
|
2244
|
+
function load(input, options) {
|
2245
|
+
var documents = loadDocuments(input, options), index, length;
|
2246
|
+
|
2247
|
+
if (0 === documents.length) {
|
2248
|
+
return undefined;
|
2249
|
+
} else if (1 === documents.length) {
|
2250
|
+
return documents[0];
|
2251
|
+
} else {
|
2252
|
+
throw new YAMLException('expected a single document in the stream, but found more');
|
2253
|
+
}
|
2254
|
+
}
|
2255
|
+
|
2256
|
+
|
2257
|
+
function safeLoadAll(input, output, options) {
|
2258
|
+
loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
2259
|
+
}
|
2260
|
+
|
2261
|
+
|
2262
|
+
function safeLoad(input, options) {
|
2263
|
+
return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
2264
|
+
}
|
2265
|
+
|
2266
|
+
|
2267
|
+
module.exports.loadAll = loadAll;
|
2268
|
+
module.exports.load = load;
|
2269
|
+
module.exports.safeLoadAll = safeLoadAll;
|
2270
|
+
module.exports.safeLoad = safeLoad;
|
2271
|
+
|
2272
|
+
},{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
|
2273
|
+
'use strict';
|
2274
|
+
|
2275
|
+
|
2276
|
+
var common = require('./common');
|
2277
|
+
|
2278
|
+
|
2279
|
+
function Mark(name, buffer, position, line, column) {
|
2280
|
+
this.name = name;
|
2281
|
+
this.buffer = buffer;
|
2282
|
+
this.position = position;
|
2283
|
+
this.line = line;
|
2284
|
+
this.column = column;
|
2285
|
+
}
|
2286
|
+
|
2287
|
+
|
2288
|
+
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
2289
|
+
var head, start, tail, end, snippet;
|
2290
|
+
|
2291
|
+
if (!this.buffer) {
|
2292
|
+
return null;
|
2293
|
+
}
|
2294
|
+
|
2295
|
+
indent = indent || 4;
|
2296
|
+
maxLength = maxLength || 75;
|
2297
|
+
|
2298
|
+
head = '';
|
2299
|
+
start = this.position;
|
2300
|
+
|
2301
|
+
while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
|
2302
|
+
start -= 1;
|
2303
|
+
if (this.position - start > (maxLength / 2 - 1)) {
|
2304
|
+
head = ' ... ';
|
2305
|
+
start += 5;
|
2306
|
+
break;
|
2307
|
+
}
|
2308
|
+
}
|
2309
|
+
|
2310
|
+
tail = '';
|
2311
|
+
end = this.position;
|
2312
|
+
|
2313
|
+
while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
|
2314
|
+
end += 1;
|
2315
|
+
if (end - this.position > (maxLength / 2 - 1)) {
|
2316
|
+
tail = ' ... ';
|
2317
|
+
end -= 5;
|
2318
|
+
break;
|
2319
|
+
}
|
2320
|
+
}
|
2321
|
+
|
2322
|
+
snippet = this.buffer.slice(start, end);
|
2323
|
+
|
2324
|
+
return common.repeat(' ', indent) + head + snippet + tail + '\n' +
|
2325
|
+
common.repeat(' ', indent + this.position - start + head.length) + '^';
|
2326
|
+
};
|
2327
|
+
|
2328
|
+
|
2329
|
+
Mark.prototype.toString = function toString(compact) {
|
2330
|
+
var snippet, where = '';
|
2331
|
+
|
2332
|
+
if (this.name) {
|
2333
|
+
where += 'in "' + this.name + '" ';
|
2334
|
+
}
|
2335
|
+
|
2336
|
+
where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
|
2337
|
+
|
2338
|
+
if (!compact) {
|
2339
|
+
snippet = this.getSnippet();
|
2340
|
+
|
2341
|
+
if (snippet) {
|
2342
|
+
where += ':\n' + snippet;
|
2343
|
+
}
|
2344
|
+
}
|
2345
|
+
|
2346
|
+
return where;
|
2347
|
+
};
|
2348
|
+
|
2349
|
+
|
2350
|
+
module.exports = Mark;
|
2351
|
+
|
2352
|
+
},{"./common":2}],7:[function(require,module,exports){
|
2353
|
+
'use strict';
|
2354
|
+
|
2355
|
+
|
2356
|
+
var common = require('./common');
|
2357
|
+
var YAMLException = require('./exception');
|
2358
|
+
var Type = require('./type');
|
2359
|
+
|
2360
|
+
|
2361
|
+
function compileList(schema, name, result) {
|
2362
|
+
var exclude = [];
|
2363
|
+
|
2364
|
+
schema.include.forEach(function (includedSchema) {
|
2365
|
+
result = compileList(includedSchema, name, result);
|
2366
|
+
});
|
2367
|
+
|
2368
|
+
schema[name].forEach(function (currentType) {
|
2369
|
+
result.forEach(function (previousType, previousIndex) {
|
2370
|
+
if (previousType.tag === currentType.tag) {
|
2371
|
+
exclude.push(previousIndex);
|
2372
|
+
}
|
2373
|
+
});
|
2374
|
+
|
2375
|
+
result.push(currentType);
|
2376
|
+
});
|
2377
|
+
|
2378
|
+
return result.filter(function (type, index) {
|
2379
|
+
return -1 === exclude.indexOf(index);
|
2380
|
+
});
|
2381
|
+
}
|
2382
|
+
|
2383
|
+
|
2384
|
+
function compileMap(/* lists... */) {
|
2385
|
+
var result = {}, index, length;
|
2386
|
+
|
2387
|
+
function collectType(type) {
|
2388
|
+
result[type.tag] = type;
|
2389
|
+
}
|
2390
|
+
|
2391
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
2392
|
+
arguments[index].forEach(collectType);
|
2393
|
+
}
|
2394
|
+
|
2395
|
+
return result;
|
2396
|
+
}
|
2397
|
+
|
2398
|
+
|
2399
|
+
function Schema(definition) {
|
2400
|
+
this.include = definition.include || [];
|
2401
|
+
this.implicit = definition.implicit || [];
|
2402
|
+
this.explicit = definition.explicit || [];
|
2403
|
+
|
2404
|
+
this.implicit.forEach(function (type) {
|
2405
|
+
if (type.loadKind && 'scalar' !== type.loadKind) {
|
2406
|
+
throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
|
2407
|
+
}
|
2408
|
+
});
|
2409
|
+
|
2410
|
+
this.compiledImplicit = compileList(this, 'implicit', []);
|
2411
|
+
this.compiledExplicit = compileList(this, 'explicit', []);
|
2412
|
+
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
2413
|
+
}
|
2414
|
+
|
2415
|
+
|
2416
|
+
Schema.DEFAULT = null;
|
2417
|
+
|
2418
|
+
|
2419
|
+
Schema.create = function createSchema() {
|
2420
|
+
var schemas, types;
|
2421
|
+
|
2422
|
+
switch (arguments.length) {
|
2423
|
+
case 1:
|
2424
|
+
schemas = Schema.DEFAULT;
|
2425
|
+
types = arguments[0];
|
2426
|
+
break;
|
2427
|
+
|
2428
|
+
case 2:
|
2429
|
+
schemas = arguments[0];
|
2430
|
+
types = arguments[1];
|
2431
|
+
break;
|
2432
|
+
|
2433
|
+
default:
|
2434
|
+
throw new YAMLException('Wrong number of arguments for Schema.create function');
|
2435
|
+
}
|
2436
|
+
|
2437
|
+
schemas = common.toArray(schemas);
|
2438
|
+
types = common.toArray(types);
|
2439
|
+
|
2440
|
+
if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
|
2441
|
+
throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
|
2442
|
+
}
|
2443
|
+
|
2444
|
+
if (!types.every(function (type) { return type instanceof Type; })) {
|
2445
|
+
throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
2446
|
+
}
|
2447
|
+
|
2448
|
+
return new Schema({
|
2449
|
+
include: schemas,
|
2450
|
+
explicit: types
|
2451
|
+
});
|
2452
|
+
};
|
2453
|
+
|
2454
|
+
|
2455
|
+
module.exports = Schema;
|
2456
|
+
|
2457
|
+
},{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){
|
2458
|
+
// Standard YAML's Core schema.
|
2459
|
+
// http://www.yaml.org/spec/1.2/spec.html#id2804923
|
2460
|
+
//
|
2461
|
+
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
2462
|
+
// So, Core schema has no distinctions from JSON schema is JS-YAML.
|
2463
|
+
|
2464
|
+
|
2465
|
+
'use strict';
|
2466
|
+
|
2467
|
+
|
2468
|
+
var Schema = require('../schema');
|
2469
|
+
|
2470
|
+
|
2471
|
+
module.exports = new Schema({
|
2472
|
+
include: [
|
2473
|
+
require('./json')
|
2474
|
+
]
|
2475
|
+
});
|
2476
|
+
|
2477
|
+
},{"../schema":7,"./json":12}],9:[function(require,module,exports){
|
2478
|
+
// JS-YAML's default schema for `load` function.
|
2479
|
+
// It is not described in the YAML specification.
|
2480
|
+
//
|
2481
|
+
// This schema is based on JS-YAML's default safe schema and includes
|
2482
|
+
// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
|
2483
|
+
//
|
2484
|
+
// Also this schema is used as default base schema at `Schema.create` function.
|
2485
|
+
|
2486
|
+
|
2487
|
+
'use strict';
|
2488
|
+
|
2489
|
+
|
2490
|
+
var Schema = require('../schema');
|
2491
|
+
|
2492
|
+
|
2493
|
+
module.exports = Schema.DEFAULT = new Schema({
|
2494
|
+
include: [
|
2495
|
+
require('./default_safe')
|
2496
|
+
],
|
2497
|
+
explicit: [
|
2498
|
+
require('../type/js/undefined'),
|
2499
|
+
require('../type/js/regexp'),
|
2500
|
+
require('../type/js/function')
|
2501
|
+
]
|
2502
|
+
});
|
2503
|
+
|
2504
|
+
},{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){
|
2505
|
+
// JS-YAML's default schema for `safeLoad` function.
|
2506
|
+
// It is not described in the YAML specification.
|
2507
|
+
//
|
2508
|
+
// This schema is based on standard YAML's Core schema and includes most of
|
2509
|
+
// extra types described at YAML tag repository. (http://yaml.org/type/)
|
2510
|
+
|
2511
|
+
|
2512
|
+
'use strict';
|
2513
|
+
|
2514
|
+
|
2515
|
+
var Schema = require('../schema');
|
2516
|
+
|
2517
|
+
|
2518
|
+
module.exports = new Schema({
|
2519
|
+
include: [
|
2520
|
+
require('./core')
|
2521
|
+
],
|
2522
|
+
implicit: [
|
2523
|
+
require('../type/timestamp'),
|
2524
|
+
require('../type/merge')
|
2525
|
+
],
|
2526
|
+
explicit: [
|
2527
|
+
require('../type/binary'),
|
2528
|
+
require('../type/omap'),
|
2529
|
+
require('../type/pairs'),
|
2530
|
+
require('../type/set')
|
2531
|
+
]
|
2532
|
+
});
|
2533
|
+
|
2534
|
+
},{"../schema":7,"../type/binary":14,"../type/merge":22,"../type/omap":24,"../type/pairs":25,"../type/set":27,"../type/timestamp":29,"./core":8}],11:[function(require,module,exports){
|
2535
|
+
// Standard YAML's Failsafe schema.
|
2536
|
+
// http://www.yaml.org/spec/1.2/spec.html#id2802346
|
2537
|
+
|
2538
|
+
|
2539
|
+
'use strict';
|
2540
|
+
|
2541
|
+
|
2542
|
+
var Schema = require('../schema');
|
2543
|
+
|
2544
|
+
|
2545
|
+
module.exports = new Schema({
|
2546
|
+
explicit: [
|
2547
|
+
require('../type/str'),
|
2548
|
+
require('../type/seq'),
|
2549
|
+
require('../type/map')
|
2550
|
+
]
|
2551
|
+
});
|
2552
|
+
|
2553
|
+
},{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){
|
2554
|
+
// Standard YAML's JSON schema.
|
2555
|
+
// http://www.yaml.org/spec/1.2/spec.html#id2803231
|
2556
|
+
//
|
2557
|
+
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
2558
|
+
// So, this schema is not such strict as defined in the YAML specification.
|
2559
|
+
// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
|
2560
|
+
|
2561
|
+
|
2562
|
+
'use strict';
|
2563
|
+
|
2564
|
+
|
2565
|
+
var Schema = require('../schema');
|
2566
|
+
|
2567
|
+
|
2568
|
+
module.exports = new Schema({
|
2569
|
+
include: [
|
2570
|
+
require('./failsafe')
|
2571
|
+
],
|
2572
|
+
implicit: [
|
2573
|
+
require('../type/null'),
|
2574
|
+
require('../type/bool'),
|
2575
|
+
require('../type/int'),
|
2576
|
+
require('../type/float')
|
2577
|
+
]
|
2578
|
+
});
|
2579
|
+
|
2580
|
+
},{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
|
2581
|
+
'use strict';
|
2582
|
+
|
2583
|
+
var YAMLException = require('./exception');
|
2584
|
+
|
2585
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
2586
|
+
'kind',
|
2587
|
+
'resolve',
|
2588
|
+
'construct',
|
2589
|
+
'instanceOf',
|
2590
|
+
'predicate',
|
2591
|
+
'represent',
|
2592
|
+
'defaultStyle',
|
2593
|
+
'styleAliases'
|
2594
|
+
];
|
2595
|
+
|
2596
|
+
var YAML_NODE_KINDS = [
|
2597
|
+
'scalar',
|
2598
|
+
'sequence',
|
2599
|
+
'mapping'
|
2600
|
+
];
|
2601
|
+
|
2602
|
+
function compileStyleAliases(map) {
|
2603
|
+
var result = {};
|
2604
|
+
|
2605
|
+
if (null !== map) {
|
2606
|
+
Object.keys(map).forEach(function (style) {
|
2607
|
+
map[style].forEach(function (alias) {
|
2608
|
+
result[String(alias)] = style;
|
2609
|
+
});
|
2610
|
+
});
|
2611
|
+
}
|
2612
|
+
|
2613
|
+
return result;
|
2614
|
+
}
|
2615
|
+
|
2616
|
+
function Type(tag, options) {
|
2617
|
+
options = options || {};
|
2618
|
+
|
2619
|
+
Object.keys(options).forEach(function (name) {
|
2620
|
+
if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
|
2621
|
+
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
2622
|
+
}
|
2623
|
+
});
|
2624
|
+
|
2625
|
+
// TODO: Add tag format check.
|
2626
|
+
this.tag = tag;
|
2627
|
+
this.kind = options['kind'] || null;
|
2628
|
+
this.resolve = options['resolve'] || function () { return true; };
|
2629
|
+
this.construct = options['construct'] || function (data) { return data; };
|
2630
|
+
this.instanceOf = options['instanceOf'] || null;
|
2631
|
+
this.predicate = options['predicate'] || null;
|
2632
|
+
this.represent = options['represent'] || null;
|
2633
|
+
this.defaultStyle = options['defaultStyle'] || null;
|
2634
|
+
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
|
2635
|
+
|
2636
|
+
if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
|
2637
|
+
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
2638
|
+
}
|
2639
|
+
}
|
2640
|
+
|
2641
|
+
module.exports = Type;
|
2642
|
+
|
2643
|
+
},{"./exception":4}],14:[function(require,module,exports){
|
2644
|
+
'use strict';
|
2645
|
+
|
2646
|
+
|
2647
|
+
// A trick for browserified version.
|
2648
|
+
// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
|
2649
|
+
var NodeBuffer = require('buffer').Buffer;
|
2650
|
+
var Type = require('../type');
|
2651
|
+
|
2652
|
+
|
2653
|
+
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
|
2654
|
+
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
2655
|
+
|
2656
|
+
|
2657
|
+
function resolveYamlBinary(data) {
|
2658
|
+
if (null === data) {
|
2659
|
+
return false;
|
2660
|
+
}
|
2661
|
+
|
2662
|
+
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
|
2663
|
+
|
2664
|
+
// Convert one by one.
|
2665
|
+
for (idx = 0; idx < max; idx ++) {
|
2666
|
+
code = map.indexOf(data.charAt(idx));
|
2667
|
+
|
2668
|
+
// Skip CR/LF
|
2669
|
+
if (code > 64) { continue; }
|
2670
|
+
|
2671
|
+
// Fail on illegal characters
|
2672
|
+
if (code < 0) { return false; }
|
2673
|
+
|
2674
|
+
bitlen += 6;
|
2675
|
+
}
|
2676
|
+
|
2677
|
+
// If there are any bits left, source was corrupted
|
2678
|
+
return (bitlen % 8) === 0;
|
2679
|
+
}
|
2680
|
+
|
2681
|
+
function constructYamlBinary(data) {
|
2682
|
+
var code, idx, tailbits,
|
2683
|
+
input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
|
2684
|
+
max = input.length,
|
2685
|
+
map = BASE64_MAP,
|
2686
|
+
bits = 0,
|
2687
|
+
result = [];
|
2688
|
+
|
2689
|
+
// Collect by 6*4 bits (3 bytes)
|
2690
|
+
|
2691
|
+
for (idx = 0; idx < max; idx++) {
|
2692
|
+
if ((idx % 4 === 0) && idx) {
|
2693
|
+
result.push((bits >> 16) & 0xFF);
|
2694
|
+
result.push((bits >> 8) & 0xFF);
|
2695
|
+
result.push(bits & 0xFF);
|
2696
|
+
}
|
2697
|
+
|
2698
|
+
bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
2699
|
+
}
|
2700
|
+
|
2701
|
+
// Dump tail
|
2702
|
+
|
2703
|
+
tailbits = (max % 4)*6;
|
2704
|
+
|
2705
|
+
if (tailbits === 0) {
|
2706
|
+
result.push((bits >> 16) & 0xFF);
|
2707
|
+
result.push((bits >> 8) & 0xFF);
|
2708
|
+
result.push(bits & 0xFF);
|
2709
|
+
} else if (tailbits === 18) {
|
2710
|
+
result.push((bits >> 10) & 0xFF);
|
2711
|
+
result.push((bits >> 2) & 0xFF);
|
2712
|
+
} else if (tailbits === 12) {
|
2713
|
+
result.push((bits >> 4) & 0xFF);
|
2714
|
+
}
|
2715
|
+
|
2716
|
+
// Wrap into Buffer for NodeJS and leave Array for browser
|
2717
|
+
if (NodeBuffer) {
|
2718
|
+
return new NodeBuffer(result);
|
2719
|
+
}
|
2720
|
+
|
2721
|
+
return result;
|
2722
|
+
}
|
2723
|
+
|
2724
|
+
function representYamlBinary(object /*, style*/) {
|
2725
|
+
var result = '', bits = 0, idx, tail,
|
2726
|
+
max = object.length,
|
2727
|
+
map = BASE64_MAP;
|
2728
|
+
|
2729
|
+
// Convert every three bytes to 4 ASCII characters.
|
2730
|
+
|
2731
|
+
for (idx = 0; idx < max; idx++) {
|
2732
|
+
if ((idx % 3 === 0) && idx) {
|
2733
|
+
result += map[(bits >> 18) & 0x3F];
|
2734
|
+
result += map[(bits >> 12) & 0x3F];
|
2735
|
+
result += map[(bits >> 6) & 0x3F];
|
2736
|
+
result += map[bits & 0x3F];
|
2737
|
+
}
|
2738
|
+
|
2739
|
+
bits = (bits << 8) + object[idx];
|
2740
|
+
}
|
2741
|
+
|
2742
|
+
// Dump tail
|
2743
|
+
|
2744
|
+
tail = max % 3;
|
2745
|
+
|
2746
|
+
if (tail === 0) {
|
2747
|
+
result += map[(bits >> 18) & 0x3F];
|
2748
|
+
result += map[(bits >> 12) & 0x3F];
|
2749
|
+
result += map[(bits >> 6) & 0x3F];
|
2750
|
+
result += map[bits & 0x3F];
|
2751
|
+
} else if (tail === 2) {
|
2752
|
+
result += map[(bits >> 10) & 0x3F];
|
2753
|
+
result += map[(bits >> 4) & 0x3F];
|
2754
|
+
result += map[(bits << 2) & 0x3F];
|
2755
|
+
result += map[64];
|
2756
|
+
} else if (tail === 1) {
|
2757
|
+
result += map[(bits >> 2) & 0x3F];
|
2758
|
+
result += map[(bits << 4) & 0x3F];
|
2759
|
+
result += map[64];
|
2760
|
+
result += map[64];
|
2761
|
+
}
|
2762
|
+
|
2763
|
+
return result;
|
2764
|
+
}
|
2765
|
+
|
2766
|
+
function isBinary(object) {
|
2767
|
+
return NodeBuffer && NodeBuffer.isBuffer(object);
|
2768
|
+
}
|
2769
|
+
|
2770
|
+
module.exports = new Type('tag:yaml.org,2002:binary', {
|
2771
|
+
kind: 'scalar',
|
2772
|
+
resolve: resolveYamlBinary,
|
2773
|
+
construct: constructYamlBinary,
|
2774
|
+
predicate: isBinary,
|
2775
|
+
represent: representYamlBinary
|
2776
|
+
});
|
2777
|
+
|
2778
|
+
},{"../type":13,"buffer":30}],15:[function(require,module,exports){
|
2779
|
+
'use strict';
|
2780
|
+
|
2781
|
+
var Type = require('../type');
|
2782
|
+
|
2783
|
+
function resolveYamlBoolean(data) {
|
2784
|
+
if (null === data) {
|
2785
|
+
return false;
|
2786
|
+
}
|
2787
|
+
|
2788
|
+
var max = data.length;
|
2789
|
+
|
2790
|
+
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
|
2791
|
+
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
|
2792
|
+
}
|
2793
|
+
|
2794
|
+
function constructYamlBoolean(data) {
|
2795
|
+
return data === 'true' ||
|
2796
|
+
data === 'True' ||
|
2797
|
+
data === 'TRUE';
|
2798
|
+
}
|
2799
|
+
|
2800
|
+
function isBoolean(object) {
|
2801
|
+
return '[object Boolean]' === Object.prototype.toString.call(object);
|
2802
|
+
}
|
2803
|
+
|
2804
|
+
module.exports = new Type('tag:yaml.org,2002:bool', {
|
2805
|
+
kind: 'scalar',
|
2806
|
+
resolve: resolveYamlBoolean,
|
2807
|
+
construct: constructYamlBoolean,
|
2808
|
+
predicate: isBoolean,
|
2809
|
+
represent: {
|
2810
|
+
lowercase: function (object) { return object ? 'true' : 'false'; },
|
2811
|
+
uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
|
2812
|
+
camelcase: function (object) { return object ? 'True' : 'False'; }
|
2813
|
+
},
|
2814
|
+
defaultStyle: 'lowercase'
|
2815
|
+
});
|
2816
|
+
|
2817
|
+
},{"../type":13}],16:[function(require,module,exports){
|
2818
|
+
'use strict';
|
2819
|
+
|
2820
|
+
var common = require('../common');
|
2821
|
+
var Type = require('../type');
|
2822
|
+
|
2823
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
2824
|
+
'^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
|
2825
|
+
'|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
|
2826
|
+
'|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
|
2827
|
+
'|[-+]?\\.(?:inf|Inf|INF)' +
|
2828
|
+
'|\\.(?:nan|NaN|NAN))$');
|
2829
|
+
|
2830
|
+
function resolveYamlFloat(data) {
|
2831
|
+
if (null === data) {
|
2832
|
+
return false;
|
2833
|
+
}
|
2834
|
+
|
2835
|
+
var value, sign, base, digits;
|
2836
|
+
|
2837
|
+
if (!YAML_FLOAT_PATTERN.test(data)) {
|
2838
|
+
return false;
|
2839
|
+
}
|
2840
|
+
return true;
|
2841
|
+
}
|
2842
|
+
|
2843
|
+
function constructYamlFloat(data) {
|
2844
|
+
var value, sign, base, digits;
|
2845
|
+
|
2846
|
+
value = data.replace(/_/g, '').toLowerCase();
|
2847
|
+
sign = '-' === value[0] ? -1 : 1;
|
2848
|
+
digits = [];
|
2849
|
+
|
2850
|
+
if (0 <= '+-'.indexOf(value[0])) {
|
2851
|
+
value = value.slice(1);
|
2852
|
+
}
|
2853
|
+
|
2854
|
+
if ('.inf' === value) {
|
2855
|
+
return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
2856
|
+
|
2857
|
+
} else if ('.nan' === value) {
|
2858
|
+
return NaN;
|
2859
|
+
|
2860
|
+
} else if (0 <= value.indexOf(':')) {
|
2861
|
+
value.split(':').forEach(function (v) {
|
2862
|
+
digits.unshift(parseFloat(v, 10));
|
2863
|
+
});
|
2864
|
+
|
2865
|
+
value = 0.0;
|
2866
|
+
base = 1;
|
2867
|
+
|
2868
|
+
digits.forEach(function (d) {
|
2869
|
+
value += d * base;
|
2870
|
+
base *= 60;
|
2871
|
+
});
|
2872
|
+
|
2873
|
+
return sign * value;
|
2874
|
+
|
2875
|
+
} else {
|
2876
|
+
return sign * parseFloat(value, 10);
|
2877
|
+
}
|
2878
|
+
}
|
2879
|
+
|
2880
|
+
function representYamlFloat(object, style) {
|
2881
|
+
if (isNaN(object)) {
|
2882
|
+
switch (style) {
|
2883
|
+
case 'lowercase':
|
2884
|
+
return '.nan';
|
2885
|
+
case 'uppercase':
|
2886
|
+
return '.NAN';
|
2887
|
+
case 'camelcase':
|
2888
|
+
return '.NaN';
|
2889
|
+
}
|
2890
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
2891
|
+
switch (style) {
|
2892
|
+
case 'lowercase':
|
2893
|
+
return '.inf';
|
2894
|
+
case 'uppercase':
|
2895
|
+
return '.INF';
|
2896
|
+
case 'camelcase':
|
2897
|
+
return '.Inf';
|
2898
|
+
}
|
2899
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
2900
|
+
switch (style) {
|
2901
|
+
case 'lowercase':
|
2902
|
+
return '-.inf';
|
2903
|
+
case 'uppercase':
|
2904
|
+
return '-.INF';
|
2905
|
+
case 'camelcase':
|
2906
|
+
return '-.Inf';
|
2907
|
+
}
|
2908
|
+
} else if (common.isNegativeZero(object)) {
|
2909
|
+
return '-0.0';
|
2910
|
+
} else {
|
2911
|
+
return object.toString(10);
|
2912
|
+
}
|
2913
|
+
}
|
2914
|
+
|
2915
|
+
function isFloat(object) {
|
2916
|
+
return ('[object Number]' === Object.prototype.toString.call(object)) &&
|
2917
|
+
(0 !== object % 1 || common.isNegativeZero(object));
|
2918
|
+
}
|
2919
|
+
|
2920
|
+
module.exports = new Type('tag:yaml.org,2002:float', {
|
2921
|
+
kind: 'scalar',
|
2922
|
+
resolve: resolveYamlFloat,
|
2923
|
+
construct: constructYamlFloat,
|
2924
|
+
predicate: isFloat,
|
2925
|
+
represent: representYamlFloat,
|
2926
|
+
defaultStyle: 'lowercase'
|
2927
|
+
});
|
2928
|
+
|
2929
|
+
},{"../common":2,"../type":13}],17:[function(require,module,exports){
|
2930
|
+
'use strict';
|
2931
|
+
|
2932
|
+
var common = require('../common');
|
2933
|
+
var Type = require('../type');
|
2934
|
+
|
2935
|
+
function isHexCode(c) {
|
2936
|
+
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
|
2937
|
+
((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
|
2938
|
+
((0x61/* a */ <= c) && (c <= 0x66/* f */));
|
2939
|
+
}
|
2940
|
+
|
2941
|
+
function isOctCode(c) {
|
2942
|
+
return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
|
2943
|
+
}
|
2944
|
+
|
2945
|
+
function isDecCode(c) {
|
2946
|
+
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
|
2947
|
+
}
|
2948
|
+
|
2949
|
+
function resolveYamlInteger(data) {
|
2950
|
+
if (null === data) {
|
2951
|
+
return false;
|
2952
|
+
}
|
2953
|
+
|
2954
|
+
var max = data.length,
|
2955
|
+
index = 0,
|
2956
|
+
hasDigits = false,
|
2957
|
+
ch;
|
2958
|
+
|
2959
|
+
if (!max) { return false; }
|
2960
|
+
|
2961
|
+
ch = data[index];
|
2962
|
+
|
2963
|
+
// sign
|
2964
|
+
if (ch === '-' || ch === '+') {
|
2965
|
+
ch = data[++index];
|
2966
|
+
}
|
2967
|
+
|
2968
|
+
if (ch === '0') {
|
2969
|
+
// 0
|
2970
|
+
if (index+1 === max) { return true; }
|
2971
|
+
ch = data[++index];
|
2972
|
+
|
2973
|
+
// base 2, base 8, base 16
|
2974
|
+
|
2975
|
+
if (ch === 'b') {
|
2976
|
+
// base 2
|
2977
|
+
index++;
|
2978
|
+
|
2979
|
+
for (; index < max; index++) {
|
2980
|
+
ch = data[index];
|
2981
|
+
if (ch === '_') { continue; }
|
2982
|
+
if (ch !== '0' && ch !== '1') {
|
2983
|
+
return false;
|
2984
|
+
}
|
2985
|
+
hasDigits = true;
|
2986
|
+
}
|
2987
|
+
return hasDigits;
|
2988
|
+
}
|
2989
|
+
|
2990
|
+
|
2991
|
+
if (ch === 'x') {
|
2992
|
+
// base 16
|
2993
|
+
index++;
|
2994
|
+
|
2995
|
+
for (; index < max; index++) {
|
2996
|
+
ch = data[index];
|
2997
|
+
if (ch === '_') { continue; }
|
2998
|
+
if (!isHexCode(data.charCodeAt(index))) {
|
2999
|
+
return false;
|
3000
|
+
}
|
3001
|
+
hasDigits = true;
|
3002
|
+
}
|
3003
|
+
return hasDigits;
|
3004
|
+
}
|
3005
|
+
|
3006
|
+
// base 8
|
3007
|
+
for (; index < max; index++) {
|
3008
|
+
ch = data[index];
|
3009
|
+
if (ch === '_') { continue; }
|
3010
|
+
if (!isOctCode(data.charCodeAt(index))) {
|
3011
|
+
return false;
|
3012
|
+
}
|
3013
|
+
hasDigits = true;
|
3014
|
+
}
|
3015
|
+
return hasDigits;
|
3016
|
+
}
|
3017
|
+
|
3018
|
+
// base 10 (except 0) or base 60
|
3019
|
+
|
3020
|
+
for (; index < max; index++) {
|
3021
|
+
ch = data[index];
|
3022
|
+
if (ch === '_') { continue; }
|
3023
|
+
if (ch === ':') { break; }
|
3024
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
3025
|
+
return false;
|
3026
|
+
}
|
3027
|
+
hasDigits = true;
|
3028
|
+
}
|
3029
|
+
|
3030
|
+
if (!hasDigits) { return false; }
|
3031
|
+
|
3032
|
+
// if !base60 - done;
|
3033
|
+
if (ch !== ':') { return true; }
|
3034
|
+
|
3035
|
+
// base60 almost not used, no needs to optimize
|
3036
|
+
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
3037
|
+
}
|
3038
|
+
|
3039
|
+
function constructYamlInteger(data) {
|
3040
|
+
var value = data, sign = 1, ch, base, digits = [];
|
3041
|
+
|
3042
|
+
if (value.indexOf('_') !== -1) {
|
3043
|
+
value = value.replace(/_/g, '');
|
3044
|
+
}
|
3045
|
+
|
3046
|
+
ch = value[0];
|
3047
|
+
|
3048
|
+
if (ch === '-' || ch === '+') {
|
3049
|
+
if (ch === '-') { sign = -1; }
|
3050
|
+
value = value.slice(1);
|
3051
|
+
ch = value[0];
|
3052
|
+
}
|
3053
|
+
|
3054
|
+
if ('0' === value) {
|
3055
|
+
return 0;
|
3056
|
+
}
|
3057
|
+
|
3058
|
+
if (ch === '0') {
|
3059
|
+
if (value[1] === 'b') {
|
3060
|
+
return sign * parseInt(value.slice(2), 2);
|
3061
|
+
}
|
3062
|
+
if (value[1] === 'x') {
|
3063
|
+
return sign * parseInt(value, 16);
|
3064
|
+
}
|
3065
|
+
return sign * parseInt(value, 8);
|
3066
|
+
|
3067
|
+
}
|
3068
|
+
|
3069
|
+
if (value.indexOf(':') !== -1) {
|
3070
|
+
value.split(':').forEach(function (v) {
|
3071
|
+
digits.unshift(parseInt(v, 10));
|
3072
|
+
});
|
3073
|
+
|
3074
|
+
value = 0;
|
3075
|
+
base = 1;
|
3076
|
+
|
3077
|
+
digits.forEach(function (d) {
|
3078
|
+
value += (d * base);
|
3079
|
+
base *= 60;
|
3080
|
+
});
|
3081
|
+
|
3082
|
+
return sign * value;
|
3083
|
+
|
3084
|
+
}
|
3085
|
+
|
3086
|
+
return sign * parseInt(value, 10);
|
3087
|
+
}
|
3088
|
+
|
3089
|
+
function isInteger(object) {
|
3090
|
+
return ('[object Number]' === Object.prototype.toString.call(object)) &&
|
3091
|
+
(0 === object % 1 && !common.isNegativeZero(object));
|
3092
|
+
}
|
3093
|
+
|
3094
|
+
module.exports = new Type('tag:yaml.org,2002:int', {
|
3095
|
+
kind: 'scalar',
|
3096
|
+
resolve: resolveYamlInteger,
|
3097
|
+
construct: constructYamlInteger,
|
3098
|
+
predicate: isInteger,
|
3099
|
+
represent: {
|
3100
|
+
binary: function (object) { return '0b' + object.toString(2); },
|
3101
|
+
octal: function (object) { return '0' + object.toString(8); },
|
3102
|
+
decimal: function (object) { return object.toString(10); },
|
3103
|
+
hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
|
3104
|
+
},
|
3105
|
+
defaultStyle: 'decimal',
|
3106
|
+
styleAliases: {
|
3107
|
+
binary: [ 2, 'bin' ],
|
3108
|
+
octal: [ 8, 'oct' ],
|
3109
|
+
decimal: [ 10, 'dec' ],
|
3110
|
+
hexadecimal: [ 16, 'hex' ]
|
3111
|
+
}
|
3112
|
+
});
|
3113
|
+
|
3114
|
+
},{"../common":2,"../type":13}],18:[function(require,module,exports){
|
3115
|
+
'use strict';
|
3116
|
+
|
3117
|
+
var esprima;
|
3118
|
+
|
3119
|
+
// Browserified version does not have esprima
|
3120
|
+
//
|
3121
|
+
// 1. For node.js just require module as deps
|
3122
|
+
// 2. For browser try to require mudule via external AMD system.
|
3123
|
+
// If not found - try to fallback to window.esprima. If not
|
3124
|
+
// found too - then fail to parse.
|
3125
|
+
//
|
3126
|
+
try {
|
3127
|
+
esprima = require('esprima');
|
3128
|
+
} catch (_) {
|
3129
|
+
/*global window */
|
3130
|
+
if (typeof window !== 'undefined') { esprima = window.esprima; }
|
3131
|
+
}
|
3132
|
+
|
3133
|
+
var Type = require('../../type');
|
3134
|
+
|
3135
|
+
function resolveJavascriptFunction(data) {
|
3136
|
+
if (null === data) {
|
3137
|
+
return false;
|
3138
|
+
}
|
3139
|
+
|
3140
|
+
try {
|
3141
|
+
var source = '(' + data + ')',
|
3142
|
+
ast = esprima.parse(source, { range: true }),
|
3143
|
+
params = [],
|
3144
|
+
body;
|
3145
|
+
|
3146
|
+
if ('Program' !== ast.type ||
|
3147
|
+
1 !== ast.body.length ||
|
3148
|
+
'ExpressionStatement' !== ast.body[0].type ||
|
3149
|
+
'FunctionExpression' !== ast.body[0].expression.type) {
|
3150
|
+
return false;
|
3151
|
+
}
|
3152
|
+
|
3153
|
+
return true;
|
3154
|
+
} catch (err) {
|
3155
|
+
return false;
|
3156
|
+
}
|
3157
|
+
}
|
3158
|
+
|
3159
|
+
function constructJavascriptFunction(data) {
|
3160
|
+
/*jslint evil:true*/
|
3161
|
+
|
3162
|
+
var source = '(' + data + ')',
|
3163
|
+
ast = esprima.parse(source, { range: true }),
|
3164
|
+
params = [],
|
3165
|
+
body;
|
3166
|
+
|
3167
|
+
if ('Program' !== ast.type ||
|
3168
|
+
1 !== ast.body.length ||
|
3169
|
+
'ExpressionStatement' !== ast.body[0].type ||
|
3170
|
+
'FunctionExpression' !== ast.body[0].expression.type) {
|
3171
|
+
throw new Error('Failed to resolve function');
|
3172
|
+
}
|
3173
|
+
|
3174
|
+
ast.body[0].expression.params.forEach(function (param) {
|
3175
|
+
params.push(param.name);
|
3176
|
+
});
|
3177
|
+
|
3178
|
+
body = ast.body[0].expression.body.range;
|
3179
|
+
|
3180
|
+
// Esprima's ranges include the first '{' and the last '}' characters on
|
3181
|
+
// function expressions. So cut them out.
|
3182
|
+
return new Function(params, source.slice(body[0]+1, body[1]-1));
|
3183
|
+
}
|
3184
|
+
|
3185
|
+
function representJavascriptFunction(object /*, style*/) {
|
3186
|
+
return object.toString();
|
3187
|
+
}
|
3188
|
+
|
3189
|
+
function isFunction(object) {
|
3190
|
+
return '[object Function]' === Object.prototype.toString.call(object);
|
3191
|
+
}
|
3192
|
+
|
3193
|
+
module.exports = new Type('tag:yaml.org,2002:js/function', {
|
3194
|
+
kind: 'scalar',
|
3195
|
+
resolve: resolveJavascriptFunction,
|
3196
|
+
construct: constructJavascriptFunction,
|
3197
|
+
predicate: isFunction,
|
3198
|
+
represent: representJavascriptFunction
|
3199
|
+
});
|
3200
|
+
|
3201
|
+
},{"../../type":13,"esprima":"esprima"}],19:[function(require,module,exports){
|
3202
|
+
'use strict';
|
3203
|
+
|
3204
|
+
var Type = require('../../type');
|
3205
|
+
|
3206
|
+
function resolveJavascriptRegExp(data) {
|
3207
|
+
if (null === data) {
|
3208
|
+
return false;
|
3209
|
+
}
|
3210
|
+
|
3211
|
+
if (0 === data.length) {
|
3212
|
+
return false;
|
3213
|
+
}
|
3214
|
+
|
3215
|
+
var regexp = data,
|
3216
|
+
tail = /\/([gim]*)$/.exec(data),
|
3217
|
+
modifiers = '';
|
3218
|
+
|
3219
|
+
// if regexp starts with '/' it can have modifiers and must be properly closed
|
3220
|
+
// `/foo/gim` - modifiers tail can be maximum 3 chars
|
3221
|
+
if ('/' === regexp[0]) {
|
3222
|
+
if (tail) {
|
3223
|
+
modifiers = tail[1];
|
3224
|
+
}
|
3225
|
+
|
3226
|
+
if (modifiers.length > 3) { return false; }
|
3227
|
+
// if expression starts with /, is should be properly terminated
|
3228
|
+
if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
|
3229
|
+
|
3230
|
+
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
3231
|
+
}
|
3232
|
+
|
3233
|
+
try {
|
3234
|
+
var dummy = new RegExp(regexp, modifiers);
|
3235
|
+
return true;
|
3236
|
+
} catch (error) {
|
3237
|
+
return false;
|
3238
|
+
}
|
3239
|
+
}
|
3240
|
+
|
3241
|
+
function constructJavascriptRegExp(data) {
|
3242
|
+
var regexp = data,
|
3243
|
+
tail = /\/([gim]*)$/.exec(data),
|
3244
|
+
modifiers = '';
|
3245
|
+
|
3246
|
+
// `/foo/gim` - tail can be maximum 4 chars
|
3247
|
+
if ('/' === regexp[0]) {
|
3248
|
+
if (tail) {
|
3249
|
+
modifiers = tail[1];
|
3250
|
+
}
|
3251
|
+
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
3252
|
+
}
|
3253
|
+
|
3254
|
+
return new RegExp(regexp, modifiers);
|
3255
|
+
}
|
3256
|
+
|
3257
|
+
function representJavascriptRegExp(object /*, style*/) {
|
3258
|
+
var result = '/' + object.source + '/';
|
3259
|
+
|
3260
|
+
if (object.global) {
|
3261
|
+
result += 'g';
|
3262
|
+
}
|
3263
|
+
|
3264
|
+
if (object.multiline) {
|
3265
|
+
result += 'm';
|
3266
|
+
}
|
3267
|
+
|
3268
|
+
if (object.ignoreCase) {
|
3269
|
+
result += 'i';
|
3270
|
+
}
|
3271
|
+
|
3272
|
+
return result;
|
3273
|
+
}
|
3274
|
+
|
3275
|
+
function isRegExp(object) {
|
3276
|
+
return '[object RegExp]' === Object.prototype.toString.call(object);
|
3277
|
+
}
|
3278
|
+
|
3279
|
+
module.exports = new Type('tag:yaml.org,2002:js/regexp', {
|
3280
|
+
kind: 'scalar',
|
3281
|
+
resolve: resolveJavascriptRegExp,
|
3282
|
+
construct: constructJavascriptRegExp,
|
3283
|
+
predicate: isRegExp,
|
3284
|
+
represent: representJavascriptRegExp
|
3285
|
+
});
|
3286
|
+
|
3287
|
+
},{"../../type":13}],20:[function(require,module,exports){
|
3288
|
+
'use strict';
|
3289
|
+
|
3290
|
+
var Type = require('../../type');
|
3291
|
+
|
3292
|
+
function resolveJavascriptUndefined() {
|
3293
|
+
return true;
|
3294
|
+
}
|
3295
|
+
|
3296
|
+
function constructJavascriptUndefined() {
|
3297
|
+
return undefined;
|
3298
|
+
}
|
3299
|
+
|
3300
|
+
function representJavascriptUndefined() {
|
3301
|
+
return '';
|
3302
|
+
}
|
3303
|
+
|
3304
|
+
function isUndefined(object) {
|
3305
|
+
return 'undefined' === typeof object;
|
3306
|
+
}
|
3307
|
+
|
3308
|
+
module.exports = new Type('tag:yaml.org,2002:js/undefined', {
|
3309
|
+
kind: 'scalar',
|
3310
|
+
resolve: resolveJavascriptUndefined,
|
3311
|
+
construct: constructJavascriptUndefined,
|
3312
|
+
predicate: isUndefined,
|
3313
|
+
represent: representJavascriptUndefined
|
3314
|
+
});
|
3315
|
+
|
3316
|
+
},{"../../type":13}],21:[function(require,module,exports){
|
3317
|
+
'use strict';
|
3318
|
+
|
3319
|
+
var Type = require('../type');
|
3320
|
+
|
3321
|
+
module.exports = new Type('tag:yaml.org,2002:map', {
|
3322
|
+
kind: 'mapping',
|
3323
|
+
construct: function (data) { return null !== data ? data : {}; }
|
3324
|
+
});
|
3325
|
+
|
3326
|
+
},{"../type":13}],22:[function(require,module,exports){
|
3327
|
+
'use strict';
|
3328
|
+
|
3329
|
+
var Type = require('../type');
|
3330
|
+
|
3331
|
+
function resolveYamlMerge(data) {
|
3332
|
+
return '<<' === data || null === data;
|
3333
|
+
}
|
3334
|
+
|
3335
|
+
module.exports = new Type('tag:yaml.org,2002:merge', {
|
3336
|
+
kind: 'scalar',
|
3337
|
+
resolve: resolveYamlMerge
|
3338
|
+
});
|
3339
|
+
|
3340
|
+
},{"../type":13}],23:[function(require,module,exports){
|
3341
|
+
'use strict';
|
3342
|
+
|
3343
|
+
var Type = require('../type');
|
3344
|
+
|
3345
|
+
function resolveYamlNull(data) {
|
3346
|
+
if (null === data) {
|
3347
|
+
return true;
|
3348
|
+
}
|
3349
|
+
|
3350
|
+
var max = data.length;
|
3351
|
+
|
3352
|
+
return (max === 1 && data === '~') ||
|
3353
|
+
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
|
3354
|
+
}
|
3355
|
+
|
3356
|
+
function constructYamlNull() {
|
3357
|
+
return null;
|
3358
|
+
}
|
3359
|
+
|
3360
|
+
function isNull(object) {
|
3361
|
+
return null === object;
|
3362
|
+
}
|
3363
|
+
|
3364
|
+
module.exports = new Type('tag:yaml.org,2002:null', {
|
3365
|
+
kind: 'scalar',
|
3366
|
+
resolve: resolveYamlNull,
|
3367
|
+
construct: constructYamlNull,
|
3368
|
+
predicate: isNull,
|
3369
|
+
represent: {
|
3370
|
+
canonical: function () { return '~'; },
|
3371
|
+
lowercase: function () { return 'null'; },
|
3372
|
+
uppercase: function () { return 'NULL'; },
|
3373
|
+
camelcase: function () { return 'Null'; }
|
3374
|
+
},
|
3375
|
+
defaultStyle: 'lowercase'
|
3376
|
+
});
|
3377
|
+
|
3378
|
+
},{"../type":13}],24:[function(require,module,exports){
|
3379
|
+
'use strict';
|
3380
|
+
|
3381
|
+
var Type = require('../type');
|
3382
|
+
|
3383
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
3384
|
+
var _toString = Object.prototype.toString;
|
3385
|
+
|
3386
|
+
function resolveYamlOmap(data) {
|
3387
|
+
if (null === data) {
|
3388
|
+
return true;
|
3389
|
+
}
|
3390
|
+
|
3391
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
|
3392
|
+
object = data;
|
3393
|
+
|
3394
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
3395
|
+
pair = object[index];
|
3396
|
+
pairHasKey = false;
|
3397
|
+
|
3398
|
+
if ('[object Object]' !== _toString.call(pair)) {
|
3399
|
+
return false;
|
3400
|
+
}
|
3401
|
+
|
3402
|
+
for (pairKey in pair) {
|
3403
|
+
if (_hasOwnProperty.call(pair, pairKey)) {
|
3404
|
+
if (!pairHasKey) {
|
3405
|
+
pairHasKey = true;
|
3406
|
+
} else {
|
3407
|
+
return false;
|
3408
|
+
}
|
3409
|
+
}
|
3410
|
+
}
|
3411
|
+
|
3412
|
+
if (!pairHasKey) {
|
3413
|
+
return false;
|
3414
|
+
}
|
3415
|
+
|
3416
|
+
if (-1 === objectKeys.indexOf(pairKey)) {
|
3417
|
+
objectKeys.push(pairKey);
|
3418
|
+
} else {
|
3419
|
+
return false;
|
3420
|
+
}
|
3421
|
+
}
|
3422
|
+
|
3423
|
+
return true;
|
3424
|
+
}
|
3425
|
+
|
3426
|
+
function constructYamlOmap(data) {
|
3427
|
+
return null !== data ? data : [];
|
3428
|
+
}
|
3429
|
+
|
3430
|
+
module.exports = new Type('tag:yaml.org,2002:omap', {
|
3431
|
+
kind: 'sequence',
|
3432
|
+
resolve: resolveYamlOmap,
|
3433
|
+
construct: constructYamlOmap
|
3434
|
+
});
|
3435
|
+
|
3436
|
+
},{"../type":13}],25:[function(require,module,exports){
|
3437
|
+
'use strict';
|
3438
|
+
|
3439
|
+
var Type = require('../type');
|
3440
|
+
|
3441
|
+
var _toString = Object.prototype.toString;
|
3442
|
+
|
3443
|
+
function resolveYamlPairs(data) {
|
3444
|
+
if (null === data) {
|
3445
|
+
return true;
|
3446
|
+
}
|
3447
|
+
|
3448
|
+
var index, length, pair, keys, result,
|
3449
|
+
object = data;
|
3450
|
+
|
3451
|
+
result = new Array(object.length);
|
3452
|
+
|
3453
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
3454
|
+
pair = object[index];
|
3455
|
+
|
3456
|
+
if ('[object Object]' !== _toString.call(pair)) {
|
3457
|
+
return false;
|
3458
|
+
}
|
3459
|
+
|
3460
|
+
keys = Object.keys(pair);
|
3461
|
+
|
3462
|
+
if (1 !== keys.length) {
|
3463
|
+
return false;
|
3464
|
+
}
|
3465
|
+
|
3466
|
+
result[index] = [ keys[0], pair[keys[0]] ];
|
3467
|
+
}
|
3468
|
+
|
3469
|
+
return true;
|
3470
|
+
}
|
3471
|
+
|
3472
|
+
function constructYamlPairs(data) {
|
3473
|
+
if (null === data) {
|
3474
|
+
return [];
|
3475
|
+
}
|
3476
|
+
|
3477
|
+
var index, length, pair, keys, result,
|
3478
|
+
object = data;
|
3479
|
+
|
3480
|
+
result = new Array(object.length);
|
3481
|
+
|
3482
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
3483
|
+
pair = object[index];
|
3484
|
+
|
3485
|
+
keys = Object.keys(pair);
|
3486
|
+
|
3487
|
+
result[index] = [ keys[0], pair[keys[0]] ];
|
3488
|
+
}
|
3489
|
+
|
3490
|
+
return result;
|
3491
|
+
}
|
3492
|
+
|
3493
|
+
module.exports = new Type('tag:yaml.org,2002:pairs', {
|
3494
|
+
kind: 'sequence',
|
3495
|
+
resolve: resolveYamlPairs,
|
3496
|
+
construct: constructYamlPairs
|
3497
|
+
});
|
3498
|
+
|
3499
|
+
},{"../type":13}],26:[function(require,module,exports){
|
3500
|
+
'use strict';
|
3501
|
+
|
3502
|
+
var Type = require('../type');
|
3503
|
+
|
3504
|
+
module.exports = new Type('tag:yaml.org,2002:seq', {
|
3505
|
+
kind: 'sequence',
|
3506
|
+
construct: function (data) { return null !== data ? data : []; }
|
3507
|
+
});
|
3508
|
+
|
3509
|
+
},{"../type":13}],27:[function(require,module,exports){
|
3510
|
+
'use strict';
|
3511
|
+
|
3512
|
+
var Type = require('../type');
|
3513
|
+
|
3514
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
3515
|
+
|
3516
|
+
function resolveYamlSet(data) {
|
3517
|
+
if (null === data) {
|
3518
|
+
return true;
|
3519
|
+
}
|
3520
|
+
|
3521
|
+
var key, object = data;
|
3522
|
+
|
3523
|
+
for (key in object) {
|
3524
|
+
if (_hasOwnProperty.call(object, key)) {
|
3525
|
+
if (null !== object[key]) {
|
3526
|
+
return false;
|
3527
|
+
}
|
3528
|
+
}
|
3529
|
+
}
|
3530
|
+
|
3531
|
+
return true;
|
3532
|
+
}
|
3533
|
+
|
3534
|
+
function constructYamlSet(data) {
|
3535
|
+
return null !== data ? data : {};
|
3536
|
+
}
|
3537
|
+
|
3538
|
+
module.exports = new Type('tag:yaml.org,2002:set', {
|
3539
|
+
kind: 'mapping',
|
3540
|
+
resolve: resolveYamlSet,
|
3541
|
+
construct: constructYamlSet
|
3542
|
+
});
|
3543
|
+
|
3544
|
+
},{"../type":13}],28:[function(require,module,exports){
|
3545
|
+
'use strict';
|
3546
|
+
|
3547
|
+
var Type = require('../type');
|
3548
|
+
|
3549
|
+
module.exports = new Type('tag:yaml.org,2002:str', {
|
3550
|
+
kind: 'scalar',
|
3551
|
+
construct: function (data) { return null !== data ? data : ''; }
|
3552
|
+
});
|
3553
|
+
|
3554
|
+
},{"../type":13}],29:[function(require,module,exports){
|
3555
|
+
'use strict';
|
3556
|
+
|
3557
|
+
var Type = require('../type');
|
3558
|
+
|
3559
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
3560
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
3561
|
+
'-([0-9][0-9]?)' + // [2] month
|
3562
|
+
'-([0-9][0-9]?)' + // [3] day
|
3563
|
+
'(?:(?:[Tt]|[ \\t]+)' + // ...
|
3564
|
+
'([0-9][0-9]?)' + // [4] hour
|
3565
|
+
':([0-9][0-9])' + // [5] minute
|
3566
|
+
':([0-9][0-9])' + // [6] second
|
3567
|
+
'(?:\\.([0-9]*))?' + // [7] fraction
|
3568
|
+
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
|
3569
|
+
'(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
|
3570
|
+
|
3571
|
+
function resolveYamlTimestamp(data) {
|
3572
|
+
if (null === data) {
|
3573
|
+
return false;
|
3574
|
+
}
|
3575
|
+
|
3576
|
+
var match, year, month, day, hour, minute, second, fraction = 0,
|
3577
|
+
delta = null, tz_hour, tz_minute, date;
|
3578
|
+
|
3579
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
3580
|
+
|
3581
|
+
if (null === match) {
|
3582
|
+
return false;
|
3583
|
+
}
|
3584
|
+
|
3585
|
+
return true;
|
3586
|
+
}
|
3587
|
+
|
3588
|
+
function constructYamlTimestamp(data) {
|
3589
|
+
var match, year, month, day, hour, minute, second, fraction = 0,
|
3590
|
+
delta = null, tz_hour, tz_minute, date;
|
3591
|
+
|
3592
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
3593
|
+
|
3594
|
+
if (null === match) {
|
3595
|
+
throw new Error('Date resolve error');
|
3596
|
+
}
|
3597
|
+
|
3598
|
+
// match: [1] year [2] month [3] day
|
3599
|
+
|
3600
|
+
year = +(match[1]);
|
3601
|
+
month = +(match[2]) - 1; // JS month starts with 0
|
3602
|
+
day = +(match[3]);
|
3603
|
+
|
3604
|
+
if (!match[4]) { // no hour
|
3605
|
+
return new Date(Date.UTC(year, month, day));
|
3606
|
+
}
|
3607
|
+
|
3608
|
+
// match: [4] hour [5] minute [6] second [7] fraction
|
3609
|
+
|
3610
|
+
hour = +(match[4]);
|
3611
|
+
minute = +(match[5]);
|
3612
|
+
second = +(match[6]);
|
3613
|
+
|
3614
|
+
if (match[7]) {
|
3615
|
+
fraction = match[7].slice(0, 3);
|
3616
|
+
while (fraction.length < 3) { // milli-seconds
|
3617
|
+
fraction += '0';
|
3618
|
+
}
|
3619
|
+
fraction = +fraction;
|
3620
|
+
}
|
3621
|
+
|
3622
|
+
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
3623
|
+
|
3624
|
+
if (match[9]) {
|
3625
|
+
tz_hour = +(match[10]);
|
3626
|
+
tz_minute = +(match[11] || 0);
|
3627
|
+
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
3628
|
+
if ('-' === match[9]) {
|
3629
|
+
delta = -delta;
|
3630
|
+
}
|
3631
|
+
}
|
3632
|
+
|
3633
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
3634
|
+
|
3635
|
+
if (delta) {
|
3636
|
+
date.setTime(date.getTime() - delta);
|
3637
|
+
}
|
3638
|
+
|
3639
|
+
return date;
|
3640
|
+
}
|
3641
|
+
|
3642
|
+
function representYamlTimestamp(object /*, style*/) {
|
3643
|
+
return object.toISOString();
|
3644
|
+
}
|
3645
|
+
|
3646
|
+
module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
3647
|
+
kind: 'scalar',
|
3648
|
+
resolve: resolveYamlTimestamp,
|
3649
|
+
construct: constructYamlTimestamp,
|
3650
|
+
instanceOf: Date,
|
3651
|
+
represent: representYamlTimestamp
|
3652
|
+
});
|
3653
|
+
|
3654
|
+
},{"../type":13}],30:[function(require,module,exports){
|
3655
|
+
|
3656
|
+
},{}],"/":[function(require,module,exports){
|
3657
|
+
'use strict';
|
3658
|
+
|
3659
|
+
|
3660
|
+
var yaml = require('./lib/js-yaml.js');
|
3661
|
+
|
3662
|
+
|
3663
|
+
module.exports = yaml;
|
3664
|
+
|
3665
|
+
},{"./lib/js-yaml.js":1}]},{},[])("/")
|
3666
|
+
});
|