opal 0.10.0 → 0.11.0

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.
Files changed (734) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +19 -0
  3. data/.gitmodules +1 -1
  4. data/.jshintrc +1 -2
  5. data/.rspec +1 -2
  6. data/.travis.yml +42 -20
  7. data/.yardopts +3 -1
  8. data/CHANGELOG.md +164 -1
  9. data/Gemfile +16 -9
  10. data/HACKING.md +4 -2
  11. data/README.md +11 -11
  12. data/Rakefile +1 -1
  13. data/appveyor.yml +29 -0
  14. data/benchmark/bm_constant_lookup_big.rb +799 -0
  15. data/benchmark/bm_constant_lookup_small.rb +59 -0
  16. data/benchmark/bm_module_definition_big.rb +400 -0
  17. data/benchmark/bm_module_definition_small.rb +30 -0
  18. data/benchmark-ips/bm_case.rb +33 -0
  19. data/benchmark-ips/bm_constants_lookup.rb +13 -0
  20. data/benchmark-ips/bm_is_number.rb +29 -0
  21. data/benchmark-ips/bm_symbol_to_proc.rb +19 -0
  22. data/bin +1 -0
  23. data/docs/compiled_ruby.md +16 -14
  24. data/docs/faq.md +3 -3
  25. data/docs/headless_chrome.md +105 -0
  26. data/docs/rspec.md +4 -20
  27. data/docs/unsupported_features.md +6 -4
  28. data/examples/rack/Gemfile +1 -0
  29. data/examples/rack/Gemfile.lock +11 -7
  30. data/examples/rack/app/application.rb +14 -3
  31. data/examples/rack/app/user.rb +2 -0
  32. data/examples/rack/config.ru +1 -1
  33. data/examples/rack/index.html.erb +1 -0
  34. data/examples/sinatra/Gemfile +1 -1
  35. data/examples/sinatra/Gemfile.lock +8 -11
  36. data/examples/sinatra/app/application.rb +2 -0
  37. data/{bin → exe}/opal +4 -2
  38. data/{bin → exe}/opal-repl +23 -1
  39. data/lib/opal/ast/builder.rb +13 -0
  40. data/lib/opal/ast/node.rb +30 -0
  41. data/lib/opal/builder.rb +82 -17
  42. data/lib/opal/builder_processors.rb +9 -7
  43. data/lib/opal/cli.rb +45 -59
  44. data/lib/opal/cli_options.rb +19 -12
  45. data/lib/opal/cli_runners/applescript.rb +3 -4
  46. data/lib/opal/cli_runners/chrome.js +135 -0
  47. data/lib/opal/cli_runners/chrome.rb +100 -0
  48. data/lib/opal/cli_runners/nashorn.rb +1 -1
  49. data/lib/opal/cli_runners/node_modules/.bin/chrome-remote-interface +1 -0
  50. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/LICENSE +18 -0
  51. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/README.md +843 -0
  52. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/bin/client.js +326 -0
  53. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/chrome-remote-interface.js +11 -0
  54. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/index.js +39 -0
  55. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/api.js +84 -0
  56. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/chrome.js +289 -0
  57. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/defaults.js +4 -0
  58. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/devtools.js +245 -0
  59. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/external-request.js +23 -0
  60. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/protocol.json +13303 -0
  61. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/websocket-wrapper.js +32 -0
  62. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/package.json +128 -0
  63. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/webpack.config.js +55 -0
  64. data/lib/opal/cli_runners/node_modules/commander/Readme.md +195 -0
  65. data/lib/opal/cli_runners/node_modules/commander/index.js +851 -0
  66. data/lib/opal/cli_runners/node_modules/commander/package.json +92 -0
  67. data/{stdlib/nodejs/node_modules/js-yaml/node_modules/argparse → lib/opal/cli_runners/node_modules/ultron}/LICENSE +7 -6
  68. data/lib/opal/cli_runners/node_modules/ultron/index.js +138 -0
  69. data/lib/opal/cli_runners/node_modules/ultron/package.json +112 -0
  70. data/{stdlib/nodejs/node_modules/js-yaml → lib/opal/cli_runners/node_modules/ws}/LICENSE +6 -6
  71. data/lib/opal/cli_runners/node_modules/ws/README.md +259 -0
  72. data/lib/opal/cli_runners/node_modules/ws/SECURITY.md +33 -0
  73. data/lib/opal/cli_runners/node_modules/ws/index.js +15 -0
  74. data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.fallback.js +56 -0
  75. data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.js +15 -0
  76. data/lib/opal/cli_runners/node_modules/ws/lib/ErrorCodes.js +28 -0
  77. data/lib/opal/cli_runners/node_modules/ws/lib/EventTarget.js +158 -0
  78. data/lib/opal/cli_runners/node_modules/ws/lib/Extensions.js +69 -0
  79. data/lib/opal/cli_runners/node_modules/ws/lib/PerMessageDeflate.js +339 -0
  80. data/lib/opal/cli_runners/node_modules/ws/lib/Receiver.js +520 -0
  81. data/lib/opal/cli_runners/node_modules/ws/lib/Sender.js +438 -0
  82. data/lib/opal/cli_runners/node_modules/ws/lib/Validation.fallback.js +9 -0
  83. data/lib/opal/cli_runners/node_modules/ws/lib/Validation.js +17 -0
  84. data/lib/opal/cli_runners/node_modules/ws/lib/WebSocket.js +705 -0
  85. data/lib/opal/cli_runners/node_modules/ws/lib/WebSocketServer.js +336 -0
  86. data/lib/opal/cli_runners/node_modules/ws/package.json +122 -0
  87. data/lib/opal/cli_runners/nodejs.rb +4 -2
  88. data/lib/opal/cli_runners/package.json +5 -0
  89. data/lib/opal/cli_runners/server.rb +1 -1
  90. data/lib/opal/cli_runners.rb +2 -1
  91. data/lib/opal/compiler.rb +136 -95
  92. data/lib/opal/config.rb +114 -36
  93. data/lib/opal/deprecations.rb +18 -0
  94. data/lib/opal/eof_content.rb +36 -0
  95. data/lib/opal/erb.rb +1 -0
  96. data/lib/opal/errors.rb +1 -0
  97. data/lib/opal/fragment.rb +1 -0
  98. data/lib/opal/nodes/arglist.rb +2 -1
  99. data/lib/opal/nodes/args/initialize_kwargs.rb +1 -0
  100. data/lib/opal/nodes/args/kwarg.rb +9 -7
  101. data/lib/opal/nodes/args/kwoptarg.rb +13 -8
  102. data/lib/opal/nodes/args/kwrestarg.rb +5 -5
  103. data/lib/opal/nodes/args/mlhsarg.rb +3 -2
  104. data/lib/opal/nodes/args/normarg.rb +6 -7
  105. data/lib/opal/nodes/args/optarg.rb +5 -7
  106. data/lib/opal/nodes/args/post_args.rb +6 -5
  107. data/lib/opal/nodes/args/post_kwargs.rb +1 -0
  108. data/lib/opal/nodes/args/restarg.rb +7 -7
  109. data/lib/opal/nodes/array.rb +1 -0
  110. data/lib/opal/nodes/base.rb +24 -3
  111. data/lib/opal/nodes/call.rb +168 -155
  112. data/lib/opal/nodes/call_special.rb +37 -214
  113. data/lib/opal/nodes/case.rb +36 -22
  114. data/lib/opal/nodes/class.rb +4 -3
  115. data/lib/opal/nodes/constants.rb +28 -48
  116. data/lib/opal/nodes/csend.rb +25 -0
  117. data/lib/opal/nodes/def.rb +57 -17
  118. data/lib/opal/nodes/defined.rb +170 -60
  119. data/lib/opal/nodes/definitions.rb +42 -133
  120. data/lib/opal/nodes/defs.rb +29 -0
  121. data/lib/opal/nodes/hash.rb +12 -35
  122. data/lib/opal/nodes/helpers.rb +31 -62
  123. data/lib/opal/nodes/if.rb +21 -32
  124. data/lib/opal/nodes/inline_args.rb +12 -13
  125. data/lib/opal/nodes/iter.rb +61 -36
  126. data/lib/opal/nodes/literal.rb +206 -114
  127. data/lib/opal/nodes/logic.rb +39 -57
  128. data/lib/opal/nodes/masgn.rb +20 -18
  129. data/lib/opal/nodes/module.rb +10 -11
  130. data/lib/opal/nodes/node_with_args.rb +15 -18
  131. data/lib/opal/nodes/rescue.rb +37 -70
  132. data/lib/opal/nodes/runtime_helpers.rb +8 -3
  133. data/lib/opal/nodes/scope.rb +10 -5
  134. data/lib/opal/nodes/singleton_class.rb +4 -3
  135. data/lib/opal/nodes/super.rb +112 -88
  136. data/lib/opal/nodes/top.rb +7 -2
  137. data/lib/opal/nodes/variables.rb +57 -35
  138. data/lib/opal/nodes/while.rb +11 -1
  139. data/lib/opal/nodes/yield.rb +1 -17
  140. data/lib/opal/nodes.rb +3 -1
  141. data/lib/opal/parser.rb +29 -766
  142. data/lib/opal/path_reader.rb +22 -5
  143. data/lib/opal/paths.rb +10 -4
  144. data/lib/opal/regexp_anchors.rb +1 -0
  145. data/lib/opal/rewriter.rb +64 -0
  146. data/lib/opal/rewriters/base.rb +63 -0
  147. data/lib/opal/rewriters/binary_operator_assignment.rb +141 -0
  148. data/lib/opal/rewriters/block_to_iter.rb +17 -0
  149. data/lib/opal/rewriters/break_finder.rb +34 -0
  150. data/lib/opal/rewriters/dot_js_syntax.rb +60 -0
  151. data/lib/opal/rewriters/explicit_writer_return.rb +58 -0
  152. data/lib/opal/rewriters/for_rewriter.rb +93 -0
  153. data/lib/opal/rewriters/hashes/key_duplicates_rewriter.rb +58 -0
  154. data/lib/opal/rewriters/js_reserved_words.rb +108 -0
  155. data/lib/opal/rewriters/logical_operator_assignment.rb +154 -0
  156. data/lib/opal/rewriters/opal_engine_check.rb +42 -0
  157. data/lib/opal/rewriters/rubyspec/filters_rewriter.rb +67 -0
  158. data/lib/opal/server.rb +4 -0
  159. data/lib/opal/simple_server.rb +101 -0
  160. data/lib/opal/source_map.rb +1 -1
  161. data/lib/opal/util.rb +6 -6
  162. data/lib/opal/version.rb +2 -1
  163. data/lib/opal.rb +7 -1
  164. data/lib/tilt/opal.rb +1 -0
  165. data/opal/README.md +1 -1
  166. data/opal/corelib/array.rb +184 -107
  167. data/opal/corelib/basic_object.rb +6 -6
  168. data/opal/corelib/boolean.rb +11 -3
  169. data/opal/corelib/class.rb +14 -11
  170. data/opal/corelib/comparable.rb +16 -0
  171. data/opal/corelib/complex.rb +5 -1
  172. data/opal/corelib/constants.rb +3 -3
  173. data/opal/corelib/enumerable.rb +176 -11
  174. data/opal/corelib/error.rb +35 -17
  175. data/opal/corelib/file.rb +114 -176
  176. data/opal/corelib/hash.rb +226 -13
  177. data/opal/corelib/helpers.rb +12 -15
  178. data/opal/corelib/io.rb +3 -2
  179. data/opal/corelib/kernel.rb +68 -32
  180. data/opal/corelib/marshal/read_buffer.rb +288 -150
  181. data/opal/corelib/marshal/write_buffer.rb +27 -2
  182. data/opal/corelib/method.rb +33 -13
  183. data/opal/corelib/module.rb +134 -82
  184. data/opal/corelib/nil.rb +11 -3
  185. data/opal/corelib/number.rb +220 -34
  186. data/opal/corelib/numeric.rb +3 -11
  187. data/opal/corelib/process.rb +44 -4
  188. data/opal/corelib/random/seedrandom.js.rb +15 -0
  189. data/opal/corelib/random.rb +117 -0
  190. data/opal/corelib/range.rb +147 -24
  191. data/opal/corelib/regexp.rb +82 -13
  192. data/opal/corelib/runtime.js +623 -397
  193. data/opal/corelib/string/encoding.rb +67 -31
  194. data/opal/corelib/string/inheritance.rb +1 -1
  195. data/opal/corelib/string.rb +40 -9
  196. data/opal/corelib/struct.rb +18 -3
  197. data/opal/corelib/time.rb +3 -3
  198. data/opal/corelib/variables.rb +1 -1
  199. data/opal/opal.rb +1 -0
  200. data/opal.gemspec +32 -29
  201. data/stdlib/base64.rb +4 -2
  202. data/stdlib/bigdecimal/bignumber.js.rb +1 -1
  203. data/stdlib/buffer/array.rb +4 -2
  204. data/stdlib/date.rb +64 -31
  205. data/stdlib/headless_chrome.rb +11 -0
  206. data/stdlib/json.rb +16 -4
  207. data/stdlib/nashorn/file.rb +15 -0
  208. data/stdlib/native.rb +21 -12
  209. data/stdlib/nodejs/dir.rb +1 -1
  210. data/stdlib/nodejs/file.rb +77 -23
  211. data/stdlib/nodejs/io.rb +30 -1
  212. data/stdlib/nodejs/{node_modules/js-yaml/dist/js-yaml.js → js-yaml-3-6-1.js} +815 -626
  213. data/stdlib/nodejs/kernel.rb +3 -1
  214. data/stdlib/nodejs/package.json +0 -1
  215. data/stdlib/nodejs/stacktrace.rb +179 -0
  216. data/stdlib/nodejs/yaml.rb +2 -1
  217. data/stdlib/opal/platform.rb +6 -14
  218. data/stdlib/opal-builder.rb +1 -0
  219. data/stdlib/opal-platform.rb +15 -0
  220. data/stdlib/pathname.rb +1 -1
  221. data/stdlib/rbconfig.rb +1 -1
  222. data/stdlib/securerandom.rb +1 -1
  223. data/stdlib/strscan.rb +15 -1
  224. data/stdlib/yaml.rb +1 -1
  225. data/tasks/benchmarking.rake +9 -0
  226. data/tasks/building.rake +24 -20
  227. data/tasks/linting.rake +24 -13
  228. data/tasks/testing/mspec_special_calls.rb +44 -15
  229. data/tasks/testing/opal_rspec_smoketest.Gemfile +6 -0
  230. data/tasks/testing.rake +351 -202
  231. metadata +135 -915
  232. data/lib/opal/cli_runners/phantom.js +0 -70
  233. data/lib/opal/cli_runners/phantomjs.rb +0 -28
  234. data/lib/opal/hike_path_finder.rb +0 -18
  235. data/lib/opal/nodes/for.rb +0 -48
  236. data/lib/opal/parser/grammar.rb +0 -6157
  237. data/lib/opal/parser/grammar.y +0 -2011
  238. data/lib/opal/parser/keywords.rb +0 -66
  239. data/lib/opal/parser/lexer.rb +0 -1352
  240. data/lib/opal/parser/parser_scope.rb +0 -28
  241. data/lib/opal/parser/sexp.rb +0 -90
  242. data/lib/opal/sprockets/environment.rb +0 -23
  243. data/lib/opal/sprockets/erb.rb +0 -23
  244. data/lib/opal/sprockets/path_reader.rb +0 -36
  245. data/lib/opal/sprockets/processor.rb +0 -145
  246. data/lib/opal/sprockets/server.rb +0 -133
  247. data/lib/opal/sprockets/source_map_header_patch.rb +0 -41
  248. data/lib/opal/sprockets/source_map_server.rb +0 -115
  249. data/lib/opal/sprockets.rb +0 -91
  250. data/spec/README.md +0 -10
  251. data/spec/filters/bugs/array.rb +0 -12
  252. data/spec/filters/bugs/basicobject.rb +0 -16
  253. data/spec/filters/bugs/bigdecimal.rb +0 -160
  254. data/spec/filters/bugs/class.rb +0 -10
  255. data/spec/filters/bugs/compiler_opal.rb +0 -5
  256. data/spec/filters/bugs/complex.rb +0 -3
  257. data/spec/filters/bugs/date.rb +0 -94
  258. data/spec/filters/bugs/enumerable.rb +0 -50
  259. data/spec/filters/bugs/enumerator.rb +0 -42
  260. data/spec/filters/bugs/exception.rb +0 -58
  261. data/spec/filters/bugs/float.rb +0 -33
  262. data/spec/filters/bugs/hash.rb +0 -11
  263. data/spec/filters/bugs/inheritance.rb +0 -5
  264. data/spec/filters/bugs/integer.rb +0 -28
  265. data/spec/filters/bugs/kernel.rb +0 -297
  266. data/spec/filters/bugs/language.rb +0 -275
  267. data/spec/filters/bugs/language_opal.rb +0 -88
  268. data/spec/filters/bugs/marshal.rb +0 -43
  269. data/spec/filters/bugs/method.rb +0 -84
  270. data/spec/filters/bugs/module.rb +0 -196
  271. data/spec/filters/bugs/numeric.rb +0 -127
  272. data/spec/filters/bugs/pathname.rb +0 -5
  273. data/spec/filters/bugs/proc.rb +0 -36
  274. data/spec/filters/bugs/range.rb +0 -144
  275. data/spec/filters/bugs/rational.rb +0 -4
  276. data/spec/filters/bugs/regexp.rb +0 -196
  277. data/spec/filters/bugs/set.rb +0 -42
  278. data/spec/filters/bugs/singleton.rb +0 -6
  279. data/spec/filters/bugs/string.rb +0 -101
  280. data/spec/filters/bugs/stringscanner.rb +0 -79
  281. data/spec/filters/bugs/struct.rb +0 -4
  282. data/spec/filters/bugs/time.rb +0 -29
  283. data/spec/filters/bugs/unboundmethod.rb +0 -27
  284. data/spec/filters/unsupported/array.rb +0 -163
  285. data/spec/filters/unsupported/basicobject.rb +0 -14
  286. data/spec/filters/unsupported/bignum.rb +0 -52
  287. data/spec/filters/unsupported/class.rb +0 -4
  288. data/spec/filters/unsupported/delegator.rb +0 -5
  289. data/spec/filters/unsupported/enumerable.rb +0 -11
  290. data/spec/filters/unsupported/enumerator.rb +0 -13
  291. data/spec/filters/unsupported/fixnum.rb +0 -14
  292. data/spec/filters/unsupported/float.rb +0 -43
  293. data/spec/filters/unsupported/freeze.rb +0 -53
  294. data/spec/filters/unsupported/hash.rb +0 -51
  295. data/spec/filters/unsupported/integer.rb +0 -3
  296. data/spec/filters/unsupported/kernel.rb +0 -31
  297. data/spec/filters/unsupported/language.rb +0 -17
  298. data/spec/filters/unsupported/marshal.rb +0 -46
  299. data/spec/filters/unsupported/matchdata.rb +0 -30
  300. data/spec/filters/unsupported/math.rb +0 -3
  301. data/spec/filters/unsupported/module.rb +0 -8
  302. data/spec/filters/unsupported/pathname.rb +0 -3
  303. data/spec/filters/unsupported/privacy.rb +0 -147
  304. data/spec/filters/unsupported/proc.rb +0 -3
  305. data/spec/filters/unsupported/regexp.rb +0 -59
  306. data/spec/filters/unsupported/set.rb +0 -4
  307. data/spec/filters/unsupported/singleton.rb +0 -6
  308. data/spec/filters/unsupported/string.rb +0 -537
  309. data/spec/filters/unsupported/struct.rb +0 -6
  310. data/spec/filters/unsupported/symbol.rb +0 -19
  311. data/spec/filters/unsupported/taint.rb +0 -15
  312. data/spec/filters/unsupported/thread.rb +0 -7
  313. data/spec/filters/unsupported/time.rb +0 -202
  314. data/spec/lib/builder_processors_spec.rb +0 -27
  315. data/spec/lib/builder_spec.rb +0 -72
  316. data/spec/lib/cli_runners/phantomjs_spec.rb +0 -39
  317. data/spec/lib/cli_spec.rb +0 -211
  318. data/spec/lib/compiler/call_spec.rb +0 -700
  319. data/spec/lib/compiler/pre_processed_conditionals_spec.rb +0 -87
  320. data/spec/lib/compiler_spec.rb +0 -285
  321. data/spec/lib/config_spec.rb +0 -13
  322. data/spec/lib/dependency_resolver_spec.rb +0 -40
  323. data/spec/lib/fixtures/complex_sprockets.js.rb.erb +0 -4
  324. data/spec/lib/fixtures/file_with_directives.js +0 -2
  325. data/spec/lib/fixtures/jst_file.js.jst +0 -1
  326. data/spec/lib/fixtures/no_requires.rb +0 -1
  327. data/spec/lib/fixtures/opal_file.rb +0 -2
  328. data/spec/lib/fixtures/require_tree_test.rb +0 -3
  329. data/spec/lib/fixtures/required_file.js +0 -1
  330. data/spec/lib/fixtures/required_tree_test/required_file1.rb +0 -1
  331. data/spec/lib/fixtures/required_tree_test/required_file2.rb +0 -1
  332. data/spec/lib/fixtures/requires.rb +0 -7
  333. data/spec/lib/fixtures/source_map/subfolder/other_file.rb +0 -1
  334. data/spec/lib/fixtures/source_map.rb +0 -1
  335. data/spec/lib/fixtures/sprockets_file.js.rb +0 -3
  336. data/spec/lib/fixtures/sprockets_require_tree_test.rb +0 -3
  337. data/spec/lib/hike_path_finder_spec.rb +0 -23
  338. data/spec/lib/lexer_spec.rb +0 -110
  339. data/spec/lib/parser/alias_spec.rb +0 -26
  340. data/spec/lib/parser/and_spec.rb +0 -13
  341. data/spec/lib/parser/aref_spec.rb +0 -10
  342. data/spec/lib/parser/attrasgn_spec.rb +0 -28
  343. data/spec/lib/parser/begin_spec.rb +0 -42
  344. data/spec/lib/parser/block_spec.rb +0 -12
  345. data/spec/lib/parser/break_spec.rb +0 -17
  346. data/spec/lib/parser/call_spec.rb +0 -201
  347. data/spec/lib/parser/class_spec.rb +0 -35
  348. data/spec/lib/parser/comments_spec.rb +0 -11
  349. data/spec/lib/parser/def_spec.rb +0 -109
  350. data/spec/lib/parser/if_spec.rb +0 -26
  351. data/spec/lib/parser/iter_spec.rb +0 -59
  352. data/spec/lib/parser/lambda_spec.rb +0 -219
  353. data/spec/lib/parser/literal_spec.rb +0 -118
  354. data/spec/lib/parser/masgn_spec.rb +0 -37
  355. data/spec/lib/parser/module_spec.rb +0 -27
  356. data/spec/lib/parser/not_spec.rb +0 -21
  357. data/spec/lib/parser/op_asgn1_spec.rb +0 -23
  358. data/spec/lib/parser/op_asgn2_spec.rb +0 -23
  359. data/spec/lib/parser/op_asgn_spec.rb +0 -17
  360. data/spec/lib/parser/or_spec.rb +0 -13
  361. data/spec/lib/parser/return_spec.rb +0 -22
  362. data/spec/lib/parser/sclass_spec.rb +0 -21
  363. data/spec/lib/parser/string_spec.rb +0 -286
  364. data/spec/lib/parser/super_spec.rb +0 -20
  365. data/spec/lib/parser/unary_spec.rb +0 -52
  366. data/spec/lib/parser/undef_spec.rb +0 -19
  367. data/spec/lib/parser/unless_spec.rb +0 -13
  368. data/spec/lib/parser/variables_spec.rb +0 -116
  369. data/spec/lib/parser/while_spec.rb +0 -15
  370. data/spec/lib/parser/yield_spec.rb +0 -20
  371. data/spec/lib/path_reader_spec.rb +0 -36
  372. data/spec/lib/paths_spec.rb +0 -18
  373. data/spec/lib/shared/path_finder_shared.rb +0 -19
  374. data/spec/lib/shared/path_reader_shared.rb +0 -31
  375. data/spec/lib/spec_helper.rb +0 -16
  376. data/spec/lib/sprockets/erb_spec.rb +0 -38
  377. data/spec/lib/sprockets/path_reader_spec.rb +0 -41
  378. data/spec/lib/sprockets/processor_spec.rb +0 -79
  379. data/spec/lib/sprockets/server_spec.rb +0 -102
  380. data/spec/lib/sprockets_spec.rb +0 -32
  381. data/spec/lib/tilt/opal_spec.rb +0 -37
  382. data/spec/mspec-opal/formatters.rb +0 -188
  383. data/spec/mspec-opal/runner.rb +0 -193
  384. data/spec/opal/compiler/irb_spec.rb +0 -44
  385. data/spec/opal/core/arity_spec.rb +0 -142
  386. data/spec/opal/core/array/intersection_spec.rb +0 -38
  387. data/spec/opal/core/array/minus_spec.rb +0 -38
  388. data/spec/opal/core/array/select_spec.rb +0 -14
  389. data/spec/opal/core/array/set_range_to_array_spec.rb +0 -7
  390. data/spec/opal/core/array/union_spec.rb +0 -38
  391. data/spec/opal/core/array/uniq_spec.rb +0 -49
  392. data/spec/opal/core/date_spec.rb +0 -177
  393. data/spec/opal/core/enumerable/all_break_spec.rb +0 -5
  394. data/spec/opal/core/enumerable/any_break_spec.rb +0 -5
  395. data/spec/opal/core/enumerable/collect_break_spec.rb +0 -13
  396. data/spec/opal/core/enumerable/count_break_spec.rb +0 -5
  397. data/spec/opal/core/enumerable/detect_break_spec.rb +0 -5
  398. data/spec/opal/core/enumerable/drop_while_break_spec.rb +0 -5
  399. data/spec/opal/core/enumerable/each_slice_break.rb +0 -6
  400. data/spec/opal/core/enumerable/each_with_index_break_spec.rb +0 -5
  401. data/spec/opal/core/enumerable/each_with_object_break_spec.rb +0 -5
  402. data/spec/opal/core/enumerable/find_all_break_spec.rb +0 -5
  403. data/spec/opal/core/enumerable/find_index_break_spec.rb +0 -5
  404. data/spec/opal/core/enumerable/grep_break_spec.rb +0 -5
  405. data/spec/opal/core/enumerable/max_break_spec.rb +0 -5
  406. data/spec/opal/core/enumerable/max_by_break_spec.rb +0 -5
  407. data/spec/opal/core/enumerable/min_break_spec.rb +0 -5
  408. data/spec/opal/core/enumerable/min_by_break_spec.rb +0 -5
  409. data/spec/opal/core/enumerable/none_break_spec.rb +0 -5
  410. data/spec/opal/core/enumerable/one_break_spec.rb +0 -5
  411. data/spec/opal/core/enumerable/reduce_break_spec.rb +0 -5
  412. data/spec/opal/core/enumerable/take_while_break_spec.rb +0 -5
  413. data/spec/opal/core/enumerator/with_index_spec.rb +0 -6
  414. data/spec/opal/core/exception_spec.rb +0 -20
  415. data/spec/opal/core/fixtures/class.rb +0 -124
  416. data/spec/opal/core/fixtures/class_variables.rb +0 -0
  417. data/spec/opal/core/fixtures/constants.rb +0 -33
  418. data/spec/opal/core/fixtures/require_tree_files/file 1.rb +0 -1
  419. data/spec/opal/core/fixtures/require_tree_files/file 2.rb +0 -1
  420. data/spec/opal/core/fixtures/require_tree_files/file 3.rb +0 -1
  421. data/spec/opal/core/fixtures/require_tree_files/file 4.rb +0 -1
  422. data/spec/opal/core/fixtures/require_tree_files/file 5.rb +0 -1
  423. data/spec/opal/core/fixtures/require_tree_files/nested/nested 1.rb +0 -1
  424. data/spec/opal/core/fixtures/require_tree_files/nested/nested 2.rb +0 -1
  425. data/spec/opal/core/fixtures/require_tree_files/other/other 1.rb +0 -1
  426. data/spec/opal/core/fixtures/require_tree_with_dot/file 1.rb +0 -1
  427. data/spec/opal/core/fixtures/require_tree_with_dot/file 2.rb +0 -1
  428. data/spec/opal/core/fixtures/require_tree_with_dot/file 3.rb +0 -1
  429. data/spec/opal/core/fixtures/require_tree_with_dot/index.rb +0 -3
  430. data/spec/opal/core/hash/has_value_spec.rb +0 -13
  431. data/spec/opal/core/hash/internals_spec.rb +0 -332
  432. data/spec/opal/core/helpers_spec.rb +0 -14
  433. data/spec/opal/core/kernel/Array_spec.rb +0 -10
  434. data/spec/opal/core/kernel/at_exit_spec.rb +0 -70
  435. data/spec/opal/core/kernel/block_given_spec.rb +0 -30
  436. data/spec/opal/core/kernel/class_spec.rb +0 -6
  437. data/spec/opal/core/kernel/define_singleton_method_spec.rb +0 -21
  438. data/spec/opal/core/kernel/equal_value_spec.rb +0 -12
  439. data/spec/opal/core/kernel/extend_spec.rb +0 -21
  440. data/spec/opal/core/kernel/format_spec.rb +0 -122
  441. data/spec/opal/core/kernel/freeze_spec.rb +0 -15
  442. data/spec/opal/core/kernel/instance_eval_spec.rb +0 -28
  443. data/spec/opal/core/kernel/instance_variable_defined_spec.rb +0 -15
  444. data/spec/opal/core/kernel/instance_variable_get_spec.rb +0 -14
  445. data/spec/opal/core/kernel/instance_variable_set_spec.rb +0 -10
  446. data/spec/opal/core/kernel/instance_variables_spec.rb +0 -110
  447. data/spec/opal/core/kernel/loop_spec.rb +0 -23
  448. data/spec/opal/core/kernel/match_spec.rb +0 -5
  449. data/spec/opal/core/kernel/method_spec.rb +0 -31
  450. data/spec/opal/core/kernel/methods_spec.rb +0 -25
  451. data/spec/opal/core/kernel/nil_spec.rb +0 -7
  452. data/spec/opal/core/kernel/p_spec.rb +0 -15
  453. data/spec/opal/core/kernel/printf_spec.rb +0 -11
  454. data/spec/opal/core/kernel/proc_spec.rb +0 -13
  455. data/spec/opal/core/kernel/raise_spec.rb +0 -13
  456. data/spec/opal/core/kernel/rand_spec.rb +0 -23
  457. data/spec/opal/core/kernel/require_tree_spec.rb +0 -18
  458. data/spec/opal/core/kernel/respond_to_spec.rb +0 -41
  459. data/spec/opal/core/kernel/send_spec.rb +0 -56
  460. data/spec/opal/core/kernel/sprintf_spec.rb +0 -5
  461. data/spec/opal/core/language/arguments/mlhs_arg_spec.rb +0 -19
  462. data/spec/opal/core/language/block_spec.rb +0 -538
  463. data/spec/opal/core/language/class_spec.rb +0 -55
  464. data/spec/opal/core/language/equal_spec.rb +0 -8
  465. data/spec/opal/core/language/fixtures/array.rb +0 -11
  466. data/spec/opal/core/language/fixtures/block.rb +0 -57
  467. data/spec/opal/core/language/fixtures/break.rb +0 -240
  468. data/spec/opal/core/language/fixtures/ensure.rb +0 -72
  469. data/spec/opal/core/language/fixtures/literal_lambda.rb +0 -7
  470. data/spec/opal/core/language/fixtures/metaclass.rb +0 -33
  471. data/spec/opal/core/language/fixtures/module.rb +0 -24
  472. data/spec/opal/core/language/fixtures/next.rb +0 -128
  473. data/spec/opal/core/language/fixtures/return.rb +0 -118
  474. data/spec/opal/core/language/fixtures/send.rb +0 -111
  475. data/spec/opal/core/language/fixtures/send_1.9.rb +0 -22
  476. data/spec/opal/core/language/fixtures/super.rb +0 -308
  477. data/spec/opal/core/language/fixtures/variables.rb +0 -58
  478. data/spec/opal/core/language/fixtures/yield.rb +0 -28
  479. data/spec/opal/core/language/heredoc_spec.rb +0 -42
  480. data/spec/opal/core/language/keyword_arguments_spec.rb +0 -11
  481. data/spec/opal/core/language/predefined_spec.rb +0 -138
  482. data/spec/opal/core/language/proc_spec.rb +0 -263
  483. data/spec/opal/core/language/regexp_spec.rb +0 -20
  484. data/spec/opal/core/language/rescue_spec.rb +0 -18
  485. data/spec/opal/core/language/send_spec.rb +0 -230
  486. data/spec/opal/core/language/string_spec.rb +0 -44
  487. data/spec/opal/core/language/ternary_operator_spec.rb +0 -20
  488. data/spec/opal/core/language/variables_spec.rb +0 -1366
  489. data/spec/opal/core/language/versions/array_1.9.rb +0 -39
  490. data/spec/opal/core/language/versions/block_1.9.rb +0 -0
  491. data/spec/opal/core/language/versions/break_1.9.rb +0 -0
  492. data/spec/opal/core/language/versions/case_1.9.rb +0 -20
  493. data/spec/opal/core/language/versions/def_2_0_spec.rb +0 -62
  494. data/spec/opal/core/language/versions/hash_1_9_spec.rb +0 -23
  495. data/spec/opal/core/language/versions/literal_lambda_1.9.rb +0 -143
  496. data/spec/opal/core/language/versions/not_1.9.rb +0 -22
  497. data/spec/opal/core/language/versions/send_1.9.rb +0 -241
  498. data/spec/opal/core/language/versions/symbol_1.9.rb +0 -15
  499. data/spec/opal/core/language/versions/variables_1.9.rb +0 -8
  500. data/spec/opal/core/language_spec.rb +0 -45
  501. data/spec/opal/core/marshal/dump_spec.rb +0 -53
  502. data/spec/opal/core/marshal/load_spec.rb +0 -7
  503. data/spec/opal/core/method/to_proc_spec.rb +0 -28
  504. data/spec/opal/core/module/alias_method_spec.rb +0 -28
  505. data/spec/opal/core/module/ancestors_spec.rb +0 -11
  506. data/spec/opal/core/module/append_features_spec.rb +0 -14
  507. data/spec/opal/core/module/attr_accessor_spec.rb +0 -26
  508. data/spec/opal/core/module/const_defined_spec.rb +0 -84
  509. data/spec/opal/core/module/const_get_spec.rb +0 -85
  510. data/spec/opal/core/module/const_missing_spec.rb +0 -17
  511. data/spec/opal/core/module/const_set_spec.rb +0 -64
  512. data/spec/opal/core/module/constants_spec.rb +0 -49
  513. data/spec/opal/core/module/fixtures/classes.rb +0 -444
  514. data/spec/opal/core/module/method_defined_spec.rb +0 -48
  515. data/spec/opal/core/module/method_lookup_spec.rb +0 -13
  516. data/spec/opal/core/module/module_function_spec.rb +0 -25
  517. data/spec/opal/core/module/name_spec.rb +0 -41
  518. data/spec/opal/core/module/public_method_defined_spec.rb +0 -18
  519. data/spec/opal/core/module/remove_const_spec.rb +0 -22
  520. data/spec/opal/core/module/undef_method_spec.rb +0 -66
  521. data/spec/opal/core/numeric/bit_and_spec.rb +0 -7
  522. data/spec/opal/core/numeric/bit_or_spec.rb +0 -8
  523. data/spec/opal/core/numeric/bit_xor_spec.rb +0 -6
  524. data/spec/opal/core/numeric/ceil_spec.rb +0 -8
  525. data/spec/opal/core/numeric/chr_spec.rb +0 -8
  526. data/spec/opal/core/numeric/comparison_spec.rb +0 -24
  527. data/spec/opal/core/numeric/complement_spec.rb +0 -8
  528. data/spec/opal/core/numeric/divide_spec.rb +0 -10
  529. data/spec/opal/core/numeric/eql_spec.rb +0 -9
  530. data/spec/opal/core/numeric/exponent_spec.rb +0 -33
  531. data/spec/opal/core/numeric/floor_spec.rb +0 -8
  532. data/spec/opal/core/numeric/gt_spec.rb +0 -11
  533. data/spec/opal/core/numeric/gte_spec.rb +0 -12
  534. data/spec/opal/core/numeric/integer_spec.rb +0 -9
  535. data/spec/opal/core/numeric/left_shift_spec.rb +0 -21
  536. data/spec/opal/core/numeric/lt_spec.rb +0 -11
  537. data/spec/opal/core/numeric/lte_spec.rb +0 -12
  538. data/spec/opal/core/numeric/minus_spec.rb +0 -8
  539. data/spec/opal/core/numeric/modulo_spec.rb +0 -19
  540. data/spec/opal/core/numeric/multiply_spec.rb +0 -9
  541. data/spec/opal/core/numeric/next_spec.rb +0 -9
  542. data/spec/opal/core/numeric/ord_spec.rb +0 -9
  543. data/spec/opal/core/numeric/plus_spec.rb +0 -8
  544. data/spec/opal/core/numeric/pred_spec.rb +0 -7
  545. data/spec/opal/core/numeric/right_shift_spec.rb +0 -25
  546. data/spec/opal/core/numeric/step_spec.rb +0 -11
  547. data/spec/opal/core/numeric/succ_spec.rb +0 -9
  548. data/spec/opal/core/numeric/times_spec.rb +0 -36
  549. data/spec/opal/core/numeric/to_f_spec.rb +0 -7
  550. data/spec/opal/core/numeric/to_i_spec.rb +0 -7
  551. data/spec/opal/core/numeric/to_json_spec.rb +0 -8
  552. data/spec/opal/core/numeric/to_s_spec.rb +0 -26
  553. data/spec/opal/core/numeric/uminus_spec.rb +0 -9
  554. data/spec/opal/core/numeric/upto_spec.rb +0 -19
  555. data/spec/opal/core/numeric/zero_spec.rb +0 -7
  556. data/spec/opal/core/object_id_spec.rb +0 -56
  557. data/spec/opal/core/proc/call_spec.rb +0 -21
  558. data/spec/opal/core/proc/element_reference_spec.rb +0 -21
  559. data/spec/opal/core/proc/proc_tricks_spec.rb +0 -7
  560. data/spec/opal/core/runtime/begin_spec.rb +0 -39
  561. data/spec/opal/core/runtime/block_send_spec.rb +0 -28
  562. data/spec/opal/core/runtime/block_spec.rb +0 -23
  563. data/spec/opal/core/runtime/bridged_classes_spec.rb +0 -123
  564. data/spec/opal/core/runtime/constants_spec.rb +0 -13
  565. data/spec/opal/core/runtime/donate_spec.rb +0 -53
  566. data/spec/opal/core/runtime/eval_spec.rb +0 -5
  567. data/spec/opal/core/runtime/main_methods_spec.rb +0 -27
  568. data/spec/opal/core/runtime/method_missing_spec.rb +0 -68
  569. data/spec/opal/core/runtime/method_spec.rb +0 -31
  570. data/spec/opal/core/runtime/operator_call_spec.rb +0 -13
  571. data/spec/opal/core/runtime/paren_spec.rb +0 -14
  572. data/spec/opal/core/runtime/rescue_spec.rb +0 -71
  573. data/spec/opal/core/runtime/return_spec.rb +0 -38
  574. data/spec/opal/core/runtime/send_spec.rb +0 -34
  575. data/spec/opal/core/runtime/singleton_class_spec.rb +0 -13
  576. data/spec/opal/core/runtime/super_spec.rb +0 -223
  577. data/spec/opal/core/runtime/truthy_spec.rb +0 -63
  578. data/spec/opal/core/runtime/variables_spec.rb +0 -20
  579. data/spec/opal/core/runtime_spec.rb +0 -58
  580. data/spec/opal/core/source_map_spec.rb +0 -49
  581. data/spec/opal/core/string_spec.rb +0 -32
  582. data/spec/opal/javascript_api_spec.rb +0 -16
  583. data/spec/opal/stdlib/erb/erb_spec.rb +0 -30
  584. data/spec/opal/stdlib/erb/inline_block.opalerb +0 -3
  585. data/spec/opal/stdlib/erb/quoted.opalerb +0 -1
  586. data/spec/opal/stdlib/erb/simple.opalerb +0 -1
  587. data/spec/opal/stdlib/js_spec.rb +0 -66
  588. data/spec/opal/stdlib/json/ext_spec.rb +0 -48
  589. data/spec/opal/stdlib/json/parse_spec.rb +0 -33
  590. data/spec/opal/stdlib/native/alias_native_spec.rb +0 -27
  591. data/spec/opal/stdlib/native/array_spec.rb +0 -11
  592. data/spec/opal/stdlib/native/each_spec.rb +0 -13
  593. data/spec/opal/stdlib/native/element_reference_spec.rb +0 -16
  594. data/spec/opal/stdlib/native/exposure_spec.rb +0 -33
  595. data/spec/opal/stdlib/native/ext_spec.rb +0 -19
  596. data/spec/opal/stdlib/native/hash_spec.rb +0 -51
  597. data/spec/opal/stdlib/native/initialize_spec.rb +0 -17
  598. data/spec/opal/stdlib/native/method_missing_spec.rb +0 -51
  599. data/spec/opal/stdlib/native/native_alias_spec.rb +0 -19
  600. data/spec/opal/stdlib/native/native_class_spec.rb +0 -18
  601. data/spec/opal/stdlib/native/native_module_spec.rb +0 -13
  602. data/spec/opal/stdlib/native/native_reader_spec.rb +0 -22
  603. data/spec/opal/stdlib/native/native_writer_spec.rb +0 -30
  604. data/spec/opal/stdlib/native/new_spec.rb +0 -92
  605. data/spec/opal/stdlib/native/struct_spec.rb +0 -12
  606. data/spec/opal/stdlib/promise/always_spec.rb +0 -49
  607. data/spec/opal/stdlib/promise/error_spec.rb +0 -15
  608. data/spec/opal/stdlib/promise/rescue_spec.rb +0 -53
  609. data/spec/opal/stdlib/promise/then_spec.rb +0 -79
  610. data/spec/opal/stdlib/promise/trace_spec.rb +0 -51
  611. data/spec/opal/stdlib/promise/value_spec.rb +0 -15
  612. data/spec/opal/stdlib/promise/when_spec.rb +0 -34
  613. data/spec/opal/stdlib/source_map_spec.rb +0 -8
  614. data/spec/opal/stdlib/strscan/scan_spec.rb +0 -11
  615. data/spec/opal/stdlib/template/paths_spec.rb +0 -10
  616. data/spec/opal/stdlib/thread/mutex_spec.rb +0 -40
  617. data/spec/opal/stdlib/thread/thread_queue_spec.rb +0 -32
  618. data/spec/opal/stdlib/thread/thread_spec.rb +0 -60
  619. data/spec/ruby_specs +0 -121
  620. data/spec/spec_helper.rb +0 -26
  621. data/spec/support/match_helpers.rb +0 -57
  622. data/spec/support/mspec_rspec_adapter.rb +0 -33
  623. data/spec/support/parser_helpers.rb +0 -37
  624. data/stdlib/nodejs/node_modules/js-yaml/HISTORY.md +0 -277
  625. data/stdlib/nodejs/node_modules/js-yaml/README.md +0 -288
  626. data/stdlib/nodejs/node_modules/js-yaml/bin/js-yaml.js +0 -140
  627. data/stdlib/nodejs/node_modules/js-yaml/bower.json +0 -23
  628. data/stdlib/nodejs/node_modules/js-yaml/dist/js-yaml.min.js +0 -3
  629. data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.js +0 -102
  630. data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.yml +0 -18
  631. data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.js +0 -31
  632. data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.json +0 -22
  633. data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.js +0 -18
  634. data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.yml +0 -197
  635. data/stdlib/nodejs/node_modules/js-yaml/index.js +0 -7
  636. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js +0 -62
  637. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/dumper.js +0 -554
  638. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/exception.js +0 -25
  639. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/loader.js +0 -1581
  640. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/mark.js +0 -78
  641. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/core.js +0 -18
  642. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +0 -25
  643. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +0 -28
  644. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +0 -17
  645. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/json.js +0 -25
  646. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema.js +0 -103
  647. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/binary.js +0 -133
  648. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/bool.js +0 -37
  649. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/float.js +0 -110
  650. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/int.js +0 -183
  651. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/function.js +0 -85
  652. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +0 -84
  653. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +0 -27
  654. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/map.js +0 -8
  655. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/merge.js +0 -12
  656. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/null.js +0 -36
  657. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js +0 -56
  658. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/pairs.js +0 -61
  659. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/seq.js +0 -8
  660. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/set.js +0 -33
  661. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/str.js +0 -8
  662. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +0 -98
  663. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type.js +0 -61
  664. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml.js +0 -39
  665. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/HISTORY.md +0 -115
  666. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/README.md +0 -239
  667. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/arguments.js +0 -36
  668. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/choice.js +0 -22
  669. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/constants.js +0 -59
  670. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/help.js +0 -13
  671. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/nargs.js +0 -33
  672. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/parents.js +0 -28
  673. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js +0 -23
  674. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js +0 -49
  675. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sum.js +0 -35
  676. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js +0 -270
  677. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/index.js +0 -1
  678. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append/constant.js +0 -47
  679. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append.js +0 -55
  680. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/count.js +0 -40
  681. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/help.js +0 -48
  682. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/constant.js +0 -43
  683. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/false.js +0 -27
  684. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/true.js +0 -26
  685. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store.js +0 -50
  686. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/subparsers.js +0 -148
  687. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/version.js +0 -50
  688. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action.js +0 -146
  689. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action_container.js +0 -481
  690. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argparse.js +0 -14
  691. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/error.js +0 -50
  692. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/exclusive.js +0 -54
  693. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/group.js +0 -75
  694. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument_parser.js +0 -1168
  695. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/const.js +0 -18
  696. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/added_formatters.js +0 -88
  697. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/formatter.js +0 -798
  698. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/namespace.js +0 -77
  699. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE +0 -23
  700. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md +0 -22
  701. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json +0 -69
  702. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore-min.js +0 -6
  703. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore.js +0 -1415
  704. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.npmignore +0 -2
  705. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.travis.yml +0 -8
  706. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown +0 -825
  707. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/bower.json +0 -33
  708. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/component.json +0 -11
  709. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/foo.js +0 -10
  710. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/gulpfile.js +0 -26
  711. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/lib/underscore.string.js +0 -673
  712. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/libpeerconnection.log +0 -0
  713. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json +0 -107
  714. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/package.json +0 -62
  715. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/README.md +0 -73
  716. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esparse.js +0 -117
  717. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esvalidate.js +0 -177
  718. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/esprima.js +0 -3908
  719. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/package.json +0 -69
  720. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/compat.js +0 -239
  721. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/reflect.js +0 -422
  722. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/run.js +0 -66
  723. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/runner.js +0 -387
  724. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/test.js +0 -20238
  725. data/stdlib/nodejs/node_modules/js-yaml/package.json +0 -83
  726. data/stdlib/phantomjs.rb +0 -17
  727. data/tasks/testing/sprockets-phantomjs.js +0 -54
  728. data/test/nodejs/test_dir.rb +0 -17
  729. data/test/nodejs/test_file.rb +0 -30
  730. data/test/opal/test_keyword.rb +0 -590
  731. data/test/opal/unsupported_and_bugs.rb +0 -30
  732. /data/{CODE_OF_CONDUCT.md → CONDUCT.md} +0 -0
  733. /data/{bin → exe}/opal-build +0 -0
  734. /data/{bin → exe}/opal-mspec +0 -0
@@ -1,4 +1,7 @@
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){
1
+ // https://github.com/nodeca/js-yaml/blob/3.6.1/dist/js-yaml.js (c76b837cacc69de6b86a0781db31a9bb7a193875)
2
+
3
+ /* jshint ignore:start */
4
+ /* js-yaml 3.6.1 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(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
5
  'use strict';
3
6
 
4
7
 
@@ -28,7 +31,7 @@ module.exports.dump = dumper.dump;
28
31
  module.exports.safeDump = dumper.safeDump;
29
32
  module.exports.YAMLException = require('./js-yaml/exception');
30
33
 
31
- // Deprecared schema names from JS-YAML 2.0.x
34
+ // Deprecated schema names from JS-YAML 2.0.x
32
35
  module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
33
36
  module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
34
37
  module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
@@ -44,23 +47,20 @@ module.exports.addConstructor = deprecated('addConstructor');
44
47
 
45
48
 
46
49
  function isNothing(subject) {
47
- return (undefined === subject) || (null === subject);
50
+ return (typeof subject === 'undefined') || (subject === null);
48
51
  }
49
52
 
50
53
 
51
54
  function isObject(subject) {
52
- return ('object' === typeof subject) && (null !== subject);
55
+ return (typeof subject === 'object') && (subject !== null);
53
56
  }
54
57
 
55
58
 
56
59
  function toArray(sequence) {
57
- if (Array.isArray(sequence)) {
58
- return sequence;
59
- } else if (isNothing(sequence)) {
60
- return [];
61
- } else {
62
- return [ sequence ];
63
- }
60
+ if (Array.isArray(sequence)) return sequence;
61
+ else if (isNothing(sequence)) return [];
62
+
63
+ return [ sequence ];
64
64
  }
65
65
 
66
66
 
@@ -92,7 +92,7 @@ function repeat(string, count) {
92
92
 
93
93
 
94
94
  function isNegativeZero(number) {
95
- return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
95
+ return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
96
96
  }
97
97
 
98
98
 
@@ -106,20 +106,18 @@ module.exports.extend = extend;
106
106
  },{}],3:[function(require,module,exports){
107
107
  'use strict';
108
108
 
109
+ /*eslint-disable no-use-before-define*/
109
110
 
110
111
  var common = require('./common');
111
112
  var YAMLException = require('./exception');
112
113
  var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
113
114
  var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
114
115
 
115
-
116
116
  var _toString = Object.prototype.toString;
117
117
  var _hasOwnProperty = Object.prototype.hasOwnProperty;
118
118
 
119
-
120
119
  var CHAR_TAB = 0x09; /* Tab */
121
120
  var CHAR_LINE_FEED = 0x0A; /* LF */
122
- var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
123
121
  var CHAR_SPACE = 0x20; /* Space */
124
122
  var CHAR_EXCLAMATION = 0x21; /* ! */
125
123
  var CHAR_DOUBLE_QUOTE = 0x22; /* " */
@@ -141,7 +139,6 @@ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
141
139
  var CHAR_VERTICAL_LINE = 0x7C; /* | */
142
140
  var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
143
141
 
144
-
145
142
  var ESCAPE_SEQUENCES = {};
146
143
 
147
144
  ESCAPE_SEQUENCES[0x00] = '\\0';
@@ -160,19 +157,15 @@ ESCAPE_SEQUENCES[0xA0] = '\\_';
160
157
  ESCAPE_SEQUENCES[0x2028] = '\\L';
161
158
  ESCAPE_SEQUENCES[0x2029] = '\\P';
162
159
 
163
-
164
160
  var DEPRECATED_BOOLEANS_SYNTAX = [
165
161
  'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
166
162
  'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
167
163
  ];
168
164
 
169
-
170
165
  function compileStyleMap(schema, map) {
171
166
  var result, keys, index, length, tag, style, type;
172
167
 
173
- if (null === map) {
174
- return {};
175
- }
168
+ if (map === null) return {};
176
169
 
177
170
  result = {};
178
171
  keys = Object.keys(map);
@@ -181,7 +174,7 @@ function compileStyleMap(schema, map) {
181
174
  tag = keys[index];
182
175
  style = String(map[tag]);
183
176
 
184
- if ('!!' === tag.slice(0, 2)) {
177
+ if (tag.slice(0, 2) === '!!') {
185
178
  tag = 'tag:yaml.org,2002:' + tag.slice(2);
186
179
  }
187
180
 
@@ -197,7 +190,6 @@ function compileStyleMap(schema, map) {
197
190
  return result;
198
191
  }
199
192
 
200
-
201
193
  function encodeHex(character) {
202
194
  var string, handle, length;
203
195
 
@@ -219,13 +211,16 @@ function encodeHex(character) {
219
211
  return '\\' + handle + common.repeat('0', length - string.length) + string;
220
212
  }
221
213
 
222
-
223
214
  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);
215
+ this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
216
+ this.indent = Math.max(1, (options['indent'] || 2));
217
+ this.skipInvalid = options['skipInvalid'] || false;
218
+ this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
219
+ this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
220
+ this.sortKeys = options['sortKeys'] || false;
221
+ this.lineWidth = options['lineWidth'] || 80;
222
+ this.noRefs = options['noRefs'] || false;
223
+ this.noCompatMode = options['noCompatMode'] || false;
229
224
 
230
225
  this.implicitTypes = this.schema.compiledImplicit;
231
226
  this.explicitTypes = this.schema.compiledExplicit;
@@ -237,6 +232,32 @@ function State(options) {
237
232
  this.usedDuplicates = null;
238
233
  }
239
234
 
235
+ // Indents every line in a string. Empty lines (\n only) are not indented.
236
+ function indentString(string, spaces) {
237
+ var ind = common.repeat(' ', spaces),
238
+ position = 0,
239
+ next = -1,
240
+ result = '',
241
+ line,
242
+ length = string.length;
243
+
244
+ while (position < length) {
245
+ next = string.indexOf('\n', position);
246
+ if (next === -1) {
247
+ line = string.slice(position);
248
+ position = length;
249
+ } else {
250
+ line = string.slice(position, next + 1);
251
+ position = next + 1;
252
+ }
253
+
254
+ if (line.length && line !== '\n') result += ind;
255
+
256
+ result += line;
257
+ }
258
+
259
+ return result;
260
+ }
240
261
 
241
262
  function generateNextLine(state, level) {
242
263
  return '\n' + common.repeat(' ', state.indent * level);
@@ -256,81 +277,308 @@ function testImplicitResolving(state, str) {
256
277
  return false;
257
278
  }
258
279
 
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;
280
+ // [33] s-white ::= s-space | s-tab
281
+ function isWhitespace(c) {
282
+ return c === CHAR_SPACE || c === CHAR_TAB;
283
+ }
284
+
285
+ // Returns true if the character can be printed without escaping.
286
+ // From YAML 1.2: "any allowed characters known to be non-printable
287
+ // should also be escaped. [However,] This isn’t mandatory"
288
+ // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
289
+ function isPrintable(c) {
290
+ return (0x00020 <= c && c <= 0x00007E)
291
+ || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
292
+ || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
293
+ || (0x10000 <= c && c <= 0x10FFFF);
294
+ }
295
+
296
+ // Simplified test for values allowed after the first character in plain style.
297
+ function isPlainSafe(c) {
298
+ // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
299
+ // where nb-char ::= c-printable - b-char - c-byte-order-mark.
300
+ return isPrintable(c) && c !== 0xFEFF
301
+ // - c-flow-indicator
302
+ && c !== CHAR_COMMA
303
+ && c !== CHAR_LEFT_SQUARE_BRACKET
304
+ && c !== CHAR_RIGHT_SQUARE_BRACKET
305
+ && c !== CHAR_LEFT_CURLY_BRACKET
306
+ && c !== CHAR_RIGHT_CURLY_BRACKET
307
+ // - ":" - "#"
308
+ && c !== CHAR_COLON
309
+ && c !== CHAR_SHARP;
310
+ }
311
+
312
+ // Simplified test for values allowed as the first character in plain style.
313
+ function isPlainSafeFirst(c) {
314
+ // Uses a subset of ns-char - c-indicator
315
+ // where ns-char = nb-char - s-white.
316
+ return isPrintable(c) && c !== 0xFEFF
317
+ && !isWhitespace(c) // - s-white
318
+ // - (c-indicator ::=
319
+ // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
320
+ && c !== CHAR_MINUS
321
+ && c !== CHAR_QUESTION
322
+ && c !== CHAR_COLON
323
+ && c !== CHAR_COMMA
324
+ && c !== CHAR_LEFT_SQUARE_BRACKET
325
+ && c !== CHAR_RIGHT_SQUARE_BRACKET
326
+ && c !== CHAR_LEFT_CURLY_BRACKET
327
+ && c !== CHAR_RIGHT_CURLY_BRACKET
328
+ // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
329
+ && c !== CHAR_SHARP
330
+ && c !== CHAR_AMPERSAND
331
+ && c !== CHAR_ASTERISK
332
+ && c !== CHAR_EXCLAMATION
333
+ && c !== CHAR_VERTICAL_LINE
334
+ && c !== CHAR_GREATER_THAN
335
+ && c !== CHAR_SINGLE_QUOTE
336
+ && c !== CHAR_DOUBLE_QUOTE
337
+ // | “%” | “@” | “`”)
338
+ && c !== CHAR_PERCENT
339
+ && c !== CHAR_COMMERCIAL_AT
340
+ && c !== CHAR_GRAVE_ACCENT;
341
+ }
342
+
343
+ var STYLE_PLAIN = 1,
344
+ STYLE_SINGLE = 2,
345
+ STYLE_LITERAL = 3,
346
+ STYLE_FOLDED = 4,
347
+ STYLE_DOUBLE = 5;
348
+
349
+ // Determines which scalar styles are possible and returns the preferred style.
350
+ // lineWidth = -1 => no limit.
351
+ // Pre-conditions: str.length > 0.
352
+ // Post-conditions:
353
+ // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
354
+ // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
355
+ // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
356
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
357
+ var i;
358
+ var char;
359
+ var hasLineBreak = false;
360
+ var hasFoldableLine = false; // only checked if shouldTrackWidth
361
+ var shouldTrackWidth = lineWidth !== -1;
362
+ var previousLineBreak = -1; // count the first line correctly
363
+ var plain = isPlainSafeFirst(string.charCodeAt(0))
364
+ && !isWhitespace(string.charCodeAt(string.length - 1));
365
+
366
+ if (singleLineOnly) {
367
+ // Case: no block styles.
368
+ // Check for disallowed characters to rule out plain and single.
369
+ for (i = 0; i < string.length; i++) {
370
+ char = string.charCodeAt(i);
371
+ if (!isPrintable(char)) {
372
+ return STYLE_DOUBLE;
307
373
  }
374
+ plain = plain && isPlainSafe(char);
308
375
  }
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
- }
376
+ } else {
377
+ // Case: block styles permitted.
378
+ for (i = 0; i < string.length; i++) {
379
+ char = string.charCodeAt(i);
380
+ if (char === CHAR_LINE_FEED) {
381
+ hasLineBreak = true;
382
+ // Check if any line can be folded.
383
+ if (shouldTrackWidth) {
384
+ hasFoldableLine = hasFoldableLine ||
385
+ // Foldable line = too long, and not more-indented.
386
+ (i - previousLineBreak - 1 > lineWidth &&
387
+ string[previousLineBreak + 1] !== ' ');
388
+ previousLineBreak = i;
389
+ }
390
+ } else if (!isPrintable(char)) {
391
+ return STYLE_DOUBLE;
392
+ }
393
+ plain = plain && isPlainSafe(char);
394
+ }
395
+ // in case the end is missing a \n
396
+ hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
397
+ (i - previousLineBreak - 1 > lineWidth &&
398
+ string[previousLineBreak + 1] !== ' '));
399
+ }
400
+ // Although every style can represent \n without escaping, prefer block styles
401
+ // for multiline, since they're more readable and they don't add empty lines.
402
+ // Also prefer folding a super-long line.
403
+ if (!hasLineBreak && !hasFoldableLine) {
404
+ // Strings interpretable as another type have to be quoted;
405
+ // e.g. the string 'true' vs. the boolean true.
406
+ return plain && !testAmbiguousType(string)
407
+ ? STYLE_PLAIN : STYLE_SINGLE;
408
+ }
409
+ // Edge case: block indentation indicator can only have one digit.
410
+ if (string[0] === ' ' && indentPerLevel > 9) {
411
+ return STYLE_DOUBLE;
412
+ }
413
+ // At this point we know block styles are valid.
414
+ // Prefer literal style unless we want to fold.
415
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
416
+ }
417
+
418
+ // Note: line breaking/folding is implemented for only the folded style.
419
+ // NB. We drop the last trailing newline (if any) of a returned block scalar
420
+ // since the dumper adds its own newline. This always works:
421
+ // • No ending newline => unaffected; already using strip "-" chomping.
422
+ // • Ending newline => removed then restored.
423
+ // Importantly, this keeps the "+" chomp indicator from gaining an extra line.
424
+ function writeScalar(state, string, level, iskey) {
425
+ state.dump = (function () {
426
+ if (string.length === 0) {
427
+ return "''";
428
+ }
429
+ if (!state.noCompatMode &&
430
+ DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
431
+ return "'" + string + "'";
432
+ }
433
+
434
+ var indent = state.indent * Math.max(1, level); // no 0-indent scalars
435
+ // As indentation gets deeper, let the width decrease monotonically
436
+ // to the lower bound min(state.lineWidth, 40).
437
+ // Note that this implies
438
+ // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
439
+ // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
440
+ // This behaves better than a constant minimum width which disallows narrower options,
441
+ // or an indent threshold which causes the width to suddenly increase.
442
+ var lineWidth = state.lineWidth === -1
443
+ ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
444
+
445
+ // Without knowing if keys are implicit/explicit, assume implicit for safety.
446
+ var singleLineOnly = iskey
447
+ // No block styles in flow mode.
448
+ || (state.flowLevel > -1 && level >= state.flowLevel);
449
+ function testAmbiguity(string) {
450
+ return testImplicitResolving(state, string);
451
+ }
452
+
453
+ switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
454
+ case STYLE_PLAIN:
455
+ return string;
456
+ case STYLE_SINGLE:
457
+ return "'" + string.replace(/'/g, "''") + "'";
458
+ case STYLE_LITERAL:
459
+ return '|' + blockHeader(string, state.indent)
460
+ + dropEndingNewline(indentString(string, indent));
461
+ case STYLE_FOLDED:
462
+ return '>' + blockHeader(string, state.indent)
463
+ + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
464
+ case STYLE_DOUBLE:
465
+ return '"' + escapeString(string, lineWidth) + '"';
466
+ default:
467
+ throw new YAMLException('impossible error: invalid scalar style');
468
+ }
469
+ }());
470
+ }
471
+
472
+ // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
473
+ function blockHeader(string, indentPerLevel) {
474
+ var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : '';
475
+
476
+ // note the special case: the string '\n' counts as a "trailing" empty line.
477
+ var clip = string[string.length - 1] === '\n';
478
+ var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
479
+ var chomp = keep ? '+' : (clip ? '' : '-');
480
+
481
+ return indentIndicator + chomp + '\n';
482
+ }
483
+
484
+ // (See the note for writeScalar.)
485
+ function dropEndingNewline(string) {
486
+ return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
487
+ }
488
+
489
+ // Note: a long line without a suitable break point will exceed the width limit.
490
+ // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
491
+ function foldString(string, width) {
492
+ // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
493
+ // unless they're before or after a more-indented line, or at the very
494
+ // beginning or end, in which case $k$ maps to $k$.
495
+ // Therefore, parse each chunk as newline(s) followed by a content line.
496
+ var lineRe = /(\n+)([^\n]*)/g;
497
+
498
+ // first line (possibly an empty line)
499
+ var result = (function () {
500
+ var nextLF = string.indexOf('\n');
501
+ nextLF = nextLF !== -1 ? nextLF : string.length;
502
+ lineRe.lastIndex = nextLF;
503
+ return foldLine(string.slice(0, nextLF), width);
504
+ }());
505
+ // If we haven't reached the first content line yet, don't add an extra \n.
506
+ var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
507
+ var moreIndented;
508
+
509
+ // rest of the lines
510
+ var match;
511
+ while ((match = lineRe.exec(string))) {
512
+ var prefix = match[1], line = match[2];
513
+ moreIndented = (line[0] === ' ');
514
+ result += prefix
515
+ + (!prevMoreIndented && !moreIndented && line !== ''
516
+ ? '\n' : '')
517
+ + foldLine(line, width);
518
+ prevMoreIndented = moreIndented;
321
519
  }
322
520
 
323
- if (checkpoint < position) {
324
- state.dump += object.slice(checkpoint, position);
325
- }
521
+ return result;
522
+ }
326
523
 
327
- if (!isQuoted && testImplicitResolving(state, state.dump)) {
328
- isQuoted = true;
524
+ // Greedy line breaking.
525
+ // Picks the longest line under the limit each time,
526
+ // otherwise settles for the shortest line over the limit.
527
+ // NB. More-indented lines *cannot* be folded, as that would add an extra \n.
528
+ function foldLine(line, width) {
529
+ if (line === '' || line[0] === ' ') return line;
530
+
531
+ // Since a more-indented line adds a \n, breaks can't be followed by a space.
532
+ var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
533
+ var match;
534
+ // start is an inclusive index. end, curr, and next are exclusive.
535
+ var start = 0, end, curr = 0, next = 0;
536
+ var result = '';
537
+
538
+ // Invariants: 0 <= start <= length-1.
539
+ // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
540
+ // Inside the loop:
541
+ // A match implies length >= 2, so curr and next are <= length-2.
542
+ while ((match = breakRe.exec(line))) {
543
+ next = match.index;
544
+ // maintain invariant: curr - start <= width
545
+ if (next - start > width) {
546
+ end = (curr > start) ? curr : next; // derive end <= length-2
547
+ result += '\n' + line.slice(start, end);
548
+ // skip the space that was output as \n
549
+ start = end + 1; // derive start <= length-1
550
+ }
551
+ curr = next;
552
+ }
553
+
554
+ // By the invariants, start <= length-1, so there is something left over.
555
+ // It is either the whole string or a part starting from non-whitespace.
556
+ result += '\n';
557
+ // Insert a break if the remainder is too long and there is a break available.
558
+ if (line.length - start > width && curr > start) {
559
+ result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
560
+ } else {
561
+ result += line.slice(start);
329
562
  }
330
563
 
331
- if (isQuoted) {
332
- state.dump = '"' + state.dump + '"';
564
+ return result.slice(1); // drop extra \n joiner
565
+ }
566
+
567
+ // Escapes a double-quoted string.
568
+ function escapeString(string) {
569
+ var result = '';
570
+ var char;
571
+ var escapeSeq;
572
+
573
+ for (var i = 0; i < string.length; i++) {
574
+ char = string.charCodeAt(i);
575
+ escapeSeq = ESCAPE_SEQUENCES[char];
576
+ result += !escapeSeq && isPrintable(char)
577
+ ? string[i]
578
+ : escapeSeq || encodeHex(char);
333
579
  }
580
+
581
+ return result;
334
582
  }
335
583
 
336
584
  function writeFlowSequence(state, level, object) {
@@ -342,9 +590,7 @@ function writeFlowSequence(state, level, object) {
342
590
  for (index = 0, length = object.length; index < length; index += 1) {
343
591
  // Write only valid elements.
344
592
  if (writeNode(state, level, object[index], false, false)) {
345
- if (0 !== index) {
346
- _result += ', ';
347
- }
593
+ if (index !== 0) _result += ', ';
348
594
  _result += state.dump;
349
595
  }
350
596
  }
@@ -362,7 +608,7 @@ function writeBlockSequence(state, level, object, compact) {
362
608
  for (index = 0, length = object.length; index < length; index += 1) {
363
609
  // Write only valid elements.
364
610
  if (writeNode(state, level + 1, object[index], true, true)) {
365
- if (!compact || 0 !== index) {
611
+ if (!compact || index !== 0) {
366
612
  _result += generateNextLine(state, level);
367
613
  }
368
614
  _result += '- ' + state.dump;
@@ -386,9 +632,7 @@ function writeFlowMapping(state, level, object) {
386
632
  for (index = 0, length = objectKeyList.length; index < length; index += 1) {
387
633
  pairBuffer = '';
388
634
 
389
- if (0 !== index) {
390
- pairBuffer += ', ';
391
- }
635
+ if (index !== 0) pairBuffer += ', ';
392
636
 
393
637
  objectKey = objectKeyList[index];
394
638
  objectValue = object[objectKey];
@@ -397,9 +641,7 @@ function writeFlowMapping(state, level, object) {
397
641
  continue; // Skip this pair because of invalid key;
398
642
  }
399
643
 
400
- if (state.dump.length > 1024) {
401
- pairBuffer += '? ';
402
- }
644
+ if (state.dump.length > 1024) pairBuffer += '? ';
403
645
 
404
646
  pairBuffer += state.dump + ': ';
405
647
 
@@ -428,21 +670,33 @@ function writeBlockMapping(state, level, object, compact) {
428
670
  explicitPair,
429
671
  pairBuffer;
430
672
 
673
+ // Allow sorting keys so that the output file is deterministic
674
+ if (state.sortKeys === true) {
675
+ // Default sorting
676
+ objectKeyList.sort();
677
+ } else if (typeof state.sortKeys === 'function') {
678
+ // Custom sort function
679
+ objectKeyList.sort(state.sortKeys);
680
+ } else if (state.sortKeys) {
681
+ // Something is wrong
682
+ throw new YAMLException('sortKeys must be a boolean or a function');
683
+ }
684
+
431
685
  for (index = 0, length = objectKeyList.length; index < length; index += 1) {
432
686
  pairBuffer = '';
433
687
 
434
- if (!compact || 0 !== index) {
688
+ if (!compact || index !== 0) {
435
689
  pairBuffer += generateNextLine(state, level);
436
690
  }
437
691
 
438
692
  objectKey = objectKeyList[index];
439
693
  objectValue = object[objectKey];
440
694
 
441
- if (!writeNode(state, level + 1, objectKey, true, true)) {
695
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
442
696
  continue; // Skip this pair because of invalid key.
443
697
  }
444
698
 
445
- explicitPair = (null !== state.tag && '?' !== state.tag) ||
699
+ explicitPair = (state.tag !== null && state.tag !== '?') ||
446
700
  (state.dump && state.dump.length > 1024);
447
701
 
448
702
  if (explicitPair) {
@@ -488,7 +742,7 @@ function detectType(state, object, explicit) {
488
742
  type = typeList[index];
489
743
 
490
744
  if ((type.instanceOf || type.predicate) &&
491
- (!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) &&
745
+ (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
492
746
  (!type.predicate || type.predicate(object))) {
493
747
 
494
748
  state.tag = explicit ? type.tag : '?';
@@ -496,7 +750,7 @@ function detectType(state, object, explicit) {
496
750
  if (type.represent) {
497
751
  style = state.styleMap[type.tag] || type.defaultStyle;
498
752
 
499
- if ('[object Function]' === _toString.call(type.represent)) {
753
+ if (_toString.call(type.represent) === '[object Function]') {
500
754
  _result = type.represent(object, style);
501
755
  } else if (_hasOwnProperty.call(type.represent, style)) {
502
756
  _result = type.represent[style](object, style);
@@ -517,7 +771,7 @@ function detectType(state, object, explicit) {
517
771
  // Serializes `object` and writes it to global `result`.
518
772
  // Returns true on success, or false on invalid object.
519
773
  //
520
- function writeNode(state, level, object, block, compact) {
774
+ function writeNode(state, level, object, block, compact, iskey) {
521
775
  state.tag = null;
522
776
  state.dump = object;
523
777
 
@@ -528,14 +782,10 @@ function writeNode(state, level, object, block, compact) {
528
782
  var type = _toString.call(state.dump);
529
783
 
530
784
  if (block) {
531
- block = (0 > state.flowLevel || state.flowLevel > level);
785
+ block = (state.flowLevel < 0 || state.flowLevel > level);
532
786
  }
533
787
 
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,
788
+ var objectOrArray = type === '[object Object]' || type === '[object Array]',
539
789
  duplicateIndex,
540
790
  duplicate;
541
791
 
@@ -544,17 +794,21 @@ function writeNode(state, level, object, block, compact) {
544
794
  duplicate = duplicateIndex !== -1;
545
795
  }
546
796
 
797
+ if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
798
+ compact = false;
799
+ }
800
+
547
801
  if (duplicate && state.usedDuplicates[duplicateIndex]) {
548
802
  state.dump = '*ref_' + duplicateIndex;
549
803
  } else {
550
804
  if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
551
805
  state.usedDuplicates[duplicateIndex] = true;
552
806
  }
553
- if ('[object Object]' === type) {
554
- if (block && (0 !== Object.keys(state.dump).length)) {
807
+ if (type === '[object Object]') {
808
+ if (block && (Object.keys(state.dump).length !== 0)) {
555
809
  writeBlockMapping(state, level, state.dump, compact);
556
810
  if (duplicate) {
557
- state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
811
+ state.dump = '&ref_' + duplicateIndex + state.dump;
558
812
  }
559
813
  } else {
560
814
  writeFlowMapping(state, level, state.dump);
@@ -562,11 +816,11 @@ function writeNode(state, level, object, block, compact) {
562
816
  state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
563
817
  }
564
818
  }
565
- } else if ('[object Array]' === type) {
566
- if (block && (0 !== state.dump.length)) {
819
+ } else if (type === '[object Array]') {
820
+ if (block && (state.dump.length !== 0)) {
567
821
  writeBlockSequence(state, level, state.dump, compact);
568
822
  if (duplicate) {
569
- state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
823
+ state.dump = '&ref_' + duplicateIndex + state.dump;
570
824
  }
571
825
  } else {
572
826
  writeFlowSequence(state, level, state.dump);
@@ -574,17 +828,16 @@ function writeNode(state, level, object, block, compact) {
574
828
  state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
575
829
  }
576
830
  }
577
- } else if ('[object String]' === type) {
578
- if ('?' !== state.tag) {
579
- writeScalar(state, state.dump);
831
+ } else if (type === '[object String]') {
832
+ if (state.tag !== '?') {
833
+ writeScalar(state, state.dump, level, iskey);
580
834
  }
581
- } else if (state.skipInvalid) {
582
- return false;
583
835
  } else {
836
+ if (state.skipInvalid) return false;
584
837
  throw new YAMLException('unacceptable kind of an object to dump ' + type);
585
838
  }
586
839
 
587
- if (null !== state.tag && '?' !== state.tag) {
840
+ if (state.tag !== null && state.tag !== '?') {
588
841
  state.dump = '!<' + state.tag + '> ' + state.dump;
589
842
  }
590
843
  }
@@ -607,21 +860,20 @@ function getDuplicateReferences(object, state) {
607
860
  }
608
861
 
609
862
  function inspectNode(object, objects, duplicatesIndexes) {
610
- var type = _toString.call(object),
611
- objectKeyList,
863
+ var objectKeyList,
612
864
  index,
613
865
  length;
614
866
 
615
- if (null !== object && 'object' === typeof object) {
867
+ if (object !== null && typeof object === 'object') {
616
868
  index = objects.indexOf(object);
617
- if (-1 !== index) {
618
- if (-1 === duplicatesIndexes.indexOf(index)) {
869
+ if (index !== -1) {
870
+ if (duplicatesIndexes.indexOf(index) === -1) {
619
871
  duplicatesIndexes.push(index);
620
872
  }
621
873
  } else {
622
874
  objects.push(object);
623
-
624
- if(Array.isArray(object)) {
875
+
876
+ if (Array.isArray(object)) {
625
877
  for (index = 0, length = object.length; index < length; index += 1) {
626
878
  inspectNode(object[index], objects, duplicatesIndexes);
627
879
  }
@@ -641,40 +893,54 @@ function dump(input, options) {
641
893
 
642
894
  var state = new State(options);
643
895
 
644
- getDuplicateReferences(input, state);
896
+ if (!state.noRefs) getDuplicateReferences(input, state);
645
897
 
646
- if (writeNode(state, 0, input, true, true)) {
647
- return state.dump + '\n';
648
- } else {
649
- return '';
650
- }
651
- }
898
+ if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
652
899
 
900
+ return '';
901
+ }
653
902
 
654
903
  function safeDump(input, options) {
655
904
  return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
656
905
  }
657
906
 
658
-
659
907
  module.exports.dump = dump;
660
908
  module.exports.safeDump = safeDump;
661
909
 
662
910
  },{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
911
+ // YAML error class. http://stackoverflow.com/questions/8458984
912
+ //
663
913
  'use strict';
664
914
 
665
-
666
915
  function YAMLException(reason, mark) {
667
- this.name = 'YAMLException';
668
- this.reason = reason;
669
- this.mark = mark;
670
- this.message = this.toString(false);
916
+ // Super constructor
917
+ Error.call(this);
918
+
919
+ // Include stack trace in error object
920
+ if (Error.captureStackTrace) {
921
+ // Chrome and NodeJS
922
+ Error.captureStackTrace(this, this.constructor);
923
+ } else {
924
+ // FF, IE 10+ and Safari 6+. Fallback for others
925
+ this.stack = (new Error()).stack || '';
926
+ }
927
+
928
+ this.name = 'YAMLException';
929
+ this.reason = reason;
930
+ this.mark = mark;
931
+ this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
671
932
  }
672
933
 
673
934
 
935
+ // Inherit from Error
936
+ YAMLException.prototype = Object.create(Error.prototype);
937
+ YAMLException.prototype.constructor = YAMLException;
938
+
939
+
674
940
  YAMLException.prototype.toString = function toString(compact) {
675
- var result;
941
+ var result = this.name + ': ';
676
942
 
677
- result = 'JS-YAML: ' + (this.reason || '(unknown reason)');
943
+ result += this.reason || '(unknown reason)';
678
944
 
679
945
  if (!compact && this.mark) {
680
946
  result += ' ' + this.mark.toString();
@@ -689,6 +955,7 @@ module.exports = YAMLException;
689
955
  },{}],5:[function(require,module,exports){
690
956
  'use strict';
691
957
 
958
+ /*eslint-disable max-len,no-use-before-define*/
692
959
 
693
960
  var common = require('./common');
694
961
  var YAMLException = require('./exception');
@@ -711,7 +978,7 @@ var CHOMPING_STRIP = 2;
711
978
  var CHOMPING_KEEP = 3;
712
979
 
713
980
 
714
- var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uD800-\uDFFF\uFFFE\uFFFF]/;
981
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
715
982
  var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
716
983
  var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
717
984
  var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
@@ -734,11 +1001,11 @@ function is_WS_OR_EOL(c) {
734
1001
  }
735
1002
 
736
1003
  function is_FLOW_INDICATOR(c) {
737
- return 0x2C/* , */ === c ||
738
- 0x5B/* [ */ === c ||
739
- 0x5D/* ] */ === c ||
740
- 0x7B/* { */ === c ||
741
- 0x7D/* } */ === c;
1004
+ return c === 0x2C/* , */ ||
1005
+ c === 0x5B/* [ */ ||
1006
+ c === 0x5D/* ] */ ||
1007
+ c === 0x7B/* { */ ||
1008
+ c === 0x7D/* } */;
742
1009
  }
743
1010
 
744
1011
  function fromHexCode(c) {
@@ -748,7 +1015,9 @@ function fromHexCode(c) {
748
1015
  return c - 0x30;
749
1016
  }
750
1017
 
1018
+ /*eslint-disable no-bitwise*/
751
1019
  lc = c | 0x20;
1020
+
752
1021
  if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
753
1022
  return lc - 0x61 + 10;
754
1023
  }
@@ -772,7 +1041,7 @@ function fromDecimalCode(c) {
772
1041
  }
773
1042
 
774
1043
  function simpleEscapeSequence(c) {
775
- return (c === 0x30/* 0 */) ? '\x00' :
1044
+ return (c === 0x30/* 0 */) ? '\x00' :
776
1045
  (c === 0x61/* a */) ? '\x07' :
777
1046
  (c === 0x62/* b */) ? '\x08' :
778
1047
  (c === 0x74/* t */) ? '\x09' :
@@ -795,12 +1064,11 @@ function simpleEscapeSequence(c) {
795
1064
  function charFromCodepoint(c) {
796
1065
  if (c <= 0xFFFF) {
797
1066
  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
1067
  }
1068
+ // Encode UTF-16 surrogate pair
1069
+ // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
1070
+ return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
1071
+ ((c - 0x010000) & 0x03FF) + 0xDC00);
804
1072
  }
805
1073
 
806
1074
  var simpleEscapeCheck = new Array(256); // integer, for fast access
@@ -818,6 +1086,8 @@ function State(input, options) {
818
1086
  this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
819
1087
  this.onWarning = options['onWarning'] || null;
820
1088
  this.legacy = options['legacy'] || false;
1089
+ this.json = options['json'] || false;
1090
+ this.listener = options['listener'] || null;
821
1091
 
822
1092
  this.implicitTypes = this.schema.compiledImplicit;
823
1093
  this.typeMap = this.schema.compiledTypeMap;
@@ -854,76 +1124,72 @@ function throwError(state, message) {
854
1124
  }
855
1125
 
856
1126
  function throwWarning(state, message) {
857
- var error = generateError(state, message);
858
-
859
1127
  if (state.onWarning) {
860
- state.onWarning.call(null, error);
861
- } else {
862
- throw error;
1128
+ state.onWarning.call(null, generateError(state, message));
863
1129
  }
864
1130
  }
865
1131
 
866
1132
 
867
1133
  var directiveHandlers = {
868
1134
 
869
- 'YAML': function handleYamlDirective(state, name, args) {
1135
+ YAML: function handleYamlDirective(state, name, args) {
870
1136
 
871
- var match, major, minor;
1137
+ var match, major, minor;
872
1138
 
873
- if (null !== state.version) {
874
- throwError(state, 'duplication of %YAML directive');
875
- }
1139
+ if (state.version !== null) {
1140
+ throwError(state, 'duplication of %YAML directive');
1141
+ }
876
1142
 
877
- if (1 !== args.length) {
878
- throwError(state, 'YAML directive accepts exactly one argument');
879
- }
1143
+ if (args.length !== 1) {
1144
+ throwError(state, 'YAML directive accepts exactly one argument');
1145
+ }
880
1146
 
881
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1147
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
882
1148
 
883
- if (null === match) {
884
- throwError(state, 'ill-formed argument of the YAML directive');
885
- }
1149
+ if (match === null) {
1150
+ throwError(state, 'ill-formed argument of the YAML directive');
1151
+ }
886
1152
 
887
- major = parseInt(match[1], 10);
888
- minor = parseInt(match[2], 10);
1153
+ major = parseInt(match[1], 10);
1154
+ minor = parseInt(match[2], 10);
889
1155
 
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);
1156
+ if (major !== 1) {
1157
+ throwError(state, 'unacceptable YAML version of the document');
1158
+ }
896
1159
 
897
- if (1 !== minor && 2 !== minor) {
898
- throwWarning(state, 'unsupported YAML version of the document');
899
- }
900
- },
1160
+ state.version = args[0];
1161
+ state.checkLineBreaks = (minor < 2);
901
1162
 
902
- 'TAG': function handleTagDirective(state, name, args) {
1163
+ if (minor !== 1 && minor !== 2) {
1164
+ throwWarning(state, 'unsupported YAML version of the document');
1165
+ }
1166
+ },
903
1167
 
904
- var handle, prefix;
1168
+ TAG: function handleTagDirective(state, name, args) {
905
1169
 
906
- if (2 !== args.length) {
907
- throwError(state, 'TAG directive accepts exactly two arguments');
908
- }
1170
+ var handle, prefix;
909
1171
 
910
- handle = args[0];
911
- prefix = args[1];
1172
+ if (args.length !== 2) {
1173
+ throwError(state, 'TAG directive accepts exactly two arguments');
1174
+ }
912
1175
 
913
- if (!PATTERN_TAG_HANDLE.test(handle)) {
914
- throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
915
- }
1176
+ handle = args[0];
1177
+ prefix = args[1];
916
1178
 
917
- if (_hasOwnProperty.call(state.tagMap, handle)) {
918
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
919
- }
1179
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
1180
+ throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
1181
+ }
920
1182
 
921
- if (!PATTERN_TAG_URI.test(prefix)) {
922
- throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
923
- }
1183
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
1184
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1185
+ }
924
1186
 
925
- state.tagMap[handle] = prefix;
1187
+ if (!PATTERN_TAG_URI.test(prefix)) {
1188
+ throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
926
1189
  }
1190
+
1191
+ state.tagMap[handle] = prefix;
1192
+ }
927
1193
  };
928
1194
 
929
1195
 
@@ -938,18 +1204,20 @@ function captureSegment(state, start, end, checkJson) {
938
1204
  _position < _length;
939
1205
  _position += 1) {
940
1206
  _character = _result.charCodeAt(_position);
941
- if (!(0x09 === _character ||
942
- 0x20 <= _character && _character <= 0x10FFFF)) {
1207
+ if (!(_character === 0x09 ||
1208
+ (0x20 <= _character && _character <= 0x10FFFF))) {
943
1209
  throwError(state, 'expected valid JSON character');
944
1210
  }
945
1211
  }
1212
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1213
+ throwError(state, 'the stream contains non-printable characters');
946
1214
  }
947
1215
 
948
1216
  state.result += _result;
949
1217
  }
950
1218
  }
951
1219
 
952
- function mergeMappings(state, destination, source) {
1220
+ function mergeMappings(state, destination, source, overridableKeys) {
953
1221
  var sourceKeys, key, index, quantity;
954
1222
 
955
1223
  if (!common.isObject(source)) {
@@ -963,29 +1231,36 @@ function mergeMappings(state, destination, source) {
963
1231
 
964
1232
  if (!_hasOwnProperty.call(destination, key)) {
965
1233
  destination[key] = source[key];
1234
+ overridableKeys[key] = true;
966
1235
  }
967
1236
  }
968
1237
  }
969
1238
 
970
- function storeMappingPair(state, _result, keyTag, keyNode, valueNode) {
1239
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) {
971
1240
  var index, quantity;
972
1241
 
973
1242
  keyNode = String(keyNode);
974
1243
 
975
- if (null === _result) {
1244
+ if (_result === null) {
976
1245
  _result = {};
977
1246
  }
978
1247
 
979
- if ('tag:yaml.org,2002:merge' === keyTag) {
1248
+ if (keyTag === 'tag:yaml.org,2002:merge') {
980
1249
  if (Array.isArray(valueNode)) {
981
1250
  for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
982
- mergeMappings(state, _result, valueNode[index]);
1251
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
983
1252
  }
984
1253
  } else {
985
- mergeMappings(state, _result, valueNode);
1254
+ mergeMappings(state, _result, valueNode, overridableKeys);
986
1255
  }
987
1256
  } else {
1257
+ if (!state.json &&
1258
+ !_hasOwnProperty.call(overridableKeys, keyNode) &&
1259
+ _hasOwnProperty.call(_result, keyNode)) {
1260
+ throwError(state, 'duplicated mapping key');
1261
+ }
988
1262
  _result[keyNode] = valueNode;
1263
+ delete overridableKeys[keyNode];
989
1264
  }
990
1265
 
991
1266
  return _result;
@@ -996,11 +1271,11 @@ function readLineBreak(state) {
996
1271
 
997
1272
  ch = state.input.charCodeAt(state.position);
998
1273
 
999
- if (0x0A/* LF */ === ch) {
1274
+ if (ch === 0x0A/* LF */) {
1000
1275
  state.position++;
1001
- } else if (0x0D/* CR */ === ch) {
1276
+ } else if (ch === 0x0D/* CR */) {
1002
1277
  state.position++;
1003
- if (0x0A/* LF */ === state.input.charCodeAt(state.position)) {
1278
+ if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
1004
1279
  state.position++;
1005
1280
  }
1006
1281
  } else {
@@ -1015,15 +1290,15 @@ function skipSeparationSpace(state, allowComments, checkIndent) {
1015
1290
  var lineBreaks = 0,
1016
1291
  ch = state.input.charCodeAt(state.position);
1017
1292
 
1018
- while (0 !== ch) {
1293
+ while (ch !== 0) {
1019
1294
  while (is_WHITE_SPACE(ch)) {
1020
1295
  ch = state.input.charCodeAt(++state.position);
1021
1296
  }
1022
1297
 
1023
- if (allowComments && 0x23/* # */ === ch) {
1298
+ if (allowComments && ch === 0x23/* # */) {
1024
1299
  do {
1025
1300
  ch = state.input.charCodeAt(++state.position);
1026
- } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && 0 !== ch);
1301
+ } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
1027
1302
  }
1028
1303
 
1029
1304
  if (is_EOL(ch)) {
@@ -1033,7 +1308,7 @@ function skipSeparationSpace(state, allowComments, checkIndent) {
1033
1308
  lineBreaks++;
1034
1309
  state.lineIndent = 0;
1035
1310
 
1036
- while (0x20/* Space */ === ch) {
1311
+ while (ch === 0x20/* Space */) {
1037
1312
  state.lineIndent++;
1038
1313
  ch = state.input.charCodeAt(++state.position);
1039
1314
  }
@@ -1042,7 +1317,7 @@ function skipSeparationSpace(state, allowComments, checkIndent) {
1042
1317
  }
1043
1318
  }
1044
1319
 
1045
- if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
1320
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1046
1321
  throwWarning(state, 'deficient indentation');
1047
1322
  }
1048
1323
 
@@ -1057,9 +1332,9 @@ function testDocumentSeparator(state) {
1057
1332
 
1058
1333
  // Condition state.position === state.lineStart is tested
1059
1334
  // 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) {
1335
+ if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
1336
+ ch === state.input.charCodeAt(_position + 1) &&
1337
+ ch === state.input.charCodeAt(_position + 2)) {
1063
1338
 
1064
1339
  _position += 3;
1065
1340
 
@@ -1074,7 +1349,7 @@ function testDocumentSeparator(state) {
1074
1349
  }
1075
1350
 
1076
1351
  function writeFoldedLines(state, count) {
1077
- if (1 === count) {
1352
+ if (count === 1) {
1078
1353
  state.result += ' ';
1079
1354
  } else if (count > 1) {
1080
1355
  state.result += common.repeat('\n', count - 1);
@@ -1097,23 +1372,23 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1097
1372
 
1098
1373
  ch = state.input.charCodeAt(state.position);
1099
1374
 
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) {
1375
+ if (is_WS_OR_EOL(ch) ||
1376
+ is_FLOW_INDICATOR(ch) ||
1377
+ ch === 0x23/* # */ ||
1378
+ ch === 0x26/* & */ ||
1379
+ ch === 0x2A/* * */ ||
1380
+ ch === 0x21/* ! */ ||
1381
+ ch === 0x7C/* | */ ||
1382
+ ch === 0x3E/* > */ ||
1383
+ ch === 0x27/* ' */ ||
1384
+ ch === 0x22/* " */ ||
1385
+ ch === 0x25/* % */ ||
1386
+ ch === 0x40/* @ */ ||
1387
+ ch === 0x60/* ` */) {
1113
1388
  return false;
1114
1389
  }
1115
1390
 
1116
- if (0x3F/* ? */ === ch || 0x2D/* - */ === ch) {
1391
+ if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
1117
1392
  following = state.input.charCodeAt(state.position + 1);
1118
1393
 
1119
1394
  if (is_WS_OR_EOL(following) ||
@@ -1127,16 +1402,16 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1127
1402
  captureStart = captureEnd = state.position;
1128
1403
  hasPendingContent = false;
1129
1404
 
1130
- while (0 !== ch) {
1131
- if (0x3A/* : */ === ch) {
1132
- following = state.input.charCodeAt(state.position+1);
1405
+ while (ch !== 0) {
1406
+ if (ch === 0x3A/* : */) {
1407
+ following = state.input.charCodeAt(state.position + 1);
1133
1408
 
1134
1409
  if (is_WS_OR_EOL(following) ||
1135
1410
  withinFlowCollection && is_FLOW_INDICATOR(following)) {
1136
1411
  break;
1137
1412
  }
1138
1413
 
1139
- } else if (0x23/* # */ === ch) {
1414
+ } else if (ch === 0x23/* # */) {
1140
1415
  preceding = state.input.charCodeAt(state.position - 1);
1141
1416
 
1142
1417
  if (is_WS_OR_EOL(preceding)) {
@@ -1184,11 +1459,11 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1184
1459
 
1185
1460
  if (state.result) {
1186
1461
  return true;
1187
- } else {
1188
- state.kind = _kind;
1189
- state.result = _result;
1190
- return false;
1191
1462
  }
1463
+
1464
+ state.kind = _kind;
1465
+ state.result = _result;
1466
+ return false;
1192
1467
  }
1193
1468
 
1194
1469
  function readSingleQuotedScalar(state, nodeIndent) {
@@ -1197,7 +1472,7 @@ function readSingleQuotedScalar(state, nodeIndent) {
1197
1472
 
1198
1473
  ch = state.input.charCodeAt(state.position);
1199
1474
 
1200
- if (0x27/* ' */ !== ch) {
1475
+ if (ch !== 0x27/* ' */) {
1201
1476
  return false;
1202
1477
  }
1203
1478
 
@@ -1206,12 +1481,12 @@ function readSingleQuotedScalar(state, nodeIndent) {
1206
1481
  state.position++;
1207
1482
  captureStart = captureEnd = state.position;
1208
1483
 
1209
- while (0 !== (ch = state.input.charCodeAt(state.position))) {
1210
- if (0x27/* ' */ === ch) {
1484
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1485
+ if (ch === 0x27/* ' */) {
1211
1486
  captureSegment(state, captureStart, state.position, true);
1212
1487
  ch = state.input.charCodeAt(++state.position);
1213
1488
 
1214
- if (0x27/* ' */ === ch) {
1489
+ if (ch === 0x27/* ' */) {
1215
1490
  captureStart = captureEnd = state.position;
1216
1491
  state.position++;
1217
1492
  } else {
@@ -1240,12 +1515,12 @@ function readDoubleQuotedScalar(state, nodeIndent) {
1240
1515
  captureEnd,
1241
1516
  hexLength,
1242
1517
  hexResult,
1243
- tmp, tmpEsc,
1518
+ tmp,
1244
1519
  ch;
1245
1520
 
1246
1521
  ch = state.input.charCodeAt(state.position);
1247
1522
 
1248
- if (0x22/* " */ !== ch) {
1523
+ if (ch !== 0x22/* " */) {
1249
1524
  return false;
1250
1525
  }
1251
1526
 
@@ -1254,20 +1529,20 @@ function readDoubleQuotedScalar(state, nodeIndent) {
1254
1529
  state.position++;
1255
1530
  captureStart = captureEnd = state.position;
1256
1531
 
1257
- while (0 !== (ch = state.input.charCodeAt(state.position))) {
1258
- if (0x22/* " */ === ch) {
1532
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1533
+ if (ch === 0x22/* " */) {
1259
1534
  captureSegment(state, captureStart, state.position, true);
1260
1535
  state.position++;
1261
1536
  return true;
1262
1537
 
1263
- } else if (0x5C/* \ */ === ch) {
1538
+ } else if (ch === 0x5C/* \ */) {
1264
1539
  captureSegment(state, captureStart, state.position, true);
1265
1540
  ch = state.input.charCodeAt(++state.position);
1266
1541
 
1267
1542
  if (is_EOL(ch)) {
1268
1543
  skipSeparationSpace(state, false, nodeIndent);
1269
1544
 
1270
- //TODO: rework to inline fn with no type cast?
1545
+ // TODO: rework to inline fn with no type cast?
1271
1546
  } else if (ch < 256 && simpleEscapeCheck[ch]) {
1272
1547
  state.result += simpleEscapeMap[ch];
1273
1548
  state.position++;
@@ -1325,6 +1600,7 @@ function readFlowCollection(state, nodeIndent) {
1325
1600
  isPair,
1326
1601
  isExplicitPair,
1327
1602
  isMapping,
1603
+ overridableKeys = {},
1328
1604
  keyNode,
1329
1605
  keyTag,
1330
1606
  valueNode,
@@ -1333,24 +1609,24 @@ function readFlowCollection(state, nodeIndent) {
1333
1609
  ch = state.input.charCodeAt(state.position);
1334
1610
 
1335
1611
  if (ch === 0x5B/* [ */) {
1336
- terminator = 0x5D/* ] */;
1612
+ terminator = 0x5D;/* ] */
1337
1613
  isMapping = false;
1338
1614
  _result = [];
1339
1615
  } else if (ch === 0x7B/* { */) {
1340
- terminator = 0x7D/* } */;
1616
+ terminator = 0x7D;/* } */
1341
1617
  isMapping = true;
1342
1618
  _result = {};
1343
1619
  } else {
1344
1620
  return false;
1345
1621
  }
1346
1622
 
1347
- if (null !== state.anchor) {
1623
+ if (state.anchor !== null) {
1348
1624
  state.anchorMap[state.anchor] = _result;
1349
1625
  }
1350
1626
 
1351
1627
  ch = state.input.charCodeAt(++state.position);
1352
1628
 
1353
- while (0 !== ch) {
1629
+ while (ch !== 0) {
1354
1630
  skipSeparationSpace(state, true, nodeIndent);
1355
1631
 
1356
1632
  ch = state.input.charCodeAt(state.position);
@@ -1369,7 +1645,7 @@ function readFlowCollection(state, nodeIndent) {
1369
1645
  keyTag = keyNode = valueNode = null;
1370
1646
  isPair = isExplicitPair = false;
1371
1647
 
1372
- if (0x3F/* ? */ === ch) {
1648
+ if (ch === 0x3F/* ? */) {
1373
1649
  following = state.input.charCodeAt(state.position + 1);
1374
1650
 
1375
1651
  if (is_WS_OR_EOL(following)) {
@@ -1387,7 +1663,7 @@ function readFlowCollection(state, nodeIndent) {
1387
1663
 
1388
1664
  ch = state.input.charCodeAt(state.position);
1389
1665
 
1390
- if ((isExplicitPair || state.line === _line) && 0x3A/* : */ === ch) {
1666
+ if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
1391
1667
  isPair = true;
1392
1668
  ch = state.input.charCodeAt(++state.position);
1393
1669
  skipSeparationSpace(state, true, nodeIndent);
@@ -1396,9 +1672,9 @@ function readFlowCollection(state, nodeIndent) {
1396
1672
  }
1397
1673
 
1398
1674
  if (isMapping) {
1399
- storeMappingPair(state, _result, keyTag, keyNode, valueNode);
1675
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1400
1676
  } else if (isPair) {
1401
- _result.push(storeMappingPair(state, null, keyTag, keyNode, valueNode));
1677
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
1402
1678
  } else {
1403
1679
  _result.push(keyNode);
1404
1680
  }
@@ -1407,7 +1683,7 @@ function readFlowCollection(state, nodeIndent) {
1407
1683
 
1408
1684
  ch = state.input.charCodeAt(state.position);
1409
1685
 
1410
- if (0x2C/* , */ === ch) {
1686
+ if (ch === 0x2C/* , */) {
1411
1687
  readNext = true;
1412
1688
  ch = state.input.charCodeAt(++state.position);
1413
1689
  } else {
@@ -1422,6 +1698,7 @@ function readBlockScalar(state, nodeIndent) {
1422
1698
  var captureStart,
1423
1699
  folding,
1424
1700
  chomping = CHOMPING_CLIP,
1701
+ didReadContent = false,
1425
1702
  detectedIndent = false,
1426
1703
  textIndent = nodeIndent,
1427
1704
  emptyLines = 0,
@@ -1442,12 +1719,12 @@ function readBlockScalar(state, nodeIndent) {
1442
1719
  state.kind = 'scalar';
1443
1720
  state.result = '';
1444
1721
 
1445
- while (0 !== ch) {
1722
+ while (ch !== 0) {
1446
1723
  ch = state.input.charCodeAt(++state.position);
1447
1724
 
1448
- if (0x2B/* + */ === ch || 0x2D/* - */ === ch) {
1725
+ if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
1449
1726
  if (CHOMPING_CLIP === chomping) {
1450
- chomping = (0x2B/* + */ === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
1727
+ chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
1451
1728
  } else {
1452
1729
  throwError(state, 'repeat of a chomping mode identifier');
1453
1730
  }
@@ -1471,20 +1748,20 @@ function readBlockScalar(state, nodeIndent) {
1471
1748
  do { ch = state.input.charCodeAt(++state.position); }
1472
1749
  while (is_WHITE_SPACE(ch));
1473
1750
 
1474
- if (0x23/* # */ === ch) {
1751
+ if (ch === 0x23/* # */) {
1475
1752
  do { ch = state.input.charCodeAt(++state.position); }
1476
- while (!is_EOL(ch) && (0 !== ch));
1753
+ while (!is_EOL(ch) && (ch !== 0));
1477
1754
  }
1478
1755
  }
1479
1756
 
1480
- while (0 !== ch) {
1757
+ while (ch !== 0) {
1481
1758
  readLineBreak(state);
1482
1759
  state.lineIndent = 0;
1483
1760
 
1484
1761
  ch = state.input.charCodeAt(state.position);
1485
1762
 
1486
1763
  while ((!detectedIndent || state.lineIndent < textIndent) &&
1487
- (0x20/* Space */ === ch)) {
1764
+ (ch === 0x20/* Space */)) {
1488
1765
  state.lineIndent++;
1489
1766
  ch = state.input.charCodeAt(++state.position);
1490
1767
  }
@@ -1503,9 +1780,9 @@ function readBlockScalar(state, nodeIndent) {
1503
1780
 
1504
1781
  // Perform the chomping.
1505
1782
  if (chomping === CHOMPING_KEEP) {
1506
- state.result += common.repeat('\n', emptyLines);
1783
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1507
1784
  } else if (chomping === CHOMPING_CLIP) {
1508
- if (detectedIndent) { // i.e. only if the scalar is not empty.
1785
+ if (didReadContent) { // i.e. only if the scalar is not empty.
1509
1786
  state.result += '\n';
1510
1787
  }
1511
1788
  }
@@ -1520,7 +1797,8 @@ function readBlockScalar(state, nodeIndent) {
1520
1797
  // Lines starting with white space characters (more-indented lines) are not folded.
1521
1798
  if (is_WHITE_SPACE(ch)) {
1522
1799
  atMoreIndented = true;
1523
- state.result += common.repeat('\n', emptyLines + 1);
1800
+ // except for the first content line (cf. Example 8.1)
1801
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1524
1802
 
1525
1803
  // End of more-indented block.
1526
1804
  } else if (atMoreIndented) {
@@ -1528,8 +1806,8 @@ function readBlockScalar(state, nodeIndent) {
1528
1806
  state.result += common.repeat('\n', emptyLines + 1);
1529
1807
 
1530
1808
  // 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.
1809
+ } else if (emptyLines === 0) {
1810
+ if (didReadContent) { // i.e. only if we have already read some scalar content.
1533
1811
  state.result += ' ';
1534
1812
  }
1535
1813
 
@@ -1540,23 +1818,18 @@ function readBlockScalar(state, nodeIndent) {
1540
1818
 
1541
1819
  // Literal style: just add exact number of line breaks between content lines.
1542
1820
  } 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
- }
1821
+ // Keep all line breaks except the header line break.
1822
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1552
1823
  }
1553
1824
 
1825
+ didReadContent = true;
1554
1826
  detectedIndent = true;
1555
1827
  emptyLines = 0;
1556
1828
  captureStart = state.position;
1557
1829
 
1558
- while (!is_EOL(ch) && (0 !== ch))
1559
- { ch = state.input.charCodeAt(++state.position); }
1830
+ while (!is_EOL(ch) && (ch !== 0)) {
1831
+ ch = state.input.charCodeAt(++state.position);
1832
+ }
1560
1833
 
1561
1834
  captureSegment(state, captureStart, state.position, false);
1562
1835
  }
@@ -1573,15 +1846,15 @@ function readBlockSequence(state, nodeIndent) {
1573
1846
  detected = false,
1574
1847
  ch;
1575
1848
 
1576
- if (null !== state.anchor) {
1849
+ if (state.anchor !== null) {
1577
1850
  state.anchorMap[state.anchor] = _result;
1578
1851
  }
1579
1852
 
1580
1853
  ch = state.input.charCodeAt(state.position);
1581
1854
 
1582
- while (0 !== ch) {
1855
+ while (ch !== 0) {
1583
1856
 
1584
- if (0x2D/* - */ !== ch) {
1857
+ if (ch !== 0x2D/* - */) {
1585
1858
  break;
1586
1859
  }
1587
1860
 
@@ -1609,7 +1882,7 @@ function readBlockSequence(state, nodeIndent) {
1609
1882
 
1610
1883
  ch = state.input.charCodeAt(state.position);
1611
1884
 
1612
- if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
1885
+ if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
1613
1886
  throwError(state, 'bad indentation of a sequence entry');
1614
1887
  } else if (state.lineIndent < nodeIndent) {
1615
1888
  break;
@@ -1622,9 +1895,8 @@ function readBlockSequence(state, nodeIndent) {
1622
1895
  state.kind = 'sequence';
1623
1896
  state.result = _result;
1624
1897
  return true;
1625
- } else {
1626
- return false;
1627
1898
  }
1899
+ return false;
1628
1900
  }
1629
1901
 
1630
1902
  function readBlockMapping(state, nodeIndent, flowIndent) {
@@ -1634,6 +1906,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1634
1906
  _tag = state.tag,
1635
1907
  _anchor = state.anchor,
1636
1908
  _result = {},
1909
+ overridableKeys = {},
1637
1910
  keyTag = null,
1638
1911
  keyNode = null,
1639
1912
  valueNode = null,
@@ -1641,13 +1914,13 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1641
1914
  detected = false,
1642
1915
  ch;
1643
1916
 
1644
- if (null !== state.anchor) {
1917
+ if (state.anchor !== null) {
1645
1918
  state.anchorMap[state.anchor] = _result;
1646
1919
  }
1647
1920
 
1648
1921
  ch = state.input.charCodeAt(state.position);
1649
1922
 
1650
- while (0 !== ch) {
1923
+ while (ch !== 0) {
1651
1924
  following = state.input.charCodeAt(state.position + 1);
1652
1925
  _line = state.line; // Save the current line.
1653
1926
 
@@ -1655,11 +1928,11 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1655
1928
  // Explicit notation case. There are two separate blocks:
1656
1929
  // first for the key (denoted by "?") and second for the value (denoted by ":")
1657
1930
  //
1658
- if ((0x3F/* ? */ === ch || 0x3A/* : */ === ch) && is_WS_OR_EOL(following)) {
1931
+ if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
1659
1932
 
1660
- if (0x3F/* ? */ === ch) {
1933
+ if (ch === 0x3F/* ? */) {
1661
1934
  if (atExplicitKey) {
1662
- storeMappingPair(state, _result, keyTag, keyNode, null);
1935
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1663
1936
  keyTag = keyNode = valueNode = null;
1664
1937
  }
1665
1938
 
@@ -1691,7 +1964,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1691
1964
  ch = state.input.charCodeAt(++state.position);
1692
1965
  }
1693
1966
 
1694
- if (0x3A/* : */ === ch) {
1967
+ if (ch === 0x3A/* : */) {
1695
1968
  ch = state.input.charCodeAt(++state.position);
1696
1969
 
1697
1970
  if (!is_WS_OR_EOL(ch)) {
@@ -1699,7 +1972,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1699
1972
  }
1700
1973
 
1701
1974
  if (atExplicitKey) {
1702
- storeMappingPair(state, _result, keyTag, keyNode, null);
1975
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1703
1976
  keyTag = keyNode = valueNode = null;
1704
1977
  }
1705
1978
 
@@ -1744,7 +2017,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1744
2017
  }
1745
2018
 
1746
2019
  if (!atExplicitKey) {
1747
- storeMappingPair(state, _result, keyTag, keyNode, valueNode);
2020
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1748
2021
  keyTag = keyNode = valueNode = null;
1749
2022
  }
1750
2023
 
@@ -1752,7 +2025,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1752
2025
  ch = state.input.charCodeAt(state.position);
1753
2026
  }
1754
2027
 
1755
- if (state.lineIndent > nodeIndent && (0 !== ch)) {
2028
+ if (state.lineIndent > nodeIndent && (ch !== 0)) {
1756
2029
  throwError(state, 'bad indentation of a mapping entry');
1757
2030
  } else if (state.lineIndent < nodeIndent) {
1758
2031
  break;
@@ -1765,7 +2038,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
1765
2038
 
1766
2039
  // Special case: last mapping's node contains only the key in explicit notation.
1767
2040
  if (atExplicitKey) {
1768
- storeMappingPair(state, _result, keyTag, keyNode, null);
2041
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1769
2042
  }
1770
2043
 
1771
2044
  // Expose the resulting mapping.
@@ -1789,21 +2062,19 @@ function readTagProperty(state) {
1789
2062
 
1790
2063
  ch = state.input.charCodeAt(state.position);
1791
2064
 
1792
- if (0x21/* ! */ !== ch) {
1793
- return false;
1794
- }
2065
+ if (ch !== 0x21/* ! */) return false;
1795
2066
 
1796
- if (null !== state.tag) {
2067
+ if (state.tag !== null) {
1797
2068
  throwError(state, 'duplication of a tag property');
1798
2069
  }
1799
2070
 
1800
2071
  ch = state.input.charCodeAt(++state.position);
1801
2072
 
1802
- if (0x3C/* < */ === ch) {
2073
+ if (ch === 0x3C/* < */) {
1803
2074
  isVerbatim = true;
1804
2075
  ch = state.input.charCodeAt(++state.position);
1805
2076
 
1806
- } else if (0x21/* ! */ === ch) {
2077
+ } else if (ch === 0x21/* ! */) {
1807
2078
  isNamed = true;
1808
2079
  tagHandle = '!!';
1809
2080
  ch = state.input.charCodeAt(++state.position);
@@ -1816,7 +2087,7 @@ function readTagProperty(state) {
1816
2087
 
1817
2088
  if (isVerbatim) {
1818
2089
  do { ch = state.input.charCodeAt(++state.position); }
1819
- while (0 !== ch && 0x3E/* > */ !== ch);
2090
+ while (ch !== 0 && ch !== 0x3E/* > */);
1820
2091
 
1821
2092
  if (state.position < state.length) {
1822
2093
  tagName = state.input.slice(_position, state.position);
@@ -1825,9 +2096,9 @@ function readTagProperty(state) {
1825
2096
  throwError(state, 'unexpected end of the stream within a verbatim tag');
1826
2097
  }
1827
2098
  } else {
1828
- while (0 !== ch && !is_WS_OR_EOL(ch)) {
2099
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1829
2100
 
1830
- if (0x21/* ! */ === ch) {
2101
+ if (ch === 0x21/* ! */) {
1831
2102
  if (!isNamed) {
1832
2103
  tagHandle = state.input.slice(_position - 1, state.position + 1);
1833
2104
 
@@ -1862,10 +2133,10 @@ function readTagProperty(state) {
1862
2133
  } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
1863
2134
  state.tag = state.tagMap[tagHandle] + tagName;
1864
2135
 
1865
- } else if ('!' === tagHandle) {
2136
+ } else if (tagHandle === '!') {
1866
2137
  state.tag = '!' + tagName;
1867
2138
 
1868
- } else if ('!!' === tagHandle) {
2139
+ } else if (tagHandle === '!!') {
1869
2140
  state.tag = 'tag:yaml.org,2002:' + tagName;
1870
2141
 
1871
2142
  } else {
@@ -1881,18 +2152,16 @@ function readAnchorProperty(state) {
1881
2152
 
1882
2153
  ch = state.input.charCodeAt(state.position);
1883
2154
 
1884
- if (0x26/* & */ !== ch) {
1885
- return false;
1886
- }
2155
+ if (ch !== 0x26/* & */) return false;
1887
2156
 
1888
- if (null !== state.anchor) {
2157
+ if (state.anchor !== null) {
1889
2158
  throwError(state, 'duplication of an anchor property');
1890
2159
  }
1891
2160
 
1892
2161
  ch = state.input.charCodeAt(++state.position);
1893
2162
  _position = state.position;
1894
2163
 
1895
- while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2164
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1896
2165
  ch = state.input.charCodeAt(++state.position);
1897
2166
  }
1898
2167
 
@@ -1906,20 +2175,16 @@ function readAnchorProperty(state) {
1906
2175
 
1907
2176
  function readAlias(state) {
1908
2177
  var _position, alias,
1909
- len = state.length,
1910
- input = state.input,
1911
2178
  ch;
1912
2179
 
1913
2180
  ch = state.input.charCodeAt(state.position);
1914
2181
 
1915
- if (0x2A/* * */ !== ch) {
1916
- return false;
1917
- }
2182
+ if (ch !== 0x2A/* * */) return false;
1918
2183
 
1919
2184
  ch = state.input.charCodeAt(++state.position);
1920
2185
  _position = state.position;
1921
2186
 
1922
- while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2187
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1923
2188
  ch = state.input.charCodeAt(++state.position);
1924
2189
  }
1925
2190
 
@@ -1949,8 +2214,11 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
1949
2214
  typeQuantity,
1950
2215
  type,
1951
2216
  flowIndent,
1952
- blockIndent,
1953
- _result;
2217
+ blockIndent;
2218
+
2219
+ if (state.listener !== null) {
2220
+ state.listener('open', state);
2221
+ }
1954
2222
 
1955
2223
  state.tag = null;
1956
2224
  state.anchor = null;
@@ -1975,7 +2243,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
1975
2243
  }
1976
2244
  }
1977
2245
 
1978
- if (1 === indentStatus) {
2246
+ if (indentStatus === 1) {
1979
2247
  while (readTagProperty(state) || readAnchorProperty(state)) {
1980
2248
  if (skipSeparationSpace(state, true, -1)) {
1981
2249
  atNewLine = true;
@@ -1998,7 +2266,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
1998
2266
  allowBlockCollections = atNewLine || allowCompact;
1999
2267
  }
2000
2268
 
2001
- if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
2269
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2002
2270
  if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2003
2271
  flowIndent = parentIndent;
2004
2272
  } else {
@@ -2007,7 +2275,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2007
2275
 
2008
2276
  blockIndent = state.position - state.lineStart;
2009
2277
 
2010
- if (1 === indentStatus) {
2278
+ if (indentStatus === 1) {
2011
2279
  if (allowBlockCollections &&
2012
2280
  (readBlockSequence(state, blockIndent) ||
2013
2281
  readBlockMapping(state, blockIndent, flowIndent)) ||
@@ -2022,31 +2290,31 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2022
2290
  } else if (readAlias(state)) {
2023
2291
  hasContent = true;
2024
2292
 
2025
- if (null !== state.tag || null !== state.anchor) {
2293
+ if (state.tag !== null || state.anchor !== null) {
2026
2294
  throwError(state, 'alias node should not have any properties');
2027
2295
  }
2028
2296
 
2029
2297
  } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2030
2298
  hasContent = true;
2031
2299
 
2032
- if (null === state.tag) {
2300
+ if (state.tag === null) {
2033
2301
  state.tag = '?';
2034
2302
  }
2035
2303
  }
2036
2304
 
2037
- if (null !== state.anchor) {
2305
+ if (state.anchor !== null) {
2038
2306
  state.anchorMap[state.anchor] = state.result;
2039
2307
  }
2040
2308
  }
2041
- } else if (0 === indentStatus) {
2309
+ } else if (indentStatus === 0) {
2042
2310
  // Special case: block sequences are allowed to have same indentation level as the parent.
2043
2311
  // http://www.yaml.org/spec/1.2/spec.html#id2799784
2044
2312
  hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2045
2313
  }
2046
2314
  }
2047
2315
 
2048
- if (null !== state.tag && '!' !== state.tag) {
2049
- if ('?' === state.tag) {
2316
+ if (state.tag !== null && state.tag !== '!') {
2317
+ if (state.tag === '?') {
2050
2318
  for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
2051
2319
  typeIndex < typeQuantity;
2052
2320
  typeIndex += 1) {
@@ -2059,7 +2327,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2059
2327
  if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
2060
2328
  state.result = type.construct(state.result);
2061
2329
  state.tag = type.tag;
2062
- if (null !== state.anchor) {
2330
+ if (state.anchor !== null) {
2063
2331
  state.anchorMap[state.anchor] = state.result;
2064
2332
  }
2065
2333
  break;
@@ -2068,7 +2336,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2068
2336
  } else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
2069
2337
  type = state.typeMap[state.tag];
2070
2338
 
2071
- if (null !== state.result && type.kind !== state.kind) {
2339
+ if (state.result !== null && type.kind !== state.kind) {
2072
2340
  throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2073
2341
  }
2074
2342
 
@@ -2076,16 +2344,19 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2076
2344
  throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
2077
2345
  } else {
2078
2346
  state.result = type.construct(state.result);
2079
- if (null !== state.anchor) {
2347
+ if (state.anchor !== null) {
2080
2348
  state.anchorMap[state.anchor] = state.result;
2081
2349
  }
2082
2350
  }
2083
2351
  } else {
2084
- throwWarning(state, 'unknown tag !<' + state.tag + '>');
2352
+ throwError(state, 'unknown tag !<' + state.tag + '>');
2085
2353
  }
2086
2354
  }
2087
2355
 
2088
- return null !== state.tag || null !== state.anchor || hasContent;
2356
+ if (state.listener !== null) {
2357
+ state.listener('close', state);
2358
+ }
2359
+ return state.tag !== null || state.anchor !== null || hasContent;
2089
2360
  }
2090
2361
 
2091
2362
  function readDocument(state) {
@@ -2101,12 +2372,12 @@ function readDocument(state) {
2101
2372
  state.tagMap = {};
2102
2373
  state.anchorMap = {};
2103
2374
 
2104
- while (0 !== (ch = state.input.charCodeAt(state.position))) {
2375
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2105
2376
  skipSeparationSpace(state, true, -1);
2106
2377
 
2107
2378
  ch = state.input.charCodeAt(state.position);
2108
2379
 
2109
- if (state.lineIndent > 0 || 0x25/* % */ !== ch) {
2380
+ if (state.lineIndent > 0 || ch !== 0x25/* % */) {
2110
2381
  break;
2111
2382
  }
2112
2383
 
@@ -2114,7 +2385,7 @@ function readDocument(state) {
2114
2385
  ch = state.input.charCodeAt(++state.position);
2115
2386
  _position = state.position;
2116
2387
 
2117
- while (0 !== ch && !is_WS_OR_EOL(ch)) {
2388
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2118
2389
  ch = state.input.charCodeAt(++state.position);
2119
2390
  }
2120
2391
 
@@ -2125,33 +2396,29 @@ function readDocument(state) {
2125
2396
  throwError(state, 'directive name must not be less than one character in length');
2126
2397
  }
2127
2398
 
2128
- while (0 !== ch) {
2399
+ while (ch !== 0) {
2129
2400
  while (is_WHITE_SPACE(ch)) {
2130
2401
  ch = state.input.charCodeAt(++state.position);
2131
2402
  }
2132
2403
 
2133
- if (0x23/* # */ === ch) {
2404
+ if (ch === 0x23/* # */) {
2134
2405
  do { ch = state.input.charCodeAt(++state.position); }
2135
- while (0 !== ch && !is_EOL(ch));
2406
+ while (ch !== 0 && !is_EOL(ch));
2136
2407
  break;
2137
2408
  }
2138
2409
 
2139
- if (is_EOL(ch)) {
2140
- break;
2141
- }
2410
+ if (is_EOL(ch)) break;
2142
2411
 
2143
2412
  _position = state.position;
2144
2413
 
2145
- while (0 !== ch && !is_WS_OR_EOL(ch)) {
2414
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2146
2415
  ch = state.input.charCodeAt(++state.position);
2147
2416
  }
2148
2417
 
2149
2418
  directiveArgs.push(state.input.slice(_position, state.position));
2150
2419
  }
2151
2420
 
2152
- if (0 !== ch) {
2153
- readLineBreak(state);
2154
- }
2421
+ if (ch !== 0) readLineBreak(state);
2155
2422
 
2156
2423
  if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2157
2424
  directiveHandlers[directiveName](state, directiveName, directiveArgs);
@@ -2162,10 +2429,10 @@ function readDocument(state) {
2162
2429
 
2163
2430
  skipSeparationSpace(state, true, -1);
2164
2431
 
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)) {
2432
+ if (state.lineIndent === 0 &&
2433
+ state.input.charCodeAt(state.position) === 0x2D/* - */ &&
2434
+ state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
2435
+ state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
2169
2436
  state.position += 3;
2170
2437
  skipSeparationSpace(state, true, -1);
2171
2438
 
@@ -2185,7 +2452,7 @@ function readDocument(state) {
2185
2452
 
2186
2453
  if (state.position === state.lineStart && testDocumentSeparator(state)) {
2187
2454
 
2188
- if (0x2E/* . */ === state.input.charCodeAt(state.position)) {
2455
+ if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
2189
2456
  state.position += 3;
2190
2457
  skipSeparationSpace(state, true, -1);
2191
2458
  }
@@ -2204,22 +2471,26 @@ function loadDocuments(input, options) {
2204
2471
  input = String(input);
2205
2472
  options = options || {};
2206
2473
 
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
- }
2474
+ if (input.length !== 0) {
2212
2475
 
2213
- var state = new State(input, options);
2476
+ // Add tailing `\n` if not exists
2477
+ if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
2478
+ input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
2479
+ input += '\n';
2480
+ }
2214
2481
 
2215
- if (PATTERN_NON_PRINTABLE.test(state.input)) {
2216
- throwError(state, 'the stream contains non-printable characters');
2482
+ // Strip BOM
2483
+ if (input.charCodeAt(0) === 0xFEFF) {
2484
+ input = input.slice(1);
2485
+ }
2217
2486
  }
2218
2487
 
2488
+ var state = new State(input, options);
2489
+
2219
2490
  // Use 0 as string terminator. That significantly simplifies bounds check.
2220
2491
  state.input += '\0';
2221
2492
 
2222
- while (0x20/* Space */ === state.input.charCodeAt(state.position)) {
2493
+ while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
2223
2494
  state.lineIndent += 1;
2224
2495
  state.position += 1;
2225
2496
  }
@@ -2242,15 +2513,15 @@ function loadAll(input, iterator, options) {
2242
2513
 
2243
2514
 
2244
2515
  function load(input, options) {
2245
- var documents = loadDocuments(input, options), index, length;
2516
+ var documents = loadDocuments(input, options);
2246
2517
 
2247
- if (0 === documents.length) {
2518
+ if (documents.length === 0) {
2519
+ /*eslint-disable no-undefined*/
2248
2520
  return undefined;
2249
- } else if (1 === documents.length) {
2521
+ } else if (documents.length === 1) {
2250
2522
  return documents[0];
2251
- } else {
2252
- throw new YAMLException('expected a single document in the stream, but found more');
2253
2523
  }
2524
+ throw new YAMLException('expected a single document in the stream, but found more');
2254
2525
  }
2255
2526
 
2256
2527
 
@@ -2288,9 +2559,7 @@ function Mark(name, buffer, position, line, column) {
2288
2559
  Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2289
2560
  var head, start, tail, end, snippet;
2290
2561
 
2291
- if (!this.buffer) {
2292
- return null;
2293
- }
2562
+ if (!this.buffer) return null;
2294
2563
 
2295
2564
  indent = indent || 4;
2296
2565
  maxLength = maxLength || 75;
@@ -2298,7 +2567,7 @@ Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2298
2567
  head = '';
2299
2568
  start = this.position;
2300
2569
 
2301
- while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
2570
+ while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
2302
2571
  start -= 1;
2303
2572
  if (this.position - start > (maxLength / 2 - 1)) {
2304
2573
  head = ' ... ';
@@ -2310,7 +2579,7 @@ Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2310
2579
  tail = '';
2311
2580
  end = this.position;
2312
2581
 
2313
- while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
2582
+ while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
2314
2583
  end += 1;
2315
2584
  if (end - this.position > (maxLength / 2 - 1)) {
2316
2585
  tail = ' ... ';
@@ -2352,6 +2621,7 @@ module.exports = Mark;
2352
2621
  },{"./common":2}],7:[function(require,module,exports){
2353
2622
  'use strict';
2354
2623
 
2624
+ /*eslint-disable max-len*/
2355
2625
 
2356
2626
  var common = require('./common');
2357
2627
  var YAMLException = require('./exception');
@@ -2376,7 +2646,7 @@ function compileList(schema, name, result) {
2376
2646
  });
2377
2647
 
2378
2648
  return result.filter(function (type, index) {
2379
- return -1 === exclude.indexOf(index);
2649
+ return exclude.indexOf(index) === -1;
2380
2650
  });
2381
2651
  }
2382
2652
 
@@ -2402,7 +2672,7 @@ function Schema(definition) {
2402
2672
  this.explicit = definition.explicit || [];
2403
2673
 
2404
2674
  this.implicit.forEach(function (type) {
2405
- if (type.loadKind && 'scalar' !== type.loadKind) {
2675
+ if (type.loadKind && type.loadKind !== 'scalar') {
2406
2676
  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
2677
  }
2408
2678
  });
@@ -2420,18 +2690,18 @@ Schema.create = function createSchema() {
2420
2690
  var schemas, types;
2421
2691
 
2422
2692
  switch (arguments.length) {
2423
- case 1:
2424
- schemas = Schema.DEFAULT;
2425
- types = arguments[0];
2426
- break;
2693
+ case 1:
2694
+ schemas = Schema.DEFAULT;
2695
+ types = arguments[0];
2696
+ break;
2427
2697
 
2428
- case 2:
2429
- schemas = arguments[0];
2430
- types = arguments[1];
2431
- break;
2698
+ case 2:
2699
+ schemas = arguments[0];
2700
+ types = arguments[1];
2701
+ break;
2432
2702
 
2433
- default:
2434
- throw new YAMLException('Wrong number of arguments for Schema.create function');
2703
+ default:
2704
+ throw new YAMLException('Wrong number of arguments for Schema.create function');
2435
2705
  }
2436
2706
 
2437
2707
  schemas = common.toArray(schemas);
@@ -2602,7 +2872,7 @@ var YAML_NODE_KINDS = [
2602
2872
  function compileStyleAliases(map) {
2603
2873
  var result = {};
2604
2874
 
2605
- if (null !== map) {
2875
+ if (map !== null) {
2606
2876
  Object.keys(map).forEach(function (style) {
2607
2877
  map[style].forEach(function (alias) {
2608
2878
  result[String(alias)] = style;
@@ -2617,7 +2887,7 @@ function Type(tag, options) {
2617
2887
  options = options || {};
2618
2888
 
2619
2889
  Object.keys(options).forEach(function (name) {
2620
- if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
2890
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
2621
2891
  throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
2622
2892
  }
2623
2893
  });
@@ -2633,7 +2903,7 @@ function Type(tag, options) {
2633
2903
  this.defaultStyle = options['defaultStyle'] || null;
2634
2904
  this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
2635
2905
 
2636
- if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
2906
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
2637
2907
  throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
2638
2908
  }
2639
2909
  }
@@ -2643,10 +2913,16 @@ module.exports = Type;
2643
2913
  },{"./exception":4}],14:[function(require,module,exports){
2644
2914
  'use strict';
2645
2915
 
2916
+ /*eslint-disable no-bitwise*/
2917
+
2918
+ var NodeBuffer;
2919
+
2920
+ try {
2921
+ // A trick for browserified version, to not include `Buffer` shim
2922
+ var _require = require;
2923
+ NodeBuffer = _require('buffer').Buffer;
2924
+ } catch (__) {}
2646
2925
 
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
2926
  var Type = require('../type');
2651
2927
 
2652
2928
 
@@ -2655,21 +2931,19 @@ var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
2655
2931
 
2656
2932
 
2657
2933
  function resolveYamlBinary(data) {
2658
- if (null === data) {
2659
- return false;
2660
- }
2934
+ if (data === null) return false;
2661
2935
 
2662
- var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
2936
+ var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
2663
2937
 
2664
2938
  // Convert one by one.
2665
- for (idx = 0; idx < max; idx ++) {
2939
+ for (idx = 0; idx < max; idx++) {
2666
2940
  code = map.indexOf(data.charAt(idx));
2667
2941
 
2668
2942
  // Skip CR/LF
2669
- if (code > 64) { continue; }
2943
+ if (code > 64) continue;
2670
2944
 
2671
2945
  // Fail on illegal characters
2672
- if (code < 0) { return false; }
2946
+ if (code < 0) return false;
2673
2947
 
2674
2948
  bitlen += 6;
2675
2949
  }
@@ -2679,7 +2953,7 @@ function resolveYamlBinary(data) {
2679
2953
  }
2680
2954
 
2681
2955
  function constructYamlBinary(data) {
2682
- var code, idx, tailbits,
2956
+ var idx, tailbits,
2683
2957
  input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
2684
2958
  max = input.length,
2685
2959
  map = BASE64_MAP,
@@ -2700,7 +2974,7 @@ function constructYamlBinary(data) {
2700
2974
 
2701
2975
  // Dump tail
2702
2976
 
2703
- tailbits = (max % 4)*6;
2977
+ tailbits = (max % 4) * 6;
2704
2978
 
2705
2979
  if (tailbits === 0) {
2706
2980
  result.push((bits >> 16) & 0xFF);
@@ -2714,9 +2988,7 @@ function constructYamlBinary(data) {
2714
2988
  }
2715
2989
 
2716
2990
  // Wrap into Buffer for NodeJS and leave Array for browser
2717
- if (NodeBuffer) {
2718
- return new NodeBuffer(result);
2719
- }
2991
+ if (NodeBuffer) return new NodeBuffer(result);
2720
2992
 
2721
2993
  return result;
2722
2994
  }
@@ -2775,15 +3047,13 @@ module.exports = new Type('tag:yaml.org,2002:binary', {
2775
3047
  represent: representYamlBinary
2776
3048
  });
2777
3049
 
2778
- },{"../type":13,"buffer":30}],15:[function(require,module,exports){
3050
+ },{"../type":13}],15:[function(require,module,exports){
2779
3051
  'use strict';
2780
3052
 
2781
3053
  var Type = require('../type');
2782
3054
 
2783
3055
  function resolveYamlBoolean(data) {
2784
- if (null === data) {
2785
- return false;
2786
- }
3056
+ if (data === null) return false;
2787
3057
 
2788
3058
  var max = data.length;
2789
3059
 
@@ -2798,7 +3068,7 @@ function constructYamlBoolean(data) {
2798
3068
  }
2799
3069
 
2800
3070
  function isBoolean(object) {
2801
- return '[object Boolean]' === Object.prototype.toString.call(object);
3071
+ return Object.prototype.toString.call(object) === '[object Boolean]';
2802
3072
  }
2803
3073
 
2804
3074
  module.exports = new Type('tag:yaml.org,2002:bool', {
@@ -2828,15 +3098,10 @@ var YAML_FLOAT_PATTERN = new RegExp(
2828
3098
  '|\\.(?:nan|NaN|NAN))$');
2829
3099
 
2830
3100
  function resolveYamlFloat(data) {
2831
- if (null === data) {
2832
- return false;
2833
- }
3101
+ if (data === null) return false;
2834
3102
 
2835
- var value, sign, base, digits;
3103
+ if (!YAML_FLOAT_PATTERN.test(data)) return false;
2836
3104
 
2837
- if (!YAML_FLOAT_PATTERN.test(data)) {
2838
- return false;
2839
- }
2840
3105
  return true;
2841
3106
  }
2842
3107
 
@@ -2844,20 +3109,20 @@ function constructYamlFloat(data) {
2844
3109
  var value, sign, base, digits;
2845
3110
 
2846
3111
  value = data.replace(/_/g, '').toLowerCase();
2847
- sign = '-' === value[0] ? -1 : 1;
3112
+ sign = value[0] === '-' ? -1 : 1;
2848
3113
  digits = [];
2849
3114
 
2850
- if (0 <= '+-'.indexOf(value[0])) {
3115
+ if ('+-'.indexOf(value[0]) >= 0) {
2851
3116
  value = value.slice(1);
2852
3117
  }
2853
3118
 
2854
- if ('.inf' === value) {
2855
- return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3119
+ if (value === '.inf') {
3120
+ return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
2856
3121
 
2857
- } else if ('.nan' === value) {
3122
+ } else if (value === '.nan') {
2858
3123
  return NaN;
2859
3124
 
2860
- } else if (0 <= value.indexOf(':')) {
3125
+ } else if (value.indexOf(':') >= 0) {
2861
3126
  value.split(':').forEach(function (v) {
2862
3127
  digits.unshift(parseFloat(v, 10));
2863
3128
  });
@@ -2872,49 +3137,49 @@ function constructYamlFloat(data) {
2872
3137
 
2873
3138
  return sign * value;
2874
3139
 
2875
- } else {
2876
- return sign * parseFloat(value, 10);
2877
3140
  }
3141
+ return sign * parseFloat(value, 10);
2878
3142
  }
2879
3143
 
3144
+
3145
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
3146
+
2880
3147
  function representYamlFloat(object, style) {
3148
+ var res;
3149
+
2881
3150
  if (isNaN(object)) {
2882
3151
  switch (style) {
2883
- case 'lowercase':
2884
- return '.nan';
2885
- case 'uppercase':
2886
- return '.NAN';
2887
- case 'camelcase':
2888
- return '.NaN';
3152
+ case 'lowercase': return '.nan';
3153
+ case 'uppercase': return '.NAN';
3154
+ case 'camelcase': return '.NaN';
2889
3155
  }
2890
3156
  } else if (Number.POSITIVE_INFINITY === object) {
2891
3157
  switch (style) {
2892
- case 'lowercase':
2893
- return '.inf';
2894
- case 'uppercase':
2895
- return '.INF';
2896
- case 'camelcase':
2897
- return '.Inf';
3158
+ case 'lowercase': return '.inf';
3159
+ case 'uppercase': return '.INF';
3160
+ case 'camelcase': return '.Inf';
2898
3161
  }
2899
3162
  } else if (Number.NEGATIVE_INFINITY === object) {
2900
3163
  switch (style) {
2901
- case 'lowercase':
2902
- return '-.inf';
2903
- case 'uppercase':
2904
- return '-.INF';
2905
- case 'camelcase':
2906
- return '-.Inf';
3164
+ case 'lowercase': return '-.inf';
3165
+ case 'uppercase': return '-.INF';
3166
+ case 'camelcase': return '-.Inf';
2907
3167
  }
2908
3168
  } else if (common.isNegativeZero(object)) {
2909
3169
  return '-0.0';
2910
- } else {
2911
- return object.toString(10);
2912
3170
  }
3171
+
3172
+ res = object.toString(10);
3173
+
3174
+ // JS stringifier can build scientific format without dots: 5e-100,
3175
+ // while YAML requres dot: 5.e-100. Fix it with simple hack
3176
+
3177
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
2913
3178
  }
2914
3179
 
2915
3180
  function isFloat(object) {
2916
- return ('[object Number]' === Object.prototype.toString.call(object)) &&
2917
- (0 !== object % 1 || common.isNegativeZero(object));
3181
+ return (Object.prototype.toString.call(object) === '[object Number]') &&
3182
+ (object % 1 !== 0 || common.isNegativeZero(object));
2918
3183
  }
2919
3184
 
2920
3185
  module.exports = new Type('tag:yaml.org,2002:float', {
@@ -2947,16 +3212,14 @@ function isDecCode(c) {
2947
3212
  }
2948
3213
 
2949
3214
  function resolveYamlInteger(data) {
2950
- if (null === data) {
2951
- return false;
2952
- }
3215
+ if (data === null) return false;
2953
3216
 
2954
3217
  var max = data.length,
2955
3218
  index = 0,
2956
3219
  hasDigits = false,
2957
3220
  ch;
2958
3221
 
2959
- if (!max) { return false; }
3222
+ if (!max) return false;
2960
3223
 
2961
3224
  ch = data[index];
2962
3225
 
@@ -2967,7 +3230,7 @@ function resolveYamlInteger(data) {
2967
3230
 
2968
3231
  if (ch === '0') {
2969
3232
  // 0
2970
- if (index+1 === max) { return true; }
3233
+ if (index + 1 === max) return true;
2971
3234
  ch = data[++index];
2972
3235
 
2973
3236
  // base 2, base 8, base 16
@@ -2978,10 +3241,8 @@ function resolveYamlInteger(data) {
2978
3241
 
2979
3242
  for (; index < max; index++) {
2980
3243
  ch = data[index];
2981
- if (ch === '_') { continue; }
2982
- if (ch !== '0' && ch !== '1') {
2983
- return false;
2984
- }
3244
+ if (ch === '_') continue;
3245
+ if (ch !== '0' && ch !== '1') return false;
2985
3246
  hasDigits = true;
2986
3247
  }
2987
3248
  return hasDigits;
@@ -2994,10 +3255,8 @@ function resolveYamlInteger(data) {
2994
3255
 
2995
3256
  for (; index < max; index++) {
2996
3257
  ch = data[index];
2997
- if (ch === '_') { continue; }
2998
- if (!isHexCode(data.charCodeAt(index))) {
2999
- return false;
3000
- }
3258
+ if (ch === '_') continue;
3259
+ if (!isHexCode(data.charCodeAt(index))) return false;
3001
3260
  hasDigits = true;
3002
3261
  }
3003
3262
  return hasDigits;
@@ -3006,10 +3265,8 @@ function resolveYamlInteger(data) {
3006
3265
  // base 8
3007
3266
  for (; index < max; index++) {
3008
3267
  ch = data[index];
3009
- if (ch === '_') { continue; }
3010
- if (!isOctCode(data.charCodeAt(index))) {
3011
- return false;
3012
- }
3268
+ if (ch === '_') continue;
3269
+ if (!isOctCode(data.charCodeAt(index))) return false;
3013
3270
  hasDigits = true;
3014
3271
  }
3015
3272
  return hasDigits;
@@ -3019,18 +3276,18 @@ function resolveYamlInteger(data) {
3019
3276
 
3020
3277
  for (; index < max; index++) {
3021
3278
  ch = data[index];
3022
- if (ch === '_') { continue; }
3023
- if (ch === ':') { break; }
3279
+ if (ch === '_') continue;
3280
+ if (ch === ':') break;
3024
3281
  if (!isDecCode(data.charCodeAt(index))) {
3025
3282
  return false;
3026
3283
  }
3027
3284
  hasDigits = true;
3028
3285
  }
3029
3286
 
3030
- if (!hasDigits) { return false; }
3287
+ if (!hasDigits) return false;
3031
3288
 
3032
3289
  // if !base60 - done;
3033
- if (ch !== ':') { return true; }
3290
+ if (ch !== ':') return true;
3034
3291
 
3035
3292
  // base60 almost not used, no needs to optimize
3036
3293
  return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
@@ -3046,24 +3303,17 @@ function constructYamlInteger(data) {
3046
3303
  ch = value[0];
3047
3304
 
3048
3305
  if (ch === '-' || ch === '+') {
3049
- if (ch === '-') { sign = -1; }
3306
+ if (ch === '-') sign = -1;
3050
3307
  value = value.slice(1);
3051
3308
  ch = value[0];
3052
3309
  }
3053
3310
 
3054
- if ('0' === value) {
3055
- return 0;
3056
- }
3311
+ if (value === '0') return 0;
3057
3312
 
3058
3313
  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
- }
3314
+ if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
3315
+ if (value[1] === 'x') return sign * parseInt(value, 16);
3065
3316
  return sign * parseInt(value, 8);
3066
-
3067
3317
  }
3068
3318
 
3069
3319
  if (value.indexOf(':') !== -1) {
@@ -3087,8 +3337,8 @@ function constructYamlInteger(data) {
3087
3337
  }
3088
3338
 
3089
3339
  function isInteger(object) {
3090
- return ('[object Number]' === Object.prototype.toString.call(object)) &&
3091
- (0 === object % 1 && !common.isNegativeZero(object));
3340
+ return (Object.prototype.toString.call(object)) === '[object Number]' &&
3341
+ (object % 1 === 0 && !common.isNegativeZero(object));
3092
3342
  }
3093
3343
 
3094
3344
  module.exports = new Type('tag:yaml.org,2002:int', {
@@ -3124,29 +3374,27 @@ var esprima;
3124
3374
  // found too - then fail to parse.
3125
3375
  //
3126
3376
  try {
3127
- esprima = require('esprima');
3377
+ // workaround to exclude package from browserify list.
3378
+ var _require = require;
3379
+ esprima = _require('esprima');
3128
3380
  } catch (_) {
3129
3381
  /*global window */
3130
- if (typeof window !== 'undefined') { esprima = window.esprima; }
3382
+ if (typeof window !== 'undefined') esprima = window.esprima;
3131
3383
  }
3132
3384
 
3133
3385
  var Type = require('../../type');
3134
3386
 
3135
3387
  function resolveJavascriptFunction(data) {
3136
- if (null === data) {
3137
- return false;
3138
- }
3388
+ if (data === null) return false;
3139
3389
 
3140
3390
  try {
3141
3391
  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) {
3392
+ ast = esprima.parse(source, { range: true });
3393
+
3394
+ if (ast.type !== 'Program' ||
3395
+ ast.body.length !== 1 ||
3396
+ ast.body[0].type !== 'ExpressionStatement' ||
3397
+ ast.body[0].expression.type !== 'FunctionExpression') {
3150
3398
  return false;
3151
3399
  }
3152
3400
 
@@ -3164,10 +3412,10 @@ function constructJavascriptFunction(data) {
3164
3412
  params = [],
3165
3413
  body;
3166
3414
 
3167
- if ('Program' !== ast.type ||
3168
- 1 !== ast.body.length ||
3169
- 'ExpressionStatement' !== ast.body[0].type ||
3170
- 'FunctionExpression' !== ast.body[0].expression.type) {
3415
+ if (ast.type !== 'Program' ||
3416
+ ast.body.length !== 1 ||
3417
+ ast.body[0].type !== 'ExpressionStatement' ||
3418
+ ast.body[0].expression.type !== 'FunctionExpression') {
3171
3419
  throw new Error('Failed to resolve function');
3172
3420
  }
3173
3421
 
@@ -3179,7 +3427,8 @@ function constructJavascriptFunction(data) {
3179
3427
 
3180
3428
  // Esprima's ranges include the first '{' and the last '}' characters on
3181
3429
  // function expressions. So cut them out.
3182
- return new Function(params, source.slice(body[0]+1, body[1]-1));
3430
+ /*eslint-disable no-new-func*/
3431
+ return new Function(params, source.slice(body[0] + 1, body[1] - 1));
3183
3432
  }
3184
3433
 
3185
3434
  function representJavascriptFunction(object /*, style*/) {
@@ -3187,7 +3436,7 @@ function representJavascriptFunction(object /*, style*/) {
3187
3436
  }
3188
3437
 
3189
3438
  function isFunction(object) {
3190
- return '[object Function]' === Object.prototype.toString.call(object);
3439
+ return Object.prototype.toString.call(object) === '[object Function]';
3191
3440
  }
3192
3441
 
3193
3442
  module.exports = new Type('tag:yaml.org,2002:js/function', {
@@ -3198,19 +3447,14 @@ module.exports = new Type('tag:yaml.org,2002:js/function', {
3198
3447
  represent: representJavascriptFunction
3199
3448
  });
3200
3449
 
3201
- },{"../../type":13,"esprima":"esprima"}],19:[function(require,module,exports){
3450
+ },{"../../type":13}],19:[function(require,module,exports){
3202
3451
  'use strict';
3203
3452
 
3204
3453
  var Type = require('../../type');
3205
3454
 
3206
3455
  function resolveJavascriptRegExp(data) {
3207
- if (null === data) {
3208
- return false;
3209
- }
3210
-
3211
- if (0 === data.length) {
3212
- return false;
3213
- }
3456
+ if (data === null) return false;
3457
+ if (data.length === 0) return false;
3214
3458
 
3215
3459
  var regexp = data,
3216
3460
  tail = /\/([gim]*)$/.exec(data),
@@ -3218,24 +3462,15 @@ function resolveJavascriptRegExp(data) {
3218
3462
 
3219
3463
  // if regexp starts with '/' it can have modifiers and must be properly closed
3220
3464
  // `/foo/gim` - modifiers tail can be maximum 3 chars
3221
- if ('/' === regexp[0]) {
3222
- if (tail) {
3223
- modifiers = tail[1];
3224
- }
3465
+ if (regexp[0] === '/') {
3466
+ if (tail) modifiers = tail[1];
3225
3467
 
3226
- if (modifiers.length > 3) { return false; }
3468
+ if (modifiers.length > 3) return false;
3227
3469
  // 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);
3470
+ if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
3231
3471
  }
3232
3472
 
3233
- try {
3234
- var dummy = new RegExp(regexp, modifiers);
3235
- return true;
3236
- } catch (error) {
3237
- return false;
3238
- }
3473
+ return true;
3239
3474
  }
3240
3475
 
3241
3476
  function constructJavascriptRegExp(data) {
@@ -3244,10 +3479,8 @@ function constructJavascriptRegExp(data) {
3244
3479
  modifiers = '';
3245
3480
 
3246
3481
  // `/foo/gim` - tail can be maximum 4 chars
3247
- if ('/' === regexp[0]) {
3248
- if (tail) {
3249
- modifiers = tail[1];
3250
- }
3482
+ if (regexp[0] === '/') {
3483
+ if (tail) modifiers = tail[1];
3251
3484
  regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3252
3485
  }
3253
3486
 
@@ -3257,23 +3490,15 @@ function constructJavascriptRegExp(data) {
3257
3490
  function representJavascriptRegExp(object /*, style*/) {
3258
3491
  var result = '/' + object.source + '/';
3259
3492
 
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
- }
3493
+ if (object.global) result += 'g';
3494
+ if (object.multiline) result += 'm';
3495
+ if (object.ignoreCase) result += 'i';
3271
3496
 
3272
3497
  return result;
3273
3498
  }
3274
3499
 
3275
3500
  function isRegExp(object) {
3276
- return '[object RegExp]' === Object.prototype.toString.call(object);
3501
+ return Object.prototype.toString.call(object) === '[object RegExp]';
3277
3502
  }
3278
3503
 
3279
3504
  module.exports = new Type('tag:yaml.org,2002:js/regexp', {
@@ -3294,6 +3519,7 @@ function resolveJavascriptUndefined() {
3294
3519
  }
3295
3520
 
3296
3521
  function constructJavascriptUndefined() {
3522
+ /*eslint-disable no-undefined*/
3297
3523
  return undefined;
3298
3524
  }
3299
3525
 
@@ -3302,7 +3528,7 @@ function representJavascriptUndefined() {
3302
3528
  }
3303
3529
 
3304
3530
  function isUndefined(object) {
3305
- return 'undefined' === typeof object;
3531
+ return typeof object === 'undefined';
3306
3532
  }
3307
3533
 
3308
3534
  module.exports = new Type('tag:yaml.org,2002:js/undefined', {
@@ -3320,7 +3546,7 @@ var Type = require('../type');
3320
3546
 
3321
3547
  module.exports = new Type('tag:yaml.org,2002:map', {
3322
3548
  kind: 'mapping',
3323
- construct: function (data) { return null !== data ? data : {}; }
3549
+ construct: function (data) { return data !== null ? data : {}; }
3324
3550
  });
3325
3551
 
3326
3552
  },{"../type":13}],22:[function(require,module,exports){
@@ -3329,7 +3555,7 @@ module.exports = new Type('tag:yaml.org,2002:map', {
3329
3555
  var Type = require('../type');
3330
3556
 
3331
3557
  function resolveYamlMerge(data) {
3332
- return '<<' === data || null === data;
3558
+ return data === '<<' || data === null;
3333
3559
  }
3334
3560
 
3335
3561
  module.exports = new Type('tag:yaml.org,2002:merge', {
@@ -3343,9 +3569,7 @@ module.exports = new Type('tag:yaml.org,2002:merge', {
3343
3569
  var Type = require('../type');
3344
3570
 
3345
3571
  function resolveYamlNull(data) {
3346
- if (null === data) {
3347
- return true;
3348
- }
3572
+ if (data === null) return true;
3349
3573
 
3350
3574
  var max = data.length;
3351
3575
 
@@ -3358,7 +3582,7 @@ function constructYamlNull() {
3358
3582
  }
3359
3583
 
3360
3584
  function isNull(object) {
3361
- return null === object;
3585
+ return object === null;
3362
3586
  }
3363
3587
 
3364
3588
  module.exports = new Type('tag:yaml.org,2002:null', {
@@ -3384,9 +3608,7 @@ var _hasOwnProperty = Object.prototype.hasOwnProperty;
3384
3608
  var _toString = Object.prototype.toString;
3385
3609
 
3386
3610
  function resolveYamlOmap(data) {
3387
- if (null === data) {
3388
- return true;
3389
- }
3611
+ if (data === null) return true;
3390
3612
 
3391
3613
  var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3392
3614
  object = data;
@@ -3395,36 +3617,26 @@ function resolveYamlOmap(data) {
3395
3617
  pair = object[index];
3396
3618
  pairHasKey = false;
3397
3619
 
3398
- if ('[object Object]' !== _toString.call(pair)) {
3399
- return false;
3400
- }
3620
+ if (_toString.call(pair) !== '[object Object]') return false;
3401
3621
 
3402
3622
  for (pairKey in pair) {
3403
3623
  if (_hasOwnProperty.call(pair, pairKey)) {
3404
- if (!pairHasKey) {
3405
- pairHasKey = true;
3406
- } else {
3407
- return false;
3408
- }
3624
+ if (!pairHasKey) pairHasKey = true;
3625
+ else return false;
3409
3626
  }
3410
3627
  }
3411
3628
 
3412
- if (!pairHasKey) {
3413
- return false;
3414
- }
3629
+ if (!pairHasKey) return false;
3415
3630
 
3416
- if (-1 === objectKeys.indexOf(pairKey)) {
3417
- objectKeys.push(pairKey);
3418
- } else {
3419
- return false;
3420
- }
3631
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
3632
+ else return false;
3421
3633
  }
3422
3634
 
3423
3635
  return true;
3424
3636
  }
3425
3637
 
3426
3638
  function constructYamlOmap(data) {
3427
- return null !== data ? data : [];
3639
+ return data !== null ? data : [];
3428
3640
  }
3429
3641
 
3430
3642
  module.exports = new Type('tag:yaml.org,2002:omap', {
@@ -3441,9 +3653,7 @@ var Type = require('../type');
3441
3653
  var _toString = Object.prototype.toString;
3442
3654
 
3443
3655
  function resolveYamlPairs(data) {
3444
- if (null === data) {
3445
- return true;
3446
- }
3656
+ if (data === null) return true;
3447
3657
 
3448
3658
  var index, length, pair, keys, result,
3449
3659
  object = data;
@@ -3453,15 +3663,11 @@ function resolveYamlPairs(data) {
3453
3663
  for (index = 0, length = object.length; index < length; index += 1) {
3454
3664
  pair = object[index];
3455
3665
 
3456
- if ('[object Object]' !== _toString.call(pair)) {
3457
- return false;
3458
- }
3666
+ if (_toString.call(pair) !== '[object Object]') return false;
3459
3667
 
3460
3668
  keys = Object.keys(pair);
3461
3669
 
3462
- if (1 !== keys.length) {
3463
- return false;
3464
- }
3670
+ if (keys.length !== 1) return false;
3465
3671
 
3466
3672
  result[index] = [ keys[0], pair[keys[0]] ];
3467
3673
  }
@@ -3470,9 +3676,7 @@ function resolveYamlPairs(data) {
3470
3676
  }
3471
3677
 
3472
3678
  function constructYamlPairs(data) {
3473
- if (null === data) {
3474
- return [];
3475
- }
3679
+ if (data === null) return [];
3476
3680
 
3477
3681
  var index, length, pair, keys, result,
3478
3682
  object = data;
@@ -3503,7 +3707,7 @@ var Type = require('../type');
3503
3707
 
3504
3708
  module.exports = new Type('tag:yaml.org,2002:seq', {
3505
3709
  kind: 'sequence',
3506
- construct: function (data) { return null !== data ? data : []; }
3710
+ construct: function (data) { return data !== null ? data : []; }
3507
3711
  });
3508
3712
 
3509
3713
  },{"../type":13}],27:[function(require,module,exports){
@@ -3514,17 +3718,13 @@ var Type = require('../type');
3514
3718
  var _hasOwnProperty = Object.prototype.hasOwnProperty;
3515
3719
 
3516
3720
  function resolveYamlSet(data) {
3517
- if (null === data) {
3518
- return true;
3519
- }
3721
+ if (data === null) return true;
3520
3722
 
3521
3723
  var key, object = data;
3522
3724
 
3523
3725
  for (key in object) {
3524
3726
  if (_hasOwnProperty.call(object, key)) {
3525
- if (null !== object[key]) {
3526
- return false;
3527
- }
3727
+ if (object[key] !== null) return false;
3528
3728
  }
3529
3729
  }
3530
3730
 
@@ -3532,7 +3732,7 @@ function resolveYamlSet(data) {
3532
3732
  }
3533
3733
 
3534
3734
  function constructYamlSet(data) {
3535
- return null !== data ? data : {};
3735
+ return data !== null ? data : {};
3536
3736
  }
3537
3737
 
3538
3738
  module.exports = new Type('tag:yaml.org,2002:set', {
@@ -3548,7 +3748,7 @@ var Type = require('../type');
3548
3748
 
3549
3749
  module.exports = new Type('tag:yaml.org,2002:str', {
3550
3750
  kind: 'scalar',
3551
- construct: function (data) { return null !== data ? data : ''; }
3751
+ construct: function (data) { return data !== null ? data : ''; }
3552
3752
  });
3553
3753
 
3554
3754
  },{"../type":13}],29:[function(require,module,exports){
@@ -3556,44 +3756,38 @@ module.exports = new Type('tag:yaml.org,2002:str', {
3556
3756
 
3557
3757
  var Type = require('../type');
3558
3758
 
3759
+ var YAML_DATE_REGEXP = new RegExp(
3760
+ '^([0-9][0-9][0-9][0-9])' + // [1] year
3761
+ '-([0-9][0-9])' + // [2] month
3762
+ '-([0-9][0-9])$'); // [3] day
3763
+
3559
3764
  var YAML_TIMESTAMP_REGEXP = new RegExp(
3560
3765
  '^([0-9][0-9][0-9][0-9])' + // [1] year
3561
3766
  '-([0-9][0-9]?)' + // [2] month
3562
3767
  '-([0-9][0-9]?)' + // [3] day
3563
- '(?:(?:[Tt]|[ \\t]+)' + // ...
3768
+ '(?:[Tt]|[ \\t]+)' + // ...
3564
3769
  '([0-9][0-9]?)' + // [4] hour
3565
3770
  ':([0-9][0-9])' + // [5] minute
3566
3771
  ':([0-9][0-9])' + // [6] second
3567
3772
  '(?:\\.([0-9]*))?' + // [7] fraction
3568
3773
  '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
3569
- '(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
3774
+ '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
3570
3775
 
3571
3776
  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;
3777
+ if (data === null) return false;
3778
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
3779
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
3780
+ return false;
3586
3781
  }
3587
3782
 
3588
3783
  function constructYamlTimestamp(data) {
3589
3784
  var match, year, month, day, hour, minute, second, fraction = 0,
3590
3785
  delta = null, tz_hour, tz_minute, date;
3591
3786
 
3592
- match = YAML_TIMESTAMP_REGEXP.exec(data);
3787
+ match = YAML_DATE_REGEXP.exec(data);
3788
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
3593
3789
 
3594
- if (null === match) {
3595
- throw new Error('Date resolve error');
3596
- }
3790
+ if (match === null) throw new Error('Date resolve error');
3597
3791
 
3598
3792
  // match: [1] year [2] month [3] day
3599
3793
 
@@ -3625,16 +3819,12 @@ function constructYamlTimestamp(data) {
3625
3819
  tz_hour = +(match[10]);
3626
3820
  tz_minute = +(match[11] || 0);
3627
3821
  delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
3628
- if ('-' === match[9]) {
3629
- delta = -delta;
3630
- }
3822
+ if (match[9] === '-') delta = -delta;
3631
3823
  }
3632
3824
 
3633
3825
  date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3634
3826
 
3635
- if (delta) {
3636
- date.setTime(date.getTime() - delta);
3637
- }
3827
+ if (delta) date.setTime(date.getTime() - delta);
3638
3828
 
3639
3829
  return date;
3640
3830
  }
@@ -3651,9 +3841,7 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', {
3651
3841
  represent: representYamlTimestamp
3652
3842
  });
3653
3843
 
3654
- },{"../type":13}],30:[function(require,module,exports){
3655
-
3656
- },{}],"/":[function(require,module,exports){
3844
+ },{"../type":13}],"/":[function(require,module,exports){
3657
3845
  'use strict';
3658
3846
 
3659
3847
 
@@ -3663,4 +3851,5 @@ var yaml = require('./lib/js-yaml.js');
3663
3851
  module.exports = yaml;
3664
3852
 
3665
3853
  },{"./lib/js-yaml.js":1}]},{},[])("/")
3666
- });
3854
+ });
3855
+ /* jshint ignore:end */