opal 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Type = require('../../type');
|
|
4
|
+
|
|
5
|
+
function resolveJavascriptUndefined() {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function constructJavascriptUndefined() {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function representJavascriptUndefined() {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isUndefined(object) {
|
|
18
|
+
return 'undefined' === typeof object;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = new Type('tag:yaml.org,2002:js/undefined', {
|
|
22
|
+
kind: 'scalar',
|
|
23
|
+
resolve: resolveJavascriptUndefined,
|
|
24
|
+
construct: constructJavascriptUndefined,
|
|
25
|
+
predicate: isUndefined,
|
|
26
|
+
represent: representJavascriptUndefined
|
|
27
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Type = require('../type');
|
|
4
|
+
|
|
5
|
+
function resolveYamlNull(data) {
|
|
6
|
+
if (null === data) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var max = data.length;
|
|
11
|
+
|
|
12
|
+
return (max === 1 && data === '~') ||
|
|
13
|
+
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function constructYamlNull() {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isNull(object) {
|
|
21
|
+
return null === object;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = new Type('tag:yaml.org,2002:null', {
|
|
25
|
+
kind: 'scalar',
|
|
26
|
+
resolve: resolveYamlNull,
|
|
27
|
+
construct: constructYamlNull,
|
|
28
|
+
predicate: isNull,
|
|
29
|
+
represent: {
|
|
30
|
+
canonical: function () { return '~'; },
|
|
31
|
+
lowercase: function () { return 'null'; },
|
|
32
|
+
uppercase: function () { return 'NULL'; },
|
|
33
|
+
camelcase: function () { return 'Null'; }
|
|
34
|
+
},
|
|
35
|
+
defaultStyle: 'lowercase'
|
|
36
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Type = require('../type');
|
|
4
|
+
|
|
5
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
6
|
+
var _toString = Object.prototype.toString;
|
|
7
|
+
|
|
8
|
+
function resolveYamlOmap(data) {
|
|
9
|
+
if (null === data) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
|
|
14
|
+
object = data;
|
|
15
|
+
|
|
16
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
17
|
+
pair = object[index];
|
|
18
|
+
pairHasKey = false;
|
|
19
|
+
|
|
20
|
+
if ('[object Object]' !== _toString.call(pair)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (pairKey in pair) {
|
|
25
|
+
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
26
|
+
if (!pairHasKey) {
|
|
27
|
+
pairHasKey = true;
|
|
28
|
+
} else {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!pairHasKey) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (-1 === objectKeys.indexOf(pairKey)) {
|
|
39
|
+
objectKeys.push(pairKey);
|
|
40
|
+
} else {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function constructYamlOmap(data) {
|
|
49
|
+
return null !== data ? data : [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = new Type('tag:yaml.org,2002:omap', {
|
|
53
|
+
kind: 'sequence',
|
|
54
|
+
resolve: resolveYamlOmap,
|
|
55
|
+
construct: constructYamlOmap
|
|
56
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Type = require('../type');
|
|
4
|
+
|
|
5
|
+
var _toString = Object.prototype.toString;
|
|
6
|
+
|
|
7
|
+
function resolveYamlPairs(data) {
|
|
8
|
+
if (null === data) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var index, length, pair, keys, result,
|
|
13
|
+
object = data;
|
|
14
|
+
|
|
15
|
+
result = new Array(object.length);
|
|
16
|
+
|
|
17
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
18
|
+
pair = object[index];
|
|
19
|
+
|
|
20
|
+
if ('[object Object]' !== _toString.call(pair)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
keys = Object.keys(pair);
|
|
25
|
+
|
|
26
|
+
if (1 !== keys.length) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
result[index] = [ keys[0], pair[keys[0]] ];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function constructYamlPairs(data) {
|
|
37
|
+
if (null === data) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var index, length, pair, keys, result,
|
|
42
|
+
object = data;
|
|
43
|
+
|
|
44
|
+
result = new Array(object.length);
|
|
45
|
+
|
|
46
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
47
|
+
pair = object[index];
|
|
48
|
+
|
|
49
|
+
keys = Object.keys(pair);
|
|
50
|
+
|
|
51
|
+
result[index] = [ keys[0], pair[keys[0]] ];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = new Type('tag:yaml.org,2002:pairs', {
|
|
58
|
+
kind: 'sequence',
|
|
59
|
+
resolve: resolveYamlPairs,
|
|
60
|
+
construct: constructYamlPairs
|
|
61
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Type = require('../type');
|
|
4
|
+
|
|
5
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
6
|
+
|
|
7
|
+
function resolveYamlSet(data) {
|
|
8
|
+
if (null === data) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var key, object = data;
|
|
13
|
+
|
|
14
|
+
for (key in object) {
|
|
15
|
+
if (_hasOwnProperty.call(object, key)) {
|
|
16
|
+
if (null !== object[key]) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function constructYamlSet(data) {
|
|
26
|
+
return null !== data ? data : {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = new Type('tag:yaml.org,2002:set', {
|
|
30
|
+
kind: 'mapping',
|
|
31
|
+
resolve: resolveYamlSet,
|
|
32
|
+
construct: constructYamlSet
|
|
33
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Type = require('../type');
|
|
4
|
+
|
|
5
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
6
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
7
|
+
'-([0-9][0-9]?)' + // [2] month
|
|
8
|
+
'-([0-9][0-9]?)' + // [3] day
|
|
9
|
+
'(?:(?:[Tt]|[ \\t]+)' + // ...
|
|
10
|
+
'([0-9][0-9]?)' + // [4] hour
|
|
11
|
+
':([0-9][0-9])' + // [5] minute
|
|
12
|
+
':([0-9][0-9])' + // [6] second
|
|
13
|
+
'(?:\\.([0-9]*))?' + // [7] fraction
|
|
14
|
+
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
|
|
15
|
+
'(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
|
|
16
|
+
|
|
17
|
+
function resolveYamlTimestamp(data) {
|
|
18
|
+
if (null === data) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var match, year, month, day, hour, minute, second, fraction = 0,
|
|
23
|
+
delta = null, tz_hour, tz_minute, date;
|
|
24
|
+
|
|
25
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
26
|
+
|
|
27
|
+
if (null === match) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function constructYamlTimestamp(data) {
|
|
35
|
+
var match, year, month, day, hour, minute, second, fraction = 0,
|
|
36
|
+
delta = null, tz_hour, tz_minute, date;
|
|
37
|
+
|
|
38
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
39
|
+
|
|
40
|
+
if (null === match) {
|
|
41
|
+
throw new Error('Date resolve error');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// match: [1] year [2] month [3] day
|
|
45
|
+
|
|
46
|
+
year = +(match[1]);
|
|
47
|
+
month = +(match[2]) - 1; // JS month starts with 0
|
|
48
|
+
day = +(match[3]);
|
|
49
|
+
|
|
50
|
+
if (!match[4]) { // no hour
|
|
51
|
+
return new Date(Date.UTC(year, month, day));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// match: [4] hour [5] minute [6] second [7] fraction
|
|
55
|
+
|
|
56
|
+
hour = +(match[4]);
|
|
57
|
+
minute = +(match[5]);
|
|
58
|
+
second = +(match[6]);
|
|
59
|
+
|
|
60
|
+
if (match[7]) {
|
|
61
|
+
fraction = match[7].slice(0, 3);
|
|
62
|
+
while (fraction.length < 3) { // milli-seconds
|
|
63
|
+
fraction += '0';
|
|
64
|
+
}
|
|
65
|
+
fraction = +fraction;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
|
69
|
+
|
|
70
|
+
if (match[9]) {
|
|
71
|
+
tz_hour = +(match[10]);
|
|
72
|
+
tz_minute = +(match[11] || 0);
|
|
73
|
+
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
|
74
|
+
if ('-' === match[9]) {
|
|
75
|
+
delta = -delta;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
80
|
+
|
|
81
|
+
if (delta) {
|
|
82
|
+
date.setTime(date.getTime() - delta);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return date;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function representYamlTimestamp(object /*, style*/) {
|
|
89
|
+
return object.toISOString();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
|
93
|
+
kind: 'scalar',
|
|
94
|
+
resolve: resolveYamlTimestamp,
|
|
95
|
+
construct: constructYamlTimestamp,
|
|
96
|
+
instanceOf: Date,
|
|
97
|
+
represent: representYamlTimestamp
|
|
98
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
|
4
|
+
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
documentation and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
18
|
+
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
24
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/*jslint sloppy:true node:true rhino:true */
|
|
28
|
+
|
|
29
|
+
var fs, esprima, fname, content, options, syntax;
|
|
30
|
+
|
|
31
|
+
if (typeof require === 'function') {
|
|
32
|
+
fs = require('fs');
|
|
33
|
+
esprima = require('esprima');
|
|
34
|
+
} else if (typeof load === 'function') {
|
|
35
|
+
try {
|
|
36
|
+
load('esprima.js');
|
|
37
|
+
} catch (e) {
|
|
38
|
+
load('../esprima.js');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Shims to Node.js objects when running under Rhino.
|
|
43
|
+
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
|
44
|
+
console = { log: print };
|
|
45
|
+
fs = { readFileSync: readFile };
|
|
46
|
+
process = { argv: arguments, exit: quit };
|
|
47
|
+
process.argv.unshift('esparse.js');
|
|
48
|
+
process.argv.unshift('rhino');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function showUsage() {
|
|
52
|
+
console.log('Usage:');
|
|
53
|
+
console.log(' esparse [options] file.js');
|
|
54
|
+
console.log();
|
|
55
|
+
console.log('Available options:');
|
|
56
|
+
console.log();
|
|
57
|
+
console.log(' --comment Gather all line and block comments in an array');
|
|
58
|
+
console.log(' --loc Include line-column location info for each syntax node');
|
|
59
|
+
console.log(' --range Include index-based range for each syntax node');
|
|
60
|
+
console.log(' --raw Display the raw value of literals');
|
|
61
|
+
console.log(' --tokens List all tokens in an array');
|
|
62
|
+
console.log(' --tolerant Tolerate errors on a best-effort basis (experimental)');
|
|
63
|
+
console.log(' -v, --version Shows program version');
|
|
64
|
+
console.log();
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (process.argv.length <= 2) {
|
|
69
|
+
showUsage();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
options = {};
|
|
73
|
+
|
|
74
|
+
process.argv.splice(2).forEach(function (entry) {
|
|
75
|
+
|
|
76
|
+
if (entry === '-h' || entry === '--help') {
|
|
77
|
+
showUsage();
|
|
78
|
+
} else if (entry === '-v' || entry === '--version') {
|
|
79
|
+
console.log('ECMAScript Parser (using Esprima version', esprima.version, ')');
|
|
80
|
+
console.log();
|
|
81
|
+
process.exit(0);
|
|
82
|
+
} else if (entry === '--comment') {
|
|
83
|
+
options.comment = true;
|
|
84
|
+
} else if (entry === '--loc') {
|
|
85
|
+
options.loc = true;
|
|
86
|
+
} else if (entry === '--range') {
|
|
87
|
+
options.range = true;
|
|
88
|
+
} else if (entry === '--raw') {
|
|
89
|
+
options.raw = true;
|
|
90
|
+
} else if (entry === '--tokens') {
|
|
91
|
+
options.tokens = true;
|
|
92
|
+
} else if (entry === '--tolerant') {
|
|
93
|
+
options.tolerant = true;
|
|
94
|
+
} else if (entry.slice(0, 2) === '--') {
|
|
95
|
+
console.log('Error: unknown option ' + entry + '.');
|
|
96
|
+
process.exit(1);
|
|
97
|
+
} else if (typeof fname === 'string') {
|
|
98
|
+
console.log('Error: more than one input file.');
|
|
99
|
+
process.exit(1);
|
|
100
|
+
} else {
|
|
101
|
+
fname = entry;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (typeof fname !== 'string') {
|
|
106
|
+
console.log('Error: no input file.');
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
content = fs.readFileSync(fname, 'utf-8');
|
|
112
|
+
syntax = esprima.parse(content, options);
|
|
113
|
+
console.log(JSON.stringify(syntax, null, 4));
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.log('Error: ' + e.message);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|