diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 03282b9b..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,138 +0,0 @@ -env: - node: true - browser: true - es6: false - -globals: - Uint8Array: false - -ignorePatterns: - - coverage/ - - demo/ - - dist/ - - node_modules - - benchmark/implementations - - rollup.config.js - -rules: - accessor-pairs: 2 - array-bracket-spacing: [ 2, "always", { "singleValue": true, "objectsInArrays": true, "arraysInArrays": true } ] - block-scoped-var: 2 - block-spacing: 2 - brace-style: [ 2, '1tbs', { "allowSingleLine": true } ] - #callback-return: 2 - comma-dangle: 2 - comma-spacing: 2 - comma-style: 2 - computed-property-spacing: [ 2, never ] - #consistent-return: 2 - consistent-this: [ 2, self ] - curly: [ 2, 'multi-line' ] - # dot-notation: [ 2, { allowKeywords: true } ] - dot-location: [ 2, 'property' ] - eol-last: 2 - eqeqeq: 2 - func-style: [ 2, declaration ] - guard-for-in: 2 - handle-callback-err: 2 - indent: [ 2, 2, { VariableDeclarator: { var: 2, let: 2, const: 3 }, SwitchCase: 1 } ] - # key-spacing: [ 2, { "align": "value" } ] - keyword-spacing: 2 - linebreak-style: 2 - max-depth: [ 1, 5 ] - max-nested-callbacks: [ 1, 7 ] - # string can exceed 80 chars, but should not overflow github website :) - max-len: [ 2, 120, 1000 ] - new-cap: 2 - new-parens: 2 - no-alert: 2 - no-array-constructor: 2 - no-bitwise: 2 - no-caller: 2 - no-case-declarations: 2 - no-catch-shadow: 2 - no-cond-assign: 2 - no-console: 1 - no-constant-condition: 2 - # no-control-regex: 2 - no-debugger: 1 - no-delete-var: 2 - no-div-regex: 2 - no-dupe-args: 2 - no-dupe-keys: 2 - no-duplicate-case: 2 - no-else-return: 2 - # no-empty: 1 - no-empty-character-class: 2 - no-empty-pattern: 2 - no-eq-null: 2 - no-eval: 2 - no-ex-assign: 2 - no-extend-native: 2 - no-extra-bind: 2 - no-extra-boolean-cast: 2 - no-extra-semi: 2 - no-fallthrough: 2 - no-floating-decimal: 2 - no-func-assign: 2 - no-implied-eval: 2 - no-inner-declarations: 2 - no-invalid-regexp: 2 - no-irregular-whitespace: 2 - no-iterator: 2 - no-labels: 2 - no-label-var: 2 - no-lone-blocks: 1 - no-lonely-if: 2 - no-loop-func: 2 - no-mixed-requires: [ 1, { "grouping": true } ] - no-mixed-spaces-and-tabs: 2 - no-native-reassign: 2 - no-negated-in-lhs: 2 - no-new: 2 - no-new-func: 2 - no-new-object: 2 - no-new-require: 2 - no-new-wrappers: 2 - no-obj-calls: 2 - no-octal: 2 - no-octal-escape: 2 - no-path-concat: 2 - no-proto: 2 - no-redeclare: 2 - # no-regex-spaces: 2 - no-return-assign: 2 - no-self-compare: 2 - no-sequences: 2 - # no-shadow: 2 - no-shadow-restricted-names: 2 - no-sparse-arrays: 2 - no-throw-literal: 2 - no-trailing-spaces: 2 - no-undef: 2 - no-undef-init: 2 - no-undefined: 2 - no-unexpected-multiline: 2 - no-unreachable: 2 - no-unused-expressions: 2 - no-unused-vars: 2 - no-use-before-define: 2 - no-void: 2 - no-with: 2 - object-curly-spacing: [ 2, always, { "objectsInObjects": true, "arraysInObjects": true } ] - operator-assignment: 1 - semi: 2 - semi-spacing: 2 - space-before-blocks: 2 - space-before-function-paren: [ 2, { "anonymous": "always", "named": "never" } ] - space-in-parens: [ 2, never ] - space-infix-ops: 2 - space-unary-ops: 2 - #spaced-comment: [ 1, always, { exceptions: [ '/', '=' ] } ] - strict: [ 2, global ] - quotes: [ 2, single, avoid-escape ] - quote-props: [ 1, 'as-needed' ] - radix: 2 - use-isnan: 2 - valid-typeof: 2 - yoda: [ 2, never, { "exceptRange": true } ] diff --git a/.gitignore b/.gitignore index 5fc6a3d9..2949f09b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules doc benchmark/implementations/* !/benchmark/implementations/current/ +dist/ diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100755 index 6deec089..00000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -/*eslint-disable no-console*/ - -var path = require('path'); -var fs = require('fs'); -var util = require('util'); -var Benchmark = require('benchmark'); -var ansi = require('ansi'); -var cursor = ansi(process.stdout); - - -var IMPLS_DIRECTORY = path.join(__dirname, 'implementations'); -var IMPLS_PATHS = {}; -var IMPLS = []; - - -fs.readdirSync(IMPLS_DIRECTORY).sort().forEach(function (name) { - var file = path.join(IMPLS_DIRECTORY, name); - var code = require(file); - - IMPLS_PATHS[name] = file; - IMPLS.push({ - name: name, - run: code.load - }); -}); - - -var SAMPLES_DIRECTORY = path.join(__dirname, 'samples'); -var SAMPLES = []; - - -fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) { - var filepath = path.join(SAMPLES_DIRECTORY, sample), - extname = path.extname(filepath), - basename = path.basename(filepath, extname), - content = fs.readFileSync(filepath, 'utf8'), - title = util.format('%s (%d characters)', sample, content.length); - - function onComplete() { - cursor.write('\n'); - } - - var suite = new Benchmark.Suite(title, { - - onStart: function onStart() { - console.log('\nSample: %s', title); - }, - - onComplete: onComplete - - }); - - - IMPLS.forEach(function (impl) { - suite.add(impl.name, { - - onCycle: function onCycle(event) { - cursor.horizontalAbsolute(); - cursor.eraseLine(); - cursor.write(' > ' + event.target); - }, - - onComplete: onComplete, - - fn: function () { impl.run(content); } - }); - }); - - - SAMPLES.push({ - name: basename, - title: title, - content: content, - suite: suite - }); -}); - - -function select(patterns) { - var result = []; - - if (!(patterns instanceof Array)) patterns = [ patterns ]; - - function checkName(name) { - return patterns.length === 0 || patterns.some(function (regexp) { - return regexp.test(name); - }); - } - - SAMPLES.forEach(function (sample) { - if (checkName(sample.name)) result.push(sample); - }); - - return result; -} - - -function run(files) { - var selected = select(files); - - if (selected.length > 0) { - console.log('Selected samples: (%d of %d)', selected.length, SAMPLES.length); - selected.forEach(function (sample) { - console.log(' > %s', sample.name); - }); - } else { - console.log("There isn't any sample matches any of these patterns: %s", util.inspect(files)); - } - - selected.forEach(function (sample) { - sample.suite.run(); - }); -} - - -run(process.argv.slice(2).map(function (source) { - return new RegExp(source, 'i'); -})); diff --git a/benchmark/benchmark.mjs b/benchmark/benchmark.mjs new file mode 100755 index 00000000..ffd5f638 --- /dev/null +++ b/benchmark/benchmark.mjs @@ -0,0 +1,103 @@ +#!/usr/bin/env node +/* eslint no-console:0 */ + +import fs from 'node:fs' +import util from 'node:util' +import { Bench } from 'tinybench' + +const IMPLS = [] + +for (const name of fs.readdirSync(new URL('./implementations', import.meta.url)).sort()) { + const filepath = new URL(`./implementations/${name}/index.mjs`, import.meta.url) + const code = await import(filepath) + + IMPLS.push({ name, code }) +} + +const SAMPLES = [] + +fs.readdirSync(new URL('./samples', import.meta.url)).sort().forEach(function (sample) { + const filepath = new URL(`./samples/${sample}`, import.meta.url) + + const content = {} + + content.string = fs.readFileSync(filepath, 'utf8') + + const title = `(${content.string.length} bytes)` + + const bench = new Bench({ name: title }) + + IMPLS.forEach(function (impl) { + bench.add(impl.name, function () { impl.code.run(content.string) }) + }) + + SAMPLES.push({ name: sample.split('.')[0], filename: sample, title, content, bench }) +}) + +function formatNumber (num) { + return num.toLocaleString('en-US', { maximumFractionDigits: 0 }) +} + +function formatTask (task) { + const result = task.result + + if (result.state !== 'completed') { + return `${task.name}: ${result.state}` + } + + return [ + task.name, + `${formatNumber(result.throughput.mean)} ops/sec`, + `+/-${result.throughput.rme.toFixed(2)}%`, + `${result.throughput.samplesCount} samples` + ].join(' ') +} + +function select (patterns) { + const result = [] + + if (!(patterns instanceof Array)) { + patterns = [patterns] + } + + function checkName (name) { + return patterns.length === 0 || patterns.some(function (regexp) { + return regexp.test(name) + }) + } + + SAMPLES.forEach(function (sample) { + if (checkName(sample.name)) { + result.push(sample) + } + }) + + return result +} + +async function run (files) { + const selected = select(files) + + if (selected.length > 0) { + console.log('Selected samples: (%d of %d)', selected.length, SAMPLES.length) + selected.forEach(function (sample) { + console.log(' > %s', sample.name) + }) + } else { + console.log('There isn\'t any sample matches any of these patterns: %s', util.inspect(files)) + } + + for (const sample of selected) { + console.log('\n\nSample: %s %s', sample.filename, sample.title) + + sample.bench.addEventListener('cycle', function (event) { + console.log(' > %s', formatTask(event.task)) + }) + + await sample.bench.run() + } +} + +await run(process.argv.slice(2).map(function (source) { + return new RegExp(source, 'i') +})) diff --git a/benchmark/implementations/current/index.js b/benchmark/implementations/current/index.js deleted file mode 100644 index ab29912f..00000000 --- a/benchmark/implementations/current/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('../../../'); diff --git a/benchmark/implementations/current/index.mjs b/benchmark/implementations/current/index.mjs new file mode 100644 index 00000000..55a1bbc1 --- /dev/null +++ b/benchmark/implementations/current/index.mjs @@ -0,0 +1,5 @@ +import yaml from '../../../index.js' + +export function run (data) { + return yaml.load(data) +} diff --git a/benchmark/profile.js b/benchmark/profile.js deleted file mode 100755 index 27d18ca6..00000000 --- a/benchmark/profile.js +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env node - - -'use strict'; - -var fs = require('fs'); -var path = require('path'); -var yaml = require('../'); - -var data = fs.readFileSync(path.join(__dirname, '/samples/document_nodeca_application.yaml'), 'utf8'); - -for (var i = 0; i < 10000; i++) { - yaml.load(data); -} diff --git a/bin/js-yaml.js b/bin/js-yaml.js index a182f1af..583e2999 100755 --- a/bin/js-yaml.js +++ b/bin/js-yaml.js @@ -1,33 +1,27 @@ #!/usr/bin/env node +'use strict' -'use strict'; +const fs = require('fs') +const argparse = require('argparse') +const yaml = require('..') -/*eslint-disable no-console*/ +/// ///////////////////////////////////////////////////////////////////////////// - -var fs = require('fs'); -var argparse = require('argparse'); -var yaml = require('..'); - - -//////////////////////////////////////////////////////////////////////////////// - - -var cli = new argparse.ArgumentParser({ +const cli = new argparse.ArgumentParser({ prog: 'js-yaml', add_help: true -}); +}) cli.add_argument('-v', '--version', { action: 'version', version: require('../package.json').version -}); +}) cli.add_argument('-c', '--compact', { help: 'Display errors in compact mode', action: 'store_true' -}); +}) // deprecated (not needed after we removed output colors) // option suppressed, but not completely removed for compatibility @@ -35,92 +29,89 @@ cli.add_argument('-j', '--to-json', { help: argparse.SUPPRESS, dest: 'json', action: 'store_true' -}); +}) cli.add_argument('-t', '--trace', { help: 'Show stack trace on error', action: 'store_true' -}); +}) cli.add_argument('file', { help: 'File to read, utf-8 encoded without BOM', nargs: '?', default: '-' -}); +}) +/// ///////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// +const options = cli.parse_args() +/// ///////////////////////////////////////////////////////////////////////////// -var options = cli.parse_args(); - - -//////////////////////////////////////////////////////////////////////////////// - -function readFile(filename, encoding, callback) { +function readFile (filename, encoding, callback) { if (options.file === '-') { // read from stdin - var chunks = []; + const chunks = [] process.stdin.on('data', function (chunk) { - chunks.push(chunk); - }); + chunks.push(chunk) + }) process.stdin.on('end', function () { - return callback(null, Buffer.concat(chunks).toString(encoding)); - }); + return callback(null, Buffer.concat(chunks).toString(encoding)) + }) } else { - fs.readFile(filename, encoding, callback); + fs.readFile(filename, encoding, callback) } } readFile(options.file, 'utf8', function (error, input) { - var output, isYaml; + let output + let isYaml if (error) { if (error.code === 'ENOENT') { - console.error('File not found: ' + options.file); - process.exit(2); + console.error('File not found: ' + options.file) + process.exit(2) } console.error( - options.trace && error.stack || + (options.trace && error.stack) || error.message || - String(error)); + String(error)) - process.exit(1); + process.exit(1) } try { - output = JSON.parse(input); - isYaml = false; + output = JSON.parse(input) + isYaml = false } catch (err) { if (err instanceof SyntaxError) { try { - output = []; - yaml.loadAll(input, function (doc) { output.push(doc); }, {}); - isYaml = true; - - if (output.length === 0) output = null; - else if (output.length === 1) output = output[0]; + output = [] + yaml.loadAll(input, function (doc) { output.push(doc) }, {}) + isYaml = true + if (output.length === 0) output = null + else if (output.length === 1) output = output[0] } catch (e) { - if (options.trace && err.stack) console.error(e.stack); - else console.error(e.toString(options.compact)); + if (options.trace && err.stack) console.error(e.stack) + else console.error(e.toString(options.compact)) - process.exit(1); + process.exit(1) } } else { console.error( - options.trace && err.stack || + (options.trace && err.stack) || err.message || - String(err)); + String(err)) - process.exit(1); + process.exit(1) } } - if (isYaml) console.log(JSON.stringify(output, null, ' ')); - else console.log(yaml.dump(output)); -}); + if (isYaml) console.log(JSON.stringify(output, null, ' ')) + else console.log(yaml.dump(output)) +}) diff --git a/dist/js-yaml.js b/dist/js-yaml.js deleted file mode 100644 index 21c52eca..00000000 --- a/dist/js-yaml.js +++ /dev/null @@ -1,3880 +0,0 @@ - -/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jsyaml = {})); -})(this, (function (exports) { 'use strict'; - - function isNothing(subject) { - return (typeof subject === 'undefined') || (subject === null); - } - - - function isObject(subject) { - return (typeof subject === 'object') && (subject !== null); - } - - - function toArray(sequence) { - if (Array.isArray(sequence)) return sequence; - else if (isNothing(sequence)) return []; - - return [ sequence ]; - } - - - function extend(target, source) { - var index, length, key, sourceKeys; - - if (source) { - sourceKeys = Object.keys(source); - - for (index = 0, length = sourceKeys.length; index < length; index += 1) { - key = sourceKeys[index]; - target[key] = source[key]; - } - } - - return target; - } - - - function repeat(string, count) { - var result = '', cycle; - - for (cycle = 0; cycle < count; cycle += 1) { - result += string; - } - - return result; - } - - - function isNegativeZero(number) { - return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); - } - - - var isNothing_1 = isNothing; - var isObject_1 = isObject; - var toArray_1 = toArray; - var repeat_1 = repeat; - var isNegativeZero_1 = isNegativeZero; - var extend_1 = extend; - - var common = { - isNothing: isNothing_1, - isObject: isObject_1, - toArray: toArray_1, - repeat: repeat_1, - isNegativeZero: isNegativeZero_1, - extend: extend_1 - }; - - // YAML error class. http://stackoverflow.com/questions/8458984 - - - function formatError(exception, compact) { - var where = '', message = exception.reason || '(unknown reason)'; - - if (!exception.mark) return message; - - if (exception.mark.name) { - where += 'in "' + exception.mark.name + '" '; - } - - where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; - - if (!compact && exception.mark.snippet) { - where += '\n\n' + exception.mark.snippet; - } - - return message + ' ' + where; - } - - - function YAMLException$1(reason, mark) { - // Super constructor - Error.call(this); - - this.name = 'YAMLException'; - this.reason = reason; - this.mark = mark; - this.message = formatError(this, false); - - // Include stack trace in error object - if (Error.captureStackTrace) { - // Chrome and NodeJS - Error.captureStackTrace(this, this.constructor); - } else { - // FF, IE 10+ and Safari 6+. Fallback for others - this.stack = (new Error()).stack || ''; - } - } - - - // Inherit from Error - YAMLException$1.prototype = Object.create(Error.prototype); - YAMLException$1.prototype.constructor = YAMLException$1; - - - YAMLException$1.prototype.toString = function toString(compact) { - return this.name + ': ' + formatError(this, compact); - }; - - - var exception = YAMLException$1; - - // get snippet for a single line, respecting maxLength - function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { - var head = ''; - var tail = ''; - var maxHalfLength = Math.floor(maxLineLength / 2) - 1; - - if (position - lineStart > maxHalfLength) { - head = ' ... '; - lineStart = position - maxHalfLength + head.length; - } - - if (lineEnd - position > maxHalfLength) { - tail = ' ...'; - lineEnd = position + maxHalfLength - tail.length; - } - - return { - str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, - pos: position - lineStart + head.length // relative position - }; - } - - - function padStart(string, max) { - return common.repeat(' ', max - string.length) + string; - } - - - function makeSnippet(mark, options) { - options = Object.create(options || null); - - if (!mark.buffer) return null; - - if (!options.maxLength) options.maxLength = 79; - if (typeof options.indent !== 'number') options.indent = 1; - if (typeof options.linesBefore !== 'number') options.linesBefore = 3; - if (typeof options.linesAfter !== 'number') options.linesAfter = 2; - - var re = /\r?\n|\r|\0/g; - var lineStarts = [ 0 ]; - var lineEnds = []; - var match; - var foundLineNo = -1; - - while ((match = re.exec(mark.buffer))) { - lineEnds.push(match.index); - lineStarts.push(match.index + match[0].length); - - if (mark.position <= match.index && foundLineNo < 0) { - foundLineNo = lineStarts.length - 2; - } - } - - if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; - - var result = '', i, line; - var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; - var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); - - for (i = 1; i <= options.linesBefore; i++) { - if (foundLineNo - i < 0) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo - i], - lineEnds[foundLineNo - i], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), - maxLineLength - ); - result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n' + result; - } - - line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); - result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; - result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; - - for (i = 1; i <= options.linesAfter; i++) { - if (foundLineNo + i >= lineEnds.length) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo + i], - lineEnds[foundLineNo + i], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), - maxLineLength - ); - result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; - } - - return result.replace(/\n$/, ''); - } - - - var snippet = makeSnippet; - - var TYPE_CONSTRUCTOR_OPTIONS = [ - 'kind', - 'multi', - 'resolve', - 'construct', - 'instanceOf', - 'predicate', - 'represent', - 'representName', - 'defaultStyle', - 'styleAliases' - ]; - - var YAML_NODE_KINDS = [ - 'scalar', - 'sequence', - 'mapping' - ]; - - function compileStyleAliases(map) { - var result = {}; - - if (map !== null) { - Object.keys(map).forEach(function (style) { - map[style].forEach(function (alias) { - result[String(alias)] = style; - }); - }); - } - - return result; - } - - function Type$1(tag, options) { - options = options || {}; - - Object.keys(options).forEach(function (name) { - if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { - throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); - } - }); - - // TODO: Add tag format check. - this.options = options; // keep original options in case user wants to extend this type later - this.tag = tag; - this.kind = options['kind'] || null; - this.resolve = options['resolve'] || function () { return true; }; - this.construct = options['construct'] || function (data) { return data; }; - this.instanceOf = options['instanceOf'] || null; - this.predicate = options['predicate'] || null; - this.represent = options['represent'] || null; - this.representName = options['representName'] || null; - this.defaultStyle = options['defaultStyle'] || null; - this.multi = options['multi'] || false; - this.styleAliases = compileStyleAliases(options['styleAliases'] || null); - - if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { - throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); - } - } - - var type = Type$1; - - /*eslint-disable max-len*/ - - - - - - function compileList(schema, name) { - var result = []; - - schema[name].forEach(function (currentType) { - var newIndex = result.length; - - result.forEach(function (previousType, previousIndex) { - if (previousType.tag === currentType.tag && - previousType.kind === currentType.kind && - previousType.multi === currentType.multi) { - - newIndex = previousIndex; - } - }); - - result[newIndex] = currentType; - }); - - return result; - } - - - function compileMap(/* lists... */) { - var result = { - scalar: {}, - sequence: {}, - mapping: {}, - fallback: {}, - multi: { - scalar: [], - sequence: [], - mapping: [], - fallback: [] - } - }, index, length; - - function collectType(type) { - if (type.multi) { - result.multi[type.kind].push(type); - result.multi['fallback'].push(type); - } else { - result[type.kind][type.tag] = result['fallback'][type.tag] = type; - } - } - - for (index = 0, length = arguments.length; index < length; index += 1) { - arguments[index].forEach(collectType); - } - return result; - } - - - function Schema$1(definition) { - return this.extend(definition); - } - - - Schema$1.prototype.extend = function extend(definition) { - var implicit = []; - var explicit = []; - - if (definition instanceof type) { - // Schema.extend(type) - explicit.push(definition); - - } else if (Array.isArray(definition)) { - // Schema.extend([ type1, type2, ... ]) - explicit = explicit.concat(definition); - - } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { - // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) - if (definition.implicit) implicit = implicit.concat(definition.implicit); - if (definition.explicit) explicit = explicit.concat(definition.explicit); - - } else { - throw new exception('Schema.extend argument should be a Type, [ Type ], ' + - 'or a schema definition ({ implicit: [...], explicit: [...] })'); - } - - implicit.forEach(function (type$1) { - if (!(type$1 instanceof type)) { - throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); - } - - if (type$1.loadKind && type$1.loadKind !== 'scalar') { - throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); - } - - if (type$1.multi) { - throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); - } - }); - - explicit.forEach(function (type$1) { - if (!(type$1 instanceof type)) { - throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); - } - }); - - var result = Object.create(Schema$1.prototype); - - result.implicit = (this.implicit || []).concat(implicit); - result.explicit = (this.explicit || []).concat(explicit); - - result.compiledImplicit = compileList(result, 'implicit'); - result.compiledExplicit = compileList(result, 'explicit'); - result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); - - return result; - }; - - - var schema = Schema$1; - - var str = new type('tag:yaml.org,2002:str', { - kind: 'scalar', - construct: function (data) { return data !== null ? data : ''; } - }); - - var seq = new type('tag:yaml.org,2002:seq', { - kind: 'sequence', - construct: function (data) { return data !== null ? data : []; } - }); - - var map = new type('tag:yaml.org,2002:map', { - kind: 'mapping', - construct: function (data) { return data !== null ? data : {}; } - }); - - var failsafe = new schema({ - explicit: [ - str, - seq, - map - ] - }); - - function resolveYamlNull(data) { - if (data === null) return true; - - var max = data.length; - - return (max === 1 && data === '~') || - (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); - } - - function constructYamlNull() { - return null; - } - - function isNull(object) { - return object === null; - } - - var _null = new type('tag:yaml.org,2002:null', { - kind: 'scalar', - resolve: resolveYamlNull, - construct: constructYamlNull, - predicate: isNull, - represent: { - canonical: function () { return '~'; }, - lowercase: function () { return 'null'; }, - uppercase: function () { return 'NULL'; }, - camelcase: function () { return 'Null'; }, - empty: function () { return ''; } - }, - defaultStyle: 'lowercase' - }); - - function resolveYamlBoolean(data) { - if (data === null) return false; - - var max = data.length; - - return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || - (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); - } - - function constructYamlBoolean(data) { - return data === 'true' || - data === 'True' || - data === 'TRUE'; - } - - function isBoolean(object) { - return Object.prototype.toString.call(object) === '[object Boolean]'; - } - - var bool = new type('tag:yaml.org,2002:bool', { - kind: 'scalar', - resolve: resolveYamlBoolean, - construct: constructYamlBoolean, - predicate: isBoolean, - represent: { - lowercase: function (object) { return object ? 'true' : 'false'; }, - uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, - camelcase: function (object) { return object ? 'True' : 'False'; } - }, - defaultStyle: 'lowercase' - }); - - function isHexCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || - ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || - ((0x61/* a */ <= c) && (c <= 0x66/* f */)); - } - - function isOctCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); - } - - function isDecCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); - } - - function resolveYamlInteger(data) { - if (data === null) return false; - - var max = data.length, - index = 0, - hasDigits = false, - ch; - - if (!max) return false; - - ch = data[index]; - - // sign - if (ch === '-' || ch === '+') { - ch = data[++index]; - } - - if (ch === '0') { - // 0 - if (index + 1 === max) return true; - ch = data[++index]; - - // base 2, base 8, base 16 - - if (ch === 'b') { - // base 2 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (ch !== '0' && ch !== '1') return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } - - - if (ch === 'x') { - // base 16 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isHexCode(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } - - - if (ch === 'o') { - // base 8 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isOctCode(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } - } - - // base 10 (except 0) - - // value should not start with `_`; - if (ch === '_') return false; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isDecCode(data.charCodeAt(index))) { - return false; - } - hasDigits = true; - } - - // Should have digits and should not end with `_` - if (!hasDigits || ch === '_') return false; - - return true; - } - - function constructYamlInteger(data) { - var value = data, sign = 1, ch; - - if (value.indexOf('_') !== -1) { - value = value.replace(/_/g, ''); - } - - ch = value[0]; - - if (ch === '-' || ch === '+') { - if (ch === '-') sign = -1; - value = value.slice(1); - ch = value[0]; - } - - if (value === '0') return 0; - - if (ch === '0') { - if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); - if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); - if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); - } - - return sign * parseInt(value, 10); - } - - function isInteger(object) { - return (Object.prototype.toString.call(object)) === '[object Number]' && - (object % 1 === 0 && !common.isNegativeZero(object)); - } - - var int = new type('tag:yaml.org,2002:int', { - kind: 'scalar', - resolve: resolveYamlInteger, - construct: constructYamlInteger, - predicate: isInteger, - represent: { - binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, - octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, - decimal: function (obj) { return obj.toString(10); }, - /* eslint-disable max-len */ - hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } - }, - defaultStyle: 'decimal', - styleAliases: { - binary: [ 2, 'bin' ], - octal: [ 8, 'oct' ], - decimal: [ 10, 'dec' ], - hexadecimal: [ 16, 'hex' ] - } - }); - - var YAML_FLOAT_PATTERN = new RegExp( - // 2.5e4, 2.5 and integers - '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + - // .2e4, .2 - // special case, seems not from spec - '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + - // .inf - '|[-+]?\\.(?:inf|Inf|INF)' + - // .nan - '|\\.(?:nan|NaN|NAN))$'); - - function resolveYamlFloat(data) { - if (data === null) return false; - - if (!YAML_FLOAT_PATTERN.test(data) || - // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === '_') { - return false; - } - - return true; - } - - function constructYamlFloat(data) { - var value, sign; - - value = data.replace(/_/g, '').toLowerCase(); - sign = value[0] === '-' ? -1 : 1; - - if ('+-'.indexOf(value[0]) >= 0) { - value = value.slice(1); - } - - if (value === '.inf') { - return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; - - } else if (value === '.nan') { - return NaN; - } - return sign * parseFloat(value, 10); - } - - - var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; - - function representYamlFloat(object, style) { - var res; - - if (isNaN(object)) { - switch (style) { - case 'lowercase': return '.nan'; - case 'uppercase': return '.NAN'; - case 'camelcase': return '.NaN'; - } - } else if (Number.POSITIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '.inf'; - case 'uppercase': return '.INF'; - case 'camelcase': return '.Inf'; - } - } else if (Number.NEGATIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '-.inf'; - case 'uppercase': return '-.INF'; - case 'camelcase': return '-.Inf'; - } - } else if (common.isNegativeZero(object)) { - return '-0.0'; - } - - res = object.toString(10); - - // JS stringifier can build scientific format without dots: 5e-100, - // while YAML requres dot: 5.e-100. Fix it with simple hack - - return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; - } - - function isFloat(object) { - return (Object.prototype.toString.call(object) === '[object Number]') && - (object % 1 !== 0 || common.isNegativeZero(object)); - } - - var float = new type('tag:yaml.org,2002:float', { - kind: 'scalar', - resolve: resolveYamlFloat, - construct: constructYamlFloat, - predicate: isFloat, - represent: representYamlFloat, - defaultStyle: 'lowercase' - }); - - var json = failsafe.extend({ - implicit: [ - _null, - bool, - int, - float - ] - }); - - var core = json; - - var YAML_DATE_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9])' + // [2] month - '-([0-9][0-9])$'); // [3] day - - var YAML_TIMESTAMP_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9]?)' + // [2] month - '-([0-9][0-9]?)' + // [3] day - '(?:[Tt]|[ \\t]+)' + // ... - '([0-9][0-9]?)' + // [4] hour - ':([0-9][0-9])' + // [5] minute - ':([0-9][0-9])' + // [6] second - '(?:\\.([0-9]*))?' + // [7] fraction - '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour - '(?::([0-9][0-9]))?))?$'); // [11] tz_minute - - function resolveYamlTimestamp(data) { - if (data === null) return false; - if (YAML_DATE_REGEXP.exec(data) !== null) return true; - if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; - return false; - } - - function constructYamlTimestamp(data) { - var match, year, month, day, hour, minute, second, fraction = 0, - delta = null, tz_hour, tz_minute, date; - - match = YAML_DATE_REGEXP.exec(data); - if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); - - if (match === null) throw new Error('Date resolve error'); - - // match: [1] year [2] month [3] day - - year = +(match[1]); - month = +(match[2]) - 1; // JS month starts with 0 - day = +(match[3]); - - if (!match[4]) { // no hour - return new Date(Date.UTC(year, month, day)); - } - - // match: [4] hour [5] minute [6] second [7] fraction - - hour = +(match[4]); - minute = +(match[5]); - second = +(match[6]); - - if (match[7]) { - fraction = match[7].slice(0, 3); - while (fraction.length < 3) { // milli-seconds - fraction += '0'; - } - fraction = +fraction; - } - - // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute - - if (match[9]) { - tz_hour = +(match[10]); - tz_minute = +(match[11] || 0); - delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds - if (match[9] === '-') delta = -delta; - } - - date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); - - if (delta) date.setTime(date.getTime() - delta); - - return date; - } - - function representYamlTimestamp(object /*, style*/) { - return object.toISOString(); - } - - var timestamp = new type('tag:yaml.org,2002:timestamp', { - kind: 'scalar', - resolve: resolveYamlTimestamp, - construct: constructYamlTimestamp, - instanceOf: Date, - represent: representYamlTimestamp - }); - - function resolveYamlMerge(data) { - return data === '<<' || data === null; - } - - var merge = new type('tag:yaml.org,2002:merge', { - kind: 'scalar', - resolve: resolveYamlMerge - }); - - /*eslint-disable no-bitwise*/ - - - - - - // [ 64, 65, 66 ] -> [ padding, CR, LF ] - var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; - - - function resolveYamlBinary(data) { - if (data === null) return false; - - var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; - - // Convert one by one. - for (idx = 0; idx < max; idx++) { - code = map.indexOf(data.charAt(idx)); - - // Skip CR/LF - if (code > 64) continue; - - // Fail on illegal characters - if (code < 0) return false; - - bitlen += 6; - } - - // If there are any bits left, source was corrupted - return (bitlen % 8) === 0; - } - - function constructYamlBinary(data) { - var idx, tailbits, - input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan - max = input.length, - map = BASE64_MAP, - bits = 0, - result = []; - - // Collect by 6*4 bits (3 bytes) - - for (idx = 0; idx < max; idx++) { - if ((idx % 4 === 0) && idx) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } - - bits = (bits << 6) | map.indexOf(input.charAt(idx)); - } - - // Dump tail - - tailbits = (max % 4) * 6; - - if (tailbits === 0) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } else if (tailbits === 18) { - result.push((bits >> 10) & 0xFF); - result.push((bits >> 2) & 0xFF); - } else if (tailbits === 12) { - result.push((bits >> 4) & 0xFF); - } - - return new Uint8Array(result); - } - - function representYamlBinary(object /*, style*/) { - var result = '', bits = 0, idx, tail, - max = object.length, - map = BASE64_MAP; - - // Convert every three bytes to 4 ASCII characters. - - for (idx = 0; idx < max; idx++) { - if ((idx % 3 === 0) && idx) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } - - bits = (bits << 8) + object[idx]; - } - - // Dump tail - - tail = max % 3; - - if (tail === 0) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } else if (tail === 2) { - result += map[(bits >> 10) & 0x3F]; - result += map[(bits >> 4) & 0x3F]; - result += map[(bits << 2) & 0x3F]; - result += map[64]; - } else if (tail === 1) { - result += map[(bits >> 2) & 0x3F]; - result += map[(bits << 4) & 0x3F]; - result += map[64]; - result += map[64]; - } - - return result; - } - - function isBinary(obj) { - return Object.prototype.toString.call(obj) === '[object Uint8Array]'; - } - - var binary = new type('tag:yaml.org,2002:binary', { - kind: 'scalar', - resolve: resolveYamlBinary, - construct: constructYamlBinary, - predicate: isBinary, - represent: representYamlBinary - }); - - var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; - var _toString$2 = Object.prototype.toString; - - function resolveYamlOmap(data) { - if (data === null) return true; - - var objectKeys = [], index, length, pair, pairKey, pairHasKey, - object = data; - - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - pairHasKey = false; - - if (_toString$2.call(pair) !== '[object Object]') return false; - - for (pairKey in pair) { - if (_hasOwnProperty$3.call(pair, pairKey)) { - if (!pairHasKey) pairHasKey = true; - else return false; - } - } - - if (!pairHasKey) return false; - - if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); - else return false; - } - - return true; - } - - function constructYamlOmap(data) { - return data !== null ? data : []; - } - - var omap = new type('tag:yaml.org,2002:omap', { - kind: 'sequence', - resolve: resolveYamlOmap, - construct: constructYamlOmap - }); - - var _toString$1 = Object.prototype.toString; - - function resolveYamlPairs(data) { - if (data === null) return true; - - var index, length, pair, keys, result, - object = data; - - result = new Array(object.length); - - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - - if (_toString$1.call(pair) !== '[object Object]') return false; - - keys = Object.keys(pair); - - if (keys.length !== 1) return false; - - result[index] = [ keys[0], pair[keys[0]] ]; - } - - return true; - } - - function constructYamlPairs(data) { - if (data === null) return []; - - var index, length, pair, keys, result, - object = data; - - result = new Array(object.length); - - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - - keys = Object.keys(pair); - - result[index] = [ keys[0], pair[keys[0]] ]; - } - - return result; - } - - var pairs = new type('tag:yaml.org,2002:pairs', { - kind: 'sequence', - resolve: resolveYamlPairs, - construct: constructYamlPairs - }); - - var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; - - function resolveYamlSet(data) { - if (data === null) return true; - - var key, object = data; - - for (key in object) { - if (_hasOwnProperty$2.call(object, key)) { - if (object[key] !== null) return false; - } - } - - return true; - } - - function constructYamlSet(data) { - return data !== null ? data : {}; - } - - var set = new type('tag:yaml.org,2002:set', { - kind: 'mapping', - resolve: resolveYamlSet, - construct: constructYamlSet - }); - - var _default = core.extend({ - implicit: [ - timestamp, - merge - ], - explicit: [ - binary, - omap, - pairs, - set - ] - }); - - /*eslint-disable max-len,no-use-before-define*/ - - - - - - - - var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; - - - var CONTEXT_FLOW_IN = 1; - var CONTEXT_FLOW_OUT = 2; - var CONTEXT_BLOCK_IN = 3; - var CONTEXT_BLOCK_OUT = 4; - - - var CHOMPING_CLIP = 1; - var CHOMPING_STRIP = 2; - var CHOMPING_KEEP = 3; - - - var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; - var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; - var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; - var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; - var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; - - - function _class(obj) { return Object.prototype.toString.call(obj); } - - function is_EOL(c) { - return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); - } - - function is_WHITE_SPACE(c) { - return (c === 0x09/* Tab */) || (c === 0x20/* Space */); - } - - function is_WS_OR_EOL(c) { - return (c === 0x09/* Tab */) || - (c === 0x20/* Space */) || - (c === 0x0A/* LF */) || - (c === 0x0D/* CR */); - } - - function is_FLOW_INDICATOR(c) { - return c === 0x2C/* , */ || - c === 0x5B/* [ */ || - c === 0x5D/* ] */ || - c === 0x7B/* { */ || - c === 0x7D/* } */; - } - - function fromHexCode(c) { - var lc; - - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - /*eslint-disable no-bitwise*/ - lc = c | 0x20; - - if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { - return lc - 0x61 + 10; - } - - return -1; - } - - function escapedHexLen(c) { - if (c === 0x78/* x */) { return 2; } - if (c === 0x75/* u */) { return 4; } - if (c === 0x55/* U */) { return 8; } - return 0; - } - - function fromDecimalCode(c) { - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - return -1; - } - - function simpleEscapeSequence(c) { - /* eslint-disable indent */ - return (c === 0x30/* 0 */) ? '\x00' : - (c === 0x61/* a */) ? '\x07' : - (c === 0x62/* b */) ? '\x08' : - (c === 0x74/* t */) ? '\x09' : - (c === 0x09/* Tab */) ? '\x09' : - (c === 0x6E/* n */) ? '\x0A' : - (c === 0x76/* v */) ? '\x0B' : - (c === 0x66/* f */) ? '\x0C' : - (c === 0x72/* r */) ? '\x0D' : - (c === 0x65/* e */) ? '\x1B' : - (c === 0x20/* Space */) ? ' ' : - (c === 0x22/* " */) ? '\x22' : - (c === 0x2F/* / */) ? '/' : - (c === 0x5C/* \ */) ? '\x5C' : - (c === 0x4E/* N */) ? '\x85' : - (c === 0x5F/* _ */) ? '\xA0' : - (c === 0x4C/* L */) ? '\u2028' : - (c === 0x50/* P */) ? '\u2029' : ''; - } - - function charFromCodepoint(c) { - if (c <= 0xFFFF) { - return String.fromCharCode(c); - } - // Encode UTF-16 surrogate pair - // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF - return String.fromCharCode( - ((c - 0x010000) >> 10) + 0xD800, - ((c - 0x010000) & 0x03FF) + 0xDC00 - ); - } - - // set a property of a literal object, while protecting against prototype pollution, - // see https://github.com/nodeca/js-yaml/issues/164 for more details - function setProperty(object, key, value) { - // used for this specific key only because Object.defineProperty is slow - if (key === '__proto__') { - Object.defineProperty(object, key, { - configurable: true, - enumerable: true, - writable: true, - value: value - }); - } else { - object[key] = value; - } - } - - var simpleEscapeCheck = new Array(256); // integer, for fast access - var simpleEscapeMap = new Array(256); - for (var i = 0; i < 256; i++) { - simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; - simpleEscapeMap[i] = simpleEscapeSequence(i); - } - - - function State$1(input, options) { - this.input = input; - - this.filename = options['filename'] || null; - this.schema = options['schema'] || _default; - this.onWarning = options['onWarning'] || null; - // (Hidden) Remove? makes the loader to expect YAML 1.1 documents - // if such documents have no explicit %YAML directive - this.legacy = options['legacy'] || false; - - this.json = options['json'] || false; - this.listener = options['listener'] || null; - - this.implicitTypes = this.schema.compiledImplicit; - this.typeMap = this.schema.compiledTypeMap; - - this.length = input.length; - this.position = 0; - this.line = 0; - this.lineStart = 0; - this.lineIndent = 0; - - // position of first leading tab in the current line, - // used to make sure there are no tabs in the indentation - this.firstTabInLine = -1; - - this.documents = []; - - /* - this.version; - this.checkLineBreaks; - this.tagMap; - this.anchorMap; - this.tag; - this.anchor; - this.kind; - this.result;*/ - - } - - - function generateError(state, message) { - var mark = { - name: state.filename, - buffer: state.input.slice(0, -1), // omit trailing \0 - position: state.position, - line: state.line, - column: state.position - state.lineStart - }; - - mark.snippet = snippet(mark); - - return new exception(message, mark); - } - - function throwError(state, message) { - throw generateError(state, message); - } - - function throwWarning(state, message) { - if (state.onWarning) { - state.onWarning.call(null, generateError(state, message)); - } - } - - - var directiveHandlers = { - - YAML: function handleYamlDirective(state, name, args) { - - var match, major, minor; - - if (state.version !== null) { - throwError(state, 'duplication of %YAML directive'); - } - - if (args.length !== 1) { - throwError(state, 'YAML directive accepts exactly one argument'); - } - - match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); - - if (match === null) { - throwError(state, 'ill-formed argument of the YAML directive'); - } - - major = parseInt(match[1], 10); - minor = parseInt(match[2], 10); - - if (major !== 1) { - throwError(state, 'unacceptable YAML version of the document'); - } - - state.version = args[0]; - state.checkLineBreaks = (minor < 2); - - if (minor !== 1 && minor !== 2) { - throwWarning(state, 'unsupported YAML version of the document'); - } - }, - - TAG: function handleTagDirective(state, name, args) { - - var handle, prefix; - - if (args.length !== 2) { - throwError(state, 'TAG directive accepts exactly two arguments'); - } - - handle = args[0]; - prefix = args[1]; - - if (!PATTERN_TAG_HANDLE.test(handle)) { - throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); - } - - if (_hasOwnProperty$1.call(state.tagMap, handle)) { - throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); - } - - if (!PATTERN_TAG_URI.test(prefix)) { - throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); - } - - try { - prefix = decodeURIComponent(prefix); - } catch (err) { - throwError(state, 'tag prefix is malformed: ' + prefix); - } - - state.tagMap[handle] = prefix; - } - }; - - - function captureSegment(state, start, end, checkJson) { - var _position, _length, _character, _result; - - if (start < end) { - _result = state.input.slice(start, end); - - if (checkJson) { - for (_position = 0, _length = _result.length; _position < _length; _position += 1) { - _character = _result.charCodeAt(_position); - if (!(_character === 0x09 || - (0x20 <= _character && _character <= 0x10FFFF))) { - throwError(state, 'expected valid JSON character'); - } - } - } else if (PATTERN_NON_PRINTABLE.test(_result)) { - throwError(state, 'the stream contains non-printable characters'); - } - - state.result += _result; - } - } - - function mergeMappings(state, destination, source, overridableKeys) { - var sourceKeys, key, index, quantity; - - if (!common.isObject(source)) { - throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); - } - - sourceKeys = Object.keys(source); - - for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { - key = sourceKeys[index]; - - if (!_hasOwnProperty$1.call(destination, key)) { - setProperty(destination, key, source[key]); - overridableKeys[key] = true; - } - } - } - - function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, - startLine, startLineStart, startPos) { - - var index, quantity; - - // The output is a plain object here, so keys can only be strings. - // We need to convert keyNode to a string, but doing so can hang the process - // (deeply nested arrays that explode exponentially using aliases). - if (Array.isArray(keyNode)) { - keyNode = Array.prototype.slice.call(keyNode); - - for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { - if (Array.isArray(keyNode[index])) { - throwError(state, 'nested arrays are not supported inside keys'); - } - - if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { - keyNode[index] = '[object Object]'; - } - } - } - - // Avoid code execution in load() via toString property - // (still use its own toString for arrays, timestamps, - // and whatever user schema extensions happen to have @@toStringTag) - if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { - keyNode = '[object Object]'; - } - - - keyNode = String(keyNode); - - if (_result === null) { - _result = {}; - } - - if (keyTag === 'tag:yaml.org,2002:merge') { - if (Array.isArray(valueNode)) { - for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { - mergeMappings(state, _result, valueNode[index], overridableKeys); - } - } else { - mergeMappings(state, _result, valueNode, overridableKeys); - } - } else { - if (!state.json && - !_hasOwnProperty$1.call(overridableKeys, keyNode) && - _hasOwnProperty$1.call(_result, keyNode)) { - state.line = startLine || state.line; - state.lineStart = startLineStart || state.lineStart; - state.position = startPos || state.position; - throwError(state, 'duplicated mapping key'); - } - - setProperty(_result, keyNode, valueNode); - delete overridableKeys[keyNode]; - } - - return _result; - } - - function readLineBreak(state) { - var ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x0A/* LF */) { - state.position++; - } else if (ch === 0x0D/* CR */) { - state.position++; - if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { - state.position++; - } - } else { - throwError(state, 'a line break is expected'); - } - - state.line += 1; - state.lineStart = state.position; - state.firstTabInLine = -1; - } - - function skipSeparationSpace(state, allowComments, checkIndent) { - var lineBreaks = 0, - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { - state.firstTabInLine = state.position; - } - ch = state.input.charCodeAt(++state.position); - } - - if (allowComments && ch === 0x23/* # */) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); - } - - if (is_EOL(ch)) { - readLineBreak(state); - - ch = state.input.charCodeAt(state.position); - lineBreaks++; - state.lineIndent = 0; - - while (ch === 0x20/* Space */) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - } else { - break; - } - } - - if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { - throwWarning(state, 'deficient indentation'); - } - - return lineBreaks; - } - - function testDocumentSeparator(state) { - var _position = state.position, - ch; - - ch = state.input.charCodeAt(_position); - - // Condition state.position === state.lineStart is tested - // in parent on each call, for efficiency. No needs to test here again. - if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && - ch === state.input.charCodeAt(_position + 1) && - ch === state.input.charCodeAt(_position + 2)) { - - _position += 3; - - ch = state.input.charCodeAt(_position); - - if (ch === 0 || is_WS_OR_EOL(ch)) { - return true; - } - } - - return false; - } - - function writeFoldedLines(state, count) { - if (count === 1) { - state.result += ' '; - } else if (count > 1) { - state.result += common.repeat('\n', count - 1); - } - } - - - function readPlainScalar(state, nodeIndent, withinFlowCollection) { - var preceding, - following, - captureStart, - captureEnd, - hasPendingContent, - _line, - _lineStart, - _lineIndent, - _kind = state.kind, - _result = state.result, - ch; - - ch = state.input.charCodeAt(state.position); - - if (is_WS_OR_EOL(ch) || - is_FLOW_INDICATOR(ch) || - ch === 0x23/* # */ || - ch === 0x26/* & */ || - ch === 0x2A/* * */ || - ch === 0x21/* ! */ || - ch === 0x7C/* | */ || - ch === 0x3E/* > */ || - ch === 0x27/* ' */ || - ch === 0x22/* " */ || - ch === 0x25/* % */ || - ch === 0x40/* @ */ || - ch === 0x60/* ` */) { - return false; - } - - if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - return false; - } - } - - state.kind = 'scalar'; - state.result = ''; - captureStart = captureEnd = state.position; - hasPendingContent = false; - - while (ch !== 0) { - if (ch === 0x3A/* : */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - break; - } - - } else if (ch === 0x23/* # */) { - preceding = state.input.charCodeAt(state.position - 1); - - if (is_WS_OR_EOL(preceding)) { - break; - } - - } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || - withinFlowCollection && is_FLOW_INDICATOR(ch)) { - break; - - } else if (is_EOL(ch)) { - _line = state.line; - _lineStart = state.lineStart; - _lineIndent = state.lineIndent; - skipSeparationSpace(state, false, -1); - - if (state.lineIndent >= nodeIndent) { - hasPendingContent = true; - ch = state.input.charCodeAt(state.position); - continue; - } else { - state.position = captureEnd; - state.line = _line; - state.lineStart = _lineStart; - state.lineIndent = _lineIndent; - break; - } - } - - if (hasPendingContent) { - captureSegment(state, captureStart, captureEnd, false); - writeFoldedLines(state, state.line - _line); - captureStart = captureEnd = state.position; - hasPendingContent = false; - } - - if (!is_WHITE_SPACE(ch)) { - captureEnd = state.position + 1; - } - - ch = state.input.charCodeAt(++state.position); - } - - captureSegment(state, captureStart, captureEnd, false); - - if (state.result) { - return true; - } - - state.kind = _kind; - state.result = _result; - return false; - } - - function readSingleQuotedScalar(state, nodeIndent) { - var ch, - captureStart, captureEnd; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x27/* ' */) { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x27/* ' */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x27/* ' */) { - captureStart = state.position; - state.position++; - captureEnd = state.position; - } else { - return true; - } - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a single quoted scalar'); - - } else { - state.position++; - captureEnd = state.position; - } - } - - throwError(state, 'unexpected end of the stream within a single quoted scalar'); - } - - function readDoubleQuotedScalar(state, nodeIndent) { - var captureStart, - captureEnd, - hexLength, - hexResult, - tmp, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x22/* " */) { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x22/* " */) { - captureSegment(state, captureStart, state.position, true); - state.position++; - return true; - - } else if (ch === 0x5C/* \ */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - - if (is_EOL(ch)) { - skipSeparationSpace(state, false, nodeIndent); - - // TODO: rework to inline fn with no type cast? - } else if (ch < 256 && simpleEscapeCheck[ch]) { - state.result += simpleEscapeMap[ch]; - state.position++; - - } else if ((tmp = escapedHexLen(ch)) > 0) { - hexLength = tmp; - hexResult = 0; - - for (; hexLength > 0; hexLength--) { - ch = state.input.charCodeAt(++state.position); - - if ((tmp = fromHexCode(ch)) >= 0) { - hexResult = (hexResult << 4) + tmp; - - } else { - throwError(state, 'expected hexadecimal character'); - } - } - - state.result += charFromCodepoint(hexResult); - - state.position++; - - } else { - throwError(state, 'unknown escape sequence'); - } - - captureStart = captureEnd = state.position; - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a double quoted scalar'); - - } else { - state.position++; - captureEnd = state.position; - } - } - - throwError(state, 'unexpected end of the stream within a double quoted scalar'); - } - - function readFlowCollection(state, nodeIndent) { - var readNext = true, - _line, - _lineStart, - _pos, - _tag = state.tag, - _result, - _anchor = state.anchor, - following, - terminator, - isPair, - isExplicitPair, - isMapping, - overridableKeys = Object.create(null), - keyNode, - keyTag, - valueNode, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x5B/* [ */) { - terminator = 0x5D;/* ] */ - isMapping = false; - _result = []; - } else if (ch === 0x7B/* { */) { - terminator = 0x7D;/* } */ - isMapping = true; - _result = {}; - } else { - return false; - } - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(++state.position); - - while (ch !== 0) { - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if (ch === terminator) { - state.position++; - state.tag = _tag; - state.anchor = _anchor; - state.kind = isMapping ? 'mapping' : 'sequence'; - state.result = _result; - return true; - } else if (!readNext) { - throwError(state, 'missed comma between flow collection entries'); - } else if (ch === 0x2C/* , */) { - // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 - throwError(state, "expected the node content, but found ','"); - } - - keyTag = keyNode = valueNode = null; - isPair = isExplicitPair = false; - - if (ch === 0x3F/* ? */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following)) { - isPair = isExplicitPair = true; - state.position++; - skipSeparationSpace(state, true, nodeIndent); - } - } - - _line = state.line; // Save the current line. - _lineStart = state.lineStart; - _pos = state.position; - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - keyTag = state.tag; - keyNode = state.result; - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { - isPair = true; - ch = state.input.charCodeAt(++state.position); - skipSeparationSpace(state, true, nodeIndent); - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - valueNode = state.result; - } - - if (isMapping) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); - } else if (isPair) { - _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); - } else { - _result.push(keyNode); - } - - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x2C/* , */) { - readNext = true; - ch = state.input.charCodeAt(++state.position); - } else { - readNext = false; - } - } - - throwError(state, 'unexpected end of the stream within a flow collection'); - } - - function readBlockScalar(state, nodeIndent) { - var captureStart, - folding, - chomping = CHOMPING_CLIP, - didReadContent = false, - detectedIndent = false, - textIndent = nodeIndent, - emptyLines = 0, - atMoreIndented = false, - tmp, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x7C/* | */) { - folding = false; - } else if (ch === 0x3E/* > */) { - folding = true; - } else { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - - while (ch !== 0) { - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { - if (CHOMPING_CLIP === chomping) { - chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; - } else { - throwError(state, 'repeat of a chomping mode identifier'); - } - - } else if ((tmp = fromDecimalCode(ch)) >= 0) { - if (tmp === 0) { - throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); - } else if (!detectedIndent) { - textIndent = nodeIndent + tmp - 1; - detectedIndent = true; - } else { - throwError(state, 'repeat of an indentation width identifier'); - } - - } else { - break; - } - } - - if (is_WHITE_SPACE(ch)) { - do { ch = state.input.charCodeAt(++state.position); } - while (is_WHITE_SPACE(ch)); - - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (!is_EOL(ch) && (ch !== 0)); - } - } - - while (ch !== 0) { - readLineBreak(state); - state.lineIndent = 0; - - ch = state.input.charCodeAt(state.position); - - while ((!detectedIndent || state.lineIndent < textIndent) && - (ch === 0x20/* Space */)) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - - if (!detectedIndent && state.lineIndent > textIndent) { - textIndent = state.lineIndent; - } - - if (is_EOL(ch)) { - emptyLines++; - continue; - } - - // End of the scalar. - if (state.lineIndent < textIndent) { - - // Perform the chomping. - if (chomping === CHOMPING_KEEP) { - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } else if (chomping === CHOMPING_CLIP) { - if (didReadContent) { // i.e. only if the scalar is not empty. - state.result += '\n'; - } - } - - // Break this `while` cycle and go to the funciton's epilogue. - break; - } - - // Folded style: use fancy rules to handle line breaks. - if (folding) { - - // Lines starting with white space characters (more-indented lines) are not folded. - if (is_WHITE_SPACE(ch)) { - atMoreIndented = true; - // except for the first content line (cf. Example 8.1) - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - - // End of more-indented block. - } else if (atMoreIndented) { - atMoreIndented = false; - state.result += common.repeat('\n', emptyLines + 1); - - // Just one line break - perceive as the same line. - } else if (emptyLines === 0) { - if (didReadContent) { // i.e. only if we have already read some scalar content. - state.result += ' '; - } - - // Several line breaks - perceive as different lines. - } else { - state.result += common.repeat('\n', emptyLines); - } - - // Literal style: just add exact number of line breaks between content lines. - } else { - // Keep all line breaks except the header line break. - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } - - didReadContent = true; - detectedIndent = true; - emptyLines = 0; - captureStart = state.position; - - while (!is_EOL(ch) && (ch !== 0)) { - ch = state.input.charCodeAt(++state.position); - } - - captureSegment(state, captureStart, state.position, false); - } - - return true; - } - - function readBlockSequence(state, nodeIndent) { - var _line, - _tag = state.tag, - _anchor = state.anchor, - _result = [], - following, - detected = false, - ch; - - // there is a leading tab before this token, so it can't be a block sequence/mapping; - // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - if (state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); - } - - if (ch !== 0x2D/* - */) { - break; - } - - following = state.input.charCodeAt(state.position + 1); - - if (!is_WS_OR_EOL(following)) { - break; - } - - detected = true; - state.position++; - - if (skipSeparationSpace(state, true, -1)) { - if (state.lineIndent <= nodeIndent) { - _result.push(null); - ch = state.input.charCodeAt(state.position); - continue; - } - } - - _line = state.line; - composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); - _result.push(state.result); - skipSeparationSpace(state, true, -1); - - ch = state.input.charCodeAt(state.position); - - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a sequence entry'); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'sequence'; - state.result = _result; - return true; - } - return false; - } - - function readBlockMapping(state, nodeIndent, flowIndent) { - var following, - allowCompact, - _line, - _keyLine, - _keyLineStart, - _keyPos, - _tag = state.tag, - _anchor = state.anchor, - _result = {}, - overridableKeys = Object.create(null), - keyTag = null, - keyNode = null, - valueNode = null, - atExplicitKey = false, - detected = false, - ch; - - // there is a leading tab before this token, so it can't be a block sequence/mapping; - // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - if (!atExplicitKey && state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); - } - - following = state.input.charCodeAt(state.position + 1); - _line = state.line; // Save the current line. - - // - // Explicit notation case. There are two separate blocks: - // first for the key (denoted by "?") and second for the value (denoted by ":") - // - if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { - - if (ch === 0x3F/* ? */) { - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - - detected = true; - atExplicitKey = true; - allowCompact = true; - - } else if (atExplicitKey) { - // i.e. 0x3A/* : */ === character after the explicit key. - atExplicitKey = false; - allowCompact = true; - - } else { - throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); - } - - state.position += 1; - ch = following; - - // - // Implicit notation case. Flow-style node as the key first, then ":", and the value. - // - } else { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - - if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { - // Neither implicit nor explicit notation. - // Reading is done. Go to the epilogue. - break; - } - - if (state.line === _line) { - ch = state.input.charCodeAt(state.position); - - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (ch === 0x3A/* : */) { - ch = state.input.charCodeAt(++state.position); - - if (!is_WS_OR_EOL(ch)) { - throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); - } - - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - - detected = true; - atExplicitKey = false; - allowCompact = false; - keyTag = state.tag; - keyNode = state.result; - - } else if (detected) { - throwError(state, 'can not read an implicit mapping pair; a colon is missed'); - - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. - } - - } else if (detected) { - throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); - - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. - } - } - - // - // Common reading code for both explicit and implicit notations. - // - if (state.line === _line || state.lineIndent > nodeIndent) { - if (atExplicitKey) { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - } - - if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { - if (atExplicitKey) { - keyNode = state.result; - } else { - valueNode = state.result; - } - } - - if (!atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); - } - - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a mapping entry'); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - - // - // Epilogue. - // - - // Special case: last mapping's node contains only the key in explicit notation. - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - } - - // Expose the resulting mapping. - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'mapping'; - state.result = _result; - } - - return detected; - } - - function readTagProperty(state) { - var _position, - isVerbatim = false, - isNamed = false, - tagHandle, - tagName, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x21/* ! */) return false; - - if (state.tag !== null) { - throwError(state, 'duplication of a tag property'); - } - - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x3C/* < */) { - isVerbatim = true; - ch = state.input.charCodeAt(++state.position); - - } else if (ch === 0x21/* ! */) { - isNamed = true; - tagHandle = '!!'; - ch = state.input.charCodeAt(++state.position); - - } else { - tagHandle = '!'; - } - - _position = state.position; - - if (isVerbatim) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && ch !== 0x3E/* > */); - - if (state.position < state.length) { - tagName = state.input.slice(_position, state.position); - ch = state.input.charCodeAt(++state.position); - } else { - throwError(state, 'unexpected end of the stream within a verbatim tag'); - } - } else { - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - - if (ch === 0x21/* ! */) { - if (!isNamed) { - tagHandle = state.input.slice(_position - 1, state.position + 1); - - if (!PATTERN_TAG_HANDLE.test(tagHandle)) { - throwError(state, 'named tag handle cannot contain such characters'); - } - - isNamed = true; - _position = state.position + 1; - } else { - throwError(state, 'tag suffix cannot contain exclamation marks'); - } - } - - ch = state.input.charCodeAt(++state.position); - } - - tagName = state.input.slice(_position, state.position); - - if (PATTERN_FLOW_INDICATORS.test(tagName)) { - throwError(state, 'tag suffix cannot contain flow indicator characters'); - } - } - - if (tagName && !PATTERN_TAG_URI.test(tagName)) { - throwError(state, 'tag name cannot contain such characters: ' + tagName); - } - - try { - tagName = decodeURIComponent(tagName); - } catch (err) { - throwError(state, 'tag name is malformed: ' + tagName); - } - - if (isVerbatim) { - state.tag = tagName; - - } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { - state.tag = state.tagMap[tagHandle] + tagName; - - } else if (tagHandle === '!') { - state.tag = '!' + tagName; - - } else if (tagHandle === '!!') { - state.tag = 'tag:yaml.org,2002:' + tagName; - - } else { - throwError(state, 'undeclared tag handle "' + tagHandle + '"'); - } - - return true; - } - - function readAnchorProperty(state) { - var _position, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x26/* & */) return false; - - if (state.anchor !== null) { - throwError(state, 'duplication of an anchor property'); - } - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an anchor node must contain at least one character'); - } - - state.anchor = state.input.slice(_position, state.position); - return true; - } - - function readAlias(state) { - var _position, alias, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x2A/* * */) return false; - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an alias node must contain at least one character'); - } - - alias = state.input.slice(_position, state.position); - - if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { - throwError(state, 'unidentified alias "' + alias + '"'); - } - - state.result = state.anchorMap[alias]; - skipSeparationSpace(state, true, -1); - return true; - } - - function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { - var allowBlockStyles, - allowBlockScalars, - allowBlockCollections, - indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } - } - - if (indentStatus === 1) { - while (readTagProperty(state) || readAnchorProperty(state)) { - if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; - allowBlockCollections = allowBlockStyles; - - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } else { - allowBlockCollections = false; - } - } - } - - if (allowBlockCollections) { - allowBlockCollections = atNewLine || allowCompact; - } - - if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { - if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { - flowIndent = parentIndent; - } else { - flowIndent = parentIndent + 1; - } - - blockIndent = state.position - state.lineStart; - - if (indentStatus === 1) { - if (allowBlockCollections && - (readBlockSequence(state, blockIndent) || - readBlockMapping(state, blockIndent, flowIndent)) || - readFlowCollection(state, flowIndent)) { - hasContent = true; - } else { - if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || - readSingleQuotedScalar(state, flowIndent) || - readDoubleQuotedScalar(state, flowIndent)) { - hasContent = true; - - } else if (readAlias(state)) { - hasContent = true; - - if (state.tag !== null || state.anchor !== null) { - throwError(state, 'alias node should not have any properties'); - } - - } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { - hasContent = true; - - if (state.tag === null) { - state.tag = '?'; - } - } - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } - } else if (indentStatus === 0) { - // Special case: block sequences are allowed to have same indentation level as the parent. - // http://www.yaml.org/spec/1.2/spec.html#id2799784 - hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); - } - } - - if (state.tag === null) { - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - - } else if (state.tag === '?') { - // Implicit resolving is not allowed for non-scalar types, and '?' - // non-specific tag is only automatically assigned to plain scalars. - // - // We only need to check kind conformity in case user explicitly assigns '?' - // tag, for example like this: "! [0]" - // - if (state.result !== null && state.kind !== 'scalar') { - throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); - } - - for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { - type = state.implicitTypes[typeIndex]; - - if (type.resolve(state.result)) { // `state.result` updated in resolver if matched - state.result = type.construct(state.result); - state.tag = type.tag; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - break; - } - } - } else if (state.tag !== '!') { - if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) { - type = state.typeMap[state.kind || 'fallback'][state.tag]; - } else { - // looking for multi type - type = null; - typeList = state.typeMap.multi[state.kind || 'fallback']; - - for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { - if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { - type = typeList[typeIndex]; - break; - } - } - } - - if (!type) { - throwError(state, 'unknown tag !<' + state.tag + '>'); - } - - if (state.result !== null && type.kind !== state.kind) { - throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); - } - - if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched - throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); - } else { - state.result = type.construct(state.result, state.tag); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } - } - - if (state.listener !== null) { - state.listener('close', state); - } - return state.tag !== null || state.anchor !== null || hasContent; - } - - function readDocument(state) { - var documentStart = state.position, - _position, - directiveName, - directiveArgs, - hasDirectives = false, - ch; - - state.version = null; - state.checkLineBreaks = state.legacy; - state.tagMap = Object.create(null); - state.anchorMap = Object.create(null); - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - skipSeparationSpace(state, true, -1); - - ch = state.input.charCodeAt(state.position); - - if (state.lineIndent > 0 || ch !== 0x25/* % */) { - break; - } - - hasDirectives = true; - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - directiveName = state.input.slice(_position, state.position); - directiveArgs = []; - - if (directiveName.length < 1) { - throwError(state, 'directive name must not be less than one character in length'); - } - - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && !is_EOL(ch)); - break; - } - - if (is_EOL(ch)) break; - - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - directiveArgs.push(state.input.slice(_position, state.position)); - } - - if (ch !== 0) readLineBreak(state); - - if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { - directiveHandlers[directiveName](state, directiveName, directiveArgs); - } else { - throwWarning(state, 'unknown document directive "' + directiveName + '"'); - } - } - - skipSeparationSpace(state, true, -1); - - if (state.lineIndent === 0 && - state.input.charCodeAt(state.position) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - - } else if (hasDirectives) { - throwError(state, 'directives end mark is expected'); - } - - composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); - skipSeparationSpace(state, true, -1); - - if (state.checkLineBreaks && - PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { - throwWarning(state, 'non-ASCII line breaks are interpreted as content'); - } - - state.documents.push(state.result); - - if (state.position === state.lineStart && testDocumentSeparator(state)) { - - if (state.input.charCodeAt(state.position) === 0x2E/* . */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - } - return; - } - - if (state.position < (state.length - 1)) { - throwError(state, 'end of the stream or a document separator is expected'); - } else { - return; - } - } - - - function loadDocuments(input, options) { - input = String(input); - options = options || {}; - - if (input.length !== 0) { - - // Add tailing `\n` if not exists - if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && - input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { - input += '\n'; - } - - // Strip BOM - if (input.charCodeAt(0) === 0xFEFF) { - input = input.slice(1); - } - } - - var state = new State$1(input, options); - - var nullpos = input.indexOf('\0'); - - if (nullpos !== -1) { - state.position = nullpos; - throwError(state, 'null byte is not allowed in input'); - } - - // Use 0 as string terminator. That significantly simplifies bounds check. - state.input += '\0'; - - while (state.input.charCodeAt(state.position) === 0x20/* Space */) { - state.lineIndent += 1; - state.position += 1; - } - - while (state.position < (state.length - 1)) { - readDocument(state); - } - - return state.documents; - } - - - function loadAll$1(input, iterator, options) { - if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { - options = iterator; - iterator = null; - } - - var documents = loadDocuments(input, options); - - if (typeof iterator !== 'function') { - return documents; - } - - for (var index = 0, length = documents.length; index < length; index += 1) { - iterator(documents[index]); - } - } - - - function load$1(input, options) { - var documents = loadDocuments(input, options); - - if (documents.length === 0) { - /*eslint-disable no-undefined*/ - return undefined; - } else if (documents.length === 1) { - return documents[0]; - } - throw new exception('expected a single document in the stream, but found more'); - } - - - var loadAll_1 = loadAll$1; - var load_1 = load$1; - - var loader = { - loadAll: loadAll_1, - load: load_1 - }; - - /*eslint-disable no-use-before-define*/ - - - - - - var _toString = Object.prototype.toString; - var _hasOwnProperty = Object.prototype.hasOwnProperty; - - var CHAR_BOM = 0xFEFF; - var CHAR_TAB = 0x09; /* Tab */ - var CHAR_LINE_FEED = 0x0A; /* LF */ - var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ - var CHAR_SPACE = 0x20; /* Space */ - var CHAR_EXCLAMATION = 0x21; /* ! */ - var CHAR_DOUBLE_QUOTE = 0x22; /* " */ - var CHAR_SHARP = 0x23; /* # */ - var CHAR_PERCENT = 0x25; /* % */ - var CHAR_AMPERSAND = 0x26; /* & */ - var CHAR_SINGLE_QUOTE = 0x27; /* ' */ - var CHAR_ASTERISK = 0x2A; /* * */ - var CHAR_COMMA = 0x2C; /* , */ - var CHAR_MINUS = 0x2D; /* - */ - var CHAR_COLON = 0x3A; /* : */ - var CHAR_EQUALS = 0x3D; /* = */ - var CHAR_GREATER_THAN = 0x3E; /* > */ - var CHAR_QUESTION = 0x3F; /* ? */ - var CHAR_COMMERCIAL_AT = 0x40; /* @ */ - var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ - var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ - var CHAR_GRAVE_ACCENT = 0x60; /* ` */ - var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ - var CHAR_VERTICAL_LINE = 0x7C; /* | */ - var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ - - var ESCAPE_SEQUENCES = {}; - - ESCAPE_SEQUENCES[0x00] = '\\0'; - ESCAPE_SEQUENCES[0x07] = '\\a'; - ESCAPE_SEQUENCES[0x08] = '\\b'; - ESCAPE_SEQUENCES[0x09] = '\\t'; - ESCAPE_SEQUENCES[0x0A] = '\\n'; - ESCAPE_SEQUENCES[0x0B] = '\\v'; - ESCAPE_SEQUENCES[0x0C] = '\\f'; - ESCAPE_SEQUENCES[0x0D] = '\\r'; - ESCAPE_SEQUENCES[0x1B] = '\\e'; - ESCAPE_SEQUENCES[0x22] = '\\"'; - ESCAPE_SEQUENCES[0x5C] = '\\\\'; - ESCAPE_SEQUENCES[0x85] = '\\N'; - ESCAPE_SEQUENCES[0xA0] = '\\_'; - ESCAPE_SEQUENCES[0x2028] = '\\L'; - ESCAPE_SEQUENCES[0x2029] = '\\P'; - - var DEPRECATED_BOOLEANS_SYNTAX = [ - 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', - 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' - ]; - - var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; - - function compileStyleMap(schema, map) { - var result, keys, index, length, tag, style, type; - - if (map === null) return {}; - - result = {}; - keys = Object.keys(map); - - for (index = 0, length = keys.length; index < length; index += 1) { - tag = keys[index]; - style = String(map[tag]); - - if (tag.slice(0, 2) === '!!') { - tag = 'tag:yaml.org,2002:' + tag.slice(2); - } - type = schema.compiledTypeMap['fallback'][tag]; - - if (type && _hasOwnProperty.call(type.styleAliases, style)) { - style = type.styleAliases[style]; - } - - result[tag] = style; - } - - return result; - } - - function encodeHex(character) { - var string, handle, length; - - string = character.toString(16).toUpperCase(); - - if (character <= 0xFF) { - handle = 'x'; - length = 2; - } else if (character <= 0xFFFF) { - handle = 'u'; - length = 4; - } else if (character <= 0xFFFFFFFF) { - handle = 'U'; - length = 8; - } else { - throw new exception('code point within a string may not be greater than 0xFFFFFFFF'); - } - - return '\\' + handle + common.repeat('0', length - string.length) + string; - } - - - var QUOTING_TYPE_SINGLE = 1, - QUOTING_TYPE_DOUBLE = 2; - - function State(options) { - this.schema = options['schema'] || _default; - this.indent = Math.max(1, (options['indent'] || 2)); - this.noArrayIndent = options['noArrayIndent'] || false; - this.skipInvalid = options['skipInvalid'] || false; - this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); - this.styleMap = compileStyleMap(this.schema, options['styles'] || null); - this.sortKeys = options['sortKeys'] || false; - this.lineWidth = options['lineWidth'] || 80; - this.noRefs = options['noRefs'] || false; - this.noCompatMode = options['noCompatMode'] || false; - this.condenseFlow = options['condenseFlow'] || false; - this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; - this.forceQuotes = options['forceQuotes'] || false; - this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; - - this.implicitTypes = this.schema.compiledImplicit; - this.explicitTypes = this.schema.compiledExplicit; - - this.tag = null; - this.result = ''; - - this.duplicates = []; - this.usedDuplicates = null; - } - - // Indents every line in a string. Empty lines (\n only) are not indented. - function indentString(string, spaces) { - var ind = common.repeat(' ', spaces), - position = 0, - next = -1, - result = '', - line, - length = string.length; - - while (position < length) { - next = string.indexOf('\n', position); - if (next === -1) { - line = string.slice(position); - position = length; - } else { - line = string.slice(position, next + 1); - position = next + 1; - } - - if (line.length && line !== '\n') result += ind; - - result += line; - } - - return result; - } - - function generateNextLine(state, level) { - return '\n' + common.repeat(' ', state.indent * level); - } - - function testImplicitResolving(state, str) { - var index, length, type; - - for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { - type = state.implicitTypes[index]; - - if (type.resolve(str)) { - return true; - } - } - - return false; - } - - // [33] s-white ::= s-space | s-tab - function isWhitespace(c) { - return c === CHAR_SPACE || c === CHAR_TAB; - } - - // Returns true if the character can be printed without escaping. - // From YAML 1.2: "any allowed characters known to be non-printable - // should also be escaped. [However,] This isn’t mandatory" - // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. - function isPrintable(c) { - return (0x00020 <= c && c <= 0x00007E) - || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) - || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) - || (0x10000 <= c && c <= 0x10FFFF); - } - - // [34] ns-char ::= nb-char - s-white - // [27] nb-char ::= c-printable - b-char - c-byte-order-mark - // [26] b-char ::= b-line-feed | b-carriage-return - // Including s-white (for some reason, examples doesn't match specs in this aspect) - // ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark - function isNsCharOrWhitespace(c) { - return isPrintable(c) - && c !== CHAR_BOM - // - b-char - && c !== CHAR_CARRIAGE_RETURN - && c !== CHAR_LINE_FEED; - } - - // [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out - // c = flow-in ⇒ ns-plain-safe-in - // c = block-key ⇒ ns-plain-safe-out - // c = flow-key ⇒ ns-plain-safe-in - // [128] ns-plain-safe-out ::= ns-char - // [129] ns-plain-safe-in ::= ns-char - c-flow-indicator - // [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) - // | ( /* An ns-char preceding */ “#” ) - // | ( “:” /* Followed by an ns-plain-safe(c) */ ) - function isPlainSafe(c, prev, inblock) { - var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); - var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); - return ( - // ns-plain-safe - inblock ? // c = flow-in - cIsNsCharOrWhitespace - : cIsNsCharOrWhitespace - // - c-flow-indicator - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET - ) - // ns-plain-char - && c !== CHAR_SHARP // false on '#' - && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' - || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' - || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' - } - - // Simplified test for values allowed as the first character in plain style. - function isPlainSafeFirst(c) { - // Uses a subset of ns-char - c-indicator - // where ns-char = nb-char - s-white. - // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part - return isPrintable(c) && c !== CHAR_BOM - && !isWhitespace(c) // - s-white - // - (c-indicator ::= - // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” - && c !== CHAR_MINUS - && c !== CHAR_QUESTION - && c !== CHAR_COLON - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET - // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” - && c !== CHAR_SHARP - && c !== CHAR_AMPERSAND - && c !== CHAR_ASTERISK - && c !== CHAR_EXCLAMATION - && c !== CHAR_VERTICAL_LINE - && c !== CHAR_EQUALS - && c !== CHAR_GREATER_THAN - && c !== CHAR_SINGLE_QUOTE - && c !== CHAR_DOUBLE_QUOTE - // | “%” | “@” | “`”) - && c !== CHAR_PERCENT - && c !== CHAR_COMMERCIAL_AT - && c !== CHAR_GRAVE_ACCENT; - } - - // Simplified test for values allowed as the last character in plain style. - function isPlainSafeLast(c) { - // just not whitespace or colon, it will be checked to be plain character later - return !isWhitespace(c) && c !== CHAR_COLON; - } - - // Same as 'string'.codePointAt(pos), but works in older browsers. - function codePointAt(string, pos) { - var first = string.charCodeAt(pos), second; - if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { - second = string.charCodeAt(pos + 1); - if (second >= 0xDC00 && second <= 0xDFFF) { - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; - } - } - return first; - } - - // Determines whether block indentation indicator is required. - function needIndentIndicator(string) { - var leadingSpaceRe = /^\n* /; - return leadingSpaceRe.test(string); - } - - var STYLE_PLAIN = 1, - STYLE_SINGLE = 2, - STYLE_LITERAL = 3, - STYLE_FOLDED = 4, - STYLE_DOUBLE = 5; - - // Determines which scalar styles are possible and returns the preferred style. - // lineWidth = -1 => no limit. - // Pre-conditions: str.length > 0. - // Post-conditions: - // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. - // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). - // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). - function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, - testAmbiguousType, quotingType, forceQuotes, inblock) { - - var i; - var char = 0; - var prevChar = null; - var hasLineBreak = false; - var hasFoldableLine = false; // only checked if shouldTrackWidth - var shouldTrackWidth = lineWidth !== -1; - var previousLineBreak = -1; // count the first line correctly - var plain = isPlainSafeFirst(codePointAt(string, 0)) - && isPlainSafeLast(codePointAt(string, string.length - 1)); - - if (singleLineOnly || forceQuotes) { - // Case: no block styles. - // Check for disallowed characters to rule out plain and single. - for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - if (!isPrintable(char)) { - return STYLE_DOUBLE; - } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; - } - } else { - // Case: block styles permitted. - for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - if (char === CHAR_LINE_FEED) { - hasLineBreak = true; - // Check if any line can be folded. - if (shouldTrackWidth) { - hasFoldableLine = hasFoldableLine || - // Foldable line = too long, and not more-indented. - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' '); - previousLineBreak = i; - } - } else if (!isPrintable(char)) { - return STYLE_DOUBLE; - } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; - } - // in case the end is missing a \n - hasFoldableLine = hasFoldableLine || (shouldTrackWidth && - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' ')); - } - // Although every style can represent \n without escaping, prefer block styles - // for multiline, since they're more readable and they don't add empty lines. - // Also prefer folding a super-long line. - if (!hasLineBreak && !hasFoldableLine) { - // Strings interpretable as another type have to be quoted; - // e.g. the string 'true' vs. the boolean true. - if (plain && !forceQuotes && !testAmbiguousType(string)) { - return STYLE_PLAIN; - } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; - } - // Edge case: block indentation indicator can only have one digit. - if (indentPerLevel > 9 && needIndentIndicator(string)) { - return STYLE_DOUBLE; - } - // At this point we know block styles are valid. - // Prefer literal style unless we want to fold. - if (!forceQuotes) { - return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; - } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; - } - - // Note: line breaking/folding is implemented for only the folded style. - // NB. We drop the last trailing newline (if any) of a returned block scalar - // since the dumper adds its own newline. This always works: - // • No ending newline => unaffected; already using strip "-" chomping. - // • Ending newline => removed then restored. - // Importantly, this keeps the "+" chomp indicator from gaining an extra line. - function writeScalar(state, string, level, iskey, inblock) { - state.dump = (function () { - if (string.length === 0) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; - } - if (!state.noCompatMode) { - if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); - } - } - - var indent = state.indent * Math.max(1, level); // no 0-indent scalars - // As indentation gets deeper, let the width decrease monotonically - // to the lower bound min(state.lineWidth, 40). - // Note that this implies - // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. - // state.lineWidth > 40 + state.indent: width decreases until the lower bound. - // This behaves better than a constant minimum width which disallows narrower options, - // or an indent threshold which causes the width to suddenly increase. - var lineWidth = state.lineWidth === -1 - ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); - - // Without knowing if keys are implicit/explicit, assume implicit for safety. - var singleLineOnly = iskey - // No block styles in flow mode. - || (state.flowLevel > -1 && level >= state.flowLevel); - function testAmbiguity(string) { - return testImplicitResolving(state, string); - } - - switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, - testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { - - case STYLE_PLAIN: - return string; - case STYLE_SINGLE: - return "'" + string.replace(/'/g, "''") + "'"; - case STYLE_LITERAL: - return '|' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(string, indent)); - case STYLE_FOLDED: - return '>' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); - case STYLE_DOUBLE: - return '"' + escapeString(string) + '"'; - default: - throw new exception('impossible error: invalid scalar style'); - } - }()); - } - - // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. - function blockHeader(string, indentPerLevel) { - var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; - - // note the special case: the string '\n' counts as a "trailing" empty line. - var clip = string[string.length - 1] === '\n'; - var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); - var chomp = keep ? '+' : (clip ? '' : '-'); - - return indentIndicator + chomp + '\n'; - } - - // (See the note for writeScalar.) - function dropEndingNewline(string) { - return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; - } - - // Note: a long line without a suitable break point will exceed the width limit. - // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. - function foldString(string, width) { - // In folded style, $k$ consecutive newlines output as $k+1$ newlines— - // unless they're before or after a more-indented line, or at the very - // beginning or end, in which case $k$ maps to $k$. - // Therefore, parse each chunk as newline(s) followed by a content line. - var lineRe = /(\n+)([^\n]*)/g; - - // first line (possibly an empty line) - var result = (function () { - var nextLF = string.indexOf('\n'); - nextLF = nextLF !== -1 ? nextLF : string.length; - lineRe.lastIndex = nextLF; - return foldLine(string.slice(0, nextLF), width); - }()); - // If we haven't reached the first content line yet, don't add an extra \n. - var prevMoreIndented = string[0] === '\n' || string[0] === ' '; - var moreIndented; - - // rest of the lines - var match; - while ((match = lineRe.exec(string))) { - var prefix = match[1], line = match[2]; - moreIndented = (line[0] === ' '); - result += prefix - + (!prevMoreIndented && !moreIndented && line !== '' - ? '\n' : '') - + foldLine(line, width); - prevMoreIndented = moreIndented; - } - - return result; - } - - // Greedy line breaking. - // Picks the longest line under the limit each time, - // otherwise settles for the shortest line over the limit. - // NB. More-indented lines *cannot* be folded, as that would add an extra \n. - function foldLine(line, width) { - if (line === '' || line[0] === ' ') return line; - - // Since a more-indented line adds a \n, breaks can't be followed by a space. - var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. - var match; - // start is an inclusive index. end, curr, and next are exclusive. - var start = 0, end, curr = 0, next = 0; - var result = ''; - - // Invariants: 0 <= start <= length-1. - // 0 <= curr <= next <= max(0, length-2). curr - start <= width. - // Inside the loop: - // A match implies length >= 2, so curr and next are <= length-2. - while ((match = breakRe.exec(line))) { - next = match.index; - // maintain invariant: curr - start <= width - if (next - start > width) { - end = (curr > start) ? curr : next; // derive end <= length-2 - result += '\n' + line.slice(start, end); - // skip the space that was output as \n - start = end + 1; // derive start <= length-1 - } - curr = next; - } - - // By the invariants, start <= length-1, so there is something left over. - // It is either the whole string or a part starting from non-whitespace. - result += '\n'; - // Insert a break if the remainder is too long and there is a break available. - if (line.length - start > width && curr > start) { - result += line.slice(start, curr) + '\n' + line.slice(curr + 1); - } else { - result += line.slice(start); - } - - return result.slice(1); // drop extra \n joiner - } - - // Escapes a double-quoted string. - function escapeString(string) { - var result = ''; - var char = 0; - var escapeSeq; - - for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - escapeSeq = ESCAPE_SEQUENCES[char]; - - if (!escapeSeq && isPrintable(char)) { - result += string[i]; - if (char >= 0x10000) result += string[i + 1]; - } else { - result += escapeSeq || encodeHex(char); - } - } - - return result; - } - - function writeFlowSequence(state, level, object) { - var _result = '', - _tag = state.tag, - index, - length, - value; - - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; - - if (state.replacer) { - value = state.replacer.call(object, String(index), value); - } - - // Write only valid elements, put null instead of invalid elements. - if (writeNode(state, level, value, false, false) || - (typeof value === 'undefined' && - writeNode(state, level, null, false, false))) { - - if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); - _result += state.dump; - } - } - - state.tag = _tag; - state.dump = '[' + _result + ']'; - } - - function writeBlockSequence(state, level, object, compact) { - var _result = '', - _tag = state.tag, - index, - length, - value; - - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; - - if (state.replacer) { - value = state.replacer.call(object, String(index), value); - } - - // Write only valid elements, put null instead of invalid elements. - if (writeNode(state, level + 1, value, true, true, false, true) || - (typeof value === 'undefined' && - writeNode(state, level + 1, null, true, true, false, true))) { - - if (!compact || _result !== '') { - _result += generateNextLine(state, level); - } - - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - _result += '-'; - } else { - _result += '- '; - } - - _result += state.dump; - } - } - - state.tag = _tag; - state.dump = _result || '[]'; // Empty sequence if no valid values. - } - - function writeFlowMapping(state, level, object) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - pairBuffer; - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - - pairBuffer = ''; - if (_result !== '') pairBuffer += ', '; - - if (state.condenseFlow) pairBuffer += '"'; - - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; - - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); - } - - if (!writeNode(state, level, objectKey, false, false)) { - continue; // Skip this pair because of invalid key; - } - - if (state.dump.length > 1024) pairBuffer += '? '; - - pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); - - if (!writeNode(state, level, objectValue, false, false)) { - continue; // Skip this pair because of invalid value. - } - - pairBuffer += state.dump; - - // Both key and value are valid. - _result += pairBuffer; - } - - state.tag = _tag; - state.dump = '{' + _result + '}'; - } - - function writeBlockMapping(state, level, object, compact) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - explicitPair, - pairBuffer; - - // Allow sorting keys so that the output file is deterministic - if (state.sortKeys === true) { - // Default sorting - objectKeyList.sort(); - } else if (typeof state.sortKeys === 'function') { - // Custom sort function - objectKeyList.sort(state.sortKeys); - } else if (state.sortKeys) { - // Something is wrong - throw new exception('sortKeys must be a boolean or a function'); - } - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ''; - - if (!compact || _result !== '') { - pairBuffer += generateNextLine(state, level); - } - - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; - - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); - } - - if (!writeNode(state, level + 1, objectKey, true, true, true)) { - continue; // Skip this pair because of invalid key. - } - - explicitPair = (state.tag !== null && state.tag !== '?') || - (state.dump && state.dump.length > 1024); - - if (explicitPair) { - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += '?'; - } else { - pairBuffer += '? '; - } - } - - pairBuffer += state.dump; - - if (explicitPair) { - pairBuffer += generateNextLine(state, level); - } - - if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { - continue; // Skip this pair because of invalid value. - } - - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += ':'; - } else { - pairBuffer += ': '; - } - - pairBuffer += state.dump; - - // Both key and value are valid. - _result += pairBuffer; - } - - state.tag = _tag; - state.dump = _result || '{}'; // Empty mapping if no valid pairs. - } - - function detectType(state, object, explicit) { - var _result, typeList, index, length, type, style; - - typeList = explicit ? state.explicitTypes : state.implicitTypes; - - for (index = 0, length = typeList.length; index < length; index += 1) { - type = typeList[index]; - - if ((type.instanceOf || type.predicate) && - (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && - (!type.predicate || type.predicate(object))) { - - if (explicit) { - if (type.multi && type.representName) { - state.tag = type.representName(object); - } else { - state.tag = type.tag; - } - } else { - state.tag = '?'; - } - - if (type.represent) { - style = state.styleMap[type.tag] || type.defaultStyle; - - if (_toString.call(type.represent) === '[object Function]') { - _result = type.represent(object, style); - } else if (_hasOwnProperty.call(type.represent, style)) { - _result = type.represent[style](object, style); - } else { - throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); - } - - state.dump = _result; - } - - return true; - } - } - - return false; - } - - // Serializes `object` and writes it to global `result`. - // Returns true on success, or false on invalid object. - // - function writeNode(state, level, object, block, compact, iskey, isblockseq) { - state.tag = null; - state.dump = object; - - if (!detectType(state, object, false)) { - detectType(state, object, true); - } - - var type = _toString.call(state.dump); - var inblock = block; - var tagStr; - - if (block) { - block = (state.flowLevel < 0 || state.flowLevel > level); - } - - var objectOrArray = type === '[object Object]' || type === '[object Array]', - duplicateIndex, - duplicate; - - if (objectOrArray) { - duplicateIndex = state.duplicates.indexOf(object); - duplicate = duplicateIndex !== -1; - } - - if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { - compact = false; - } - - if (duplicate && state.usedDuplicates[duplicateIndex]) { - state.dump = '*ref_' + duplicateIndex; - } else { - if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { - state.usedDuplicates[duplicateIndex] = true; - } - if (type === '[object Object]') { - if (block && (Object.keys(state.dump).length !== 0)) { - writeBlockMapping(state, level, state.dump, compact); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; - } - } else { - writeFlowMapping(state, level, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; - } - } - } else if (type === '[object Array]') { - if (block && (state.dump.length !== 0)) { - if (state.noArrayIndent && !isblockseq && level > 0) { - writeBlockSequence(state, level - 1, state.dump, compact); - } else { - writeBlockSequence(state, level, state.dump, compact); - } - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; - } - } else { - writeFlowSequence(state, level, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; - } - } - } else if (type === '[object String]') { - if (state.tag !== '?') { - writeScalar(state, state.dump, level, iskey, inblock); - } - } else if (type === '[object Undefined]') { - return false; - } else { - if (state.skipInvalid) return false; - throw new exception('unacceptable kind of an object to dump ' + type); - } - - if (state.tag !== null && state.tag !== '?') { - // Need to encode all characters except those allowed by the spec: - // - // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ - // [36] ns-hex-digit ::= ns-dec-digit - // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ - // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ - // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” - // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” - // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” - // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” - // - // Also need to encode '!' because it has special meaning (end of tag prefix). - // - tagStr = encodeURI( - state.tag[0] === '!' ? state.tag.slice(1) : state.tag - ).replace(/!/g, '%21'); - - if (state.tag[0] === '!') { - tagStr = '!' + tagStr; - } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { - tagStr = '!!' + tagStr.slice(18); - } else { - tagStr = '!<' + tagStr + '>'; - } - - state.dump = tagStr + ' ' + state.dump; - } - } - - return true; - } - - function getDuplicateReferences(object, state) { - var objects = [], - duplicatesIndexes = [], - index, - length; - - inspectNode(object, objects, duplicatesIndexes); - - for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { - state.duplicates.push(objects[duplicatesIndexes[index]]); - } - state.usedDuplicates = new Array(length); - } - - function inspectNode(object, objects, duplicatesIndexes) { - var objectKeyList, - index, - length; - - if (object !== null && typeof object === 'object') { - index = objects.indexOf(object); - if (index !== -1) { - if (duplicatesIndexes.indexOf(index) === -1) { - duplicatesIndexes.push(index); - } - } else { - objects.push(object); - - if (Array.isArray(object)) { - for (index = 0, length = object.length; index < length; index += 1) { - inspectNode(object[index], objects, duplicatesIndexes); - } - } else { - objectKeyList = Object.keys(object); - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); - } - } - } - } - } - - function dump$1(input, options) { - options = options || {}; - - var state = new State(options); - - if (!state.noRefs) getDuplicateReferences(input, state); - - var value = input; - - if (state.replacer) { - value = state.replacer.call({ '': value }, '', value); - } - - if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; - - return ''; - } - - var dump_1 = dump$1; - - var dumper = { - dump: dump_1 - }; - - function renamed(from, to) { - return function () { - throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + - 'Use yaml.' + to + ' instead, which is now safe by default.'); - }; - } - - - var Type = type; - var Schema = schema; - var FAILSAFE_SCHEMA = failsafe; - var JSON_SCHEMA = json; - var CORE_SCHEMA = core; - var DEFAULT_SCHEMA = _default; - var load = loader.load; - var loadAll = loader.loadAll; - var dump = dumper.dump; - var YAMLException = exception; - - // Re-export all types in case user wants to create custom schema - var types = { - binary: binary, - float: float, - map: map, - null: _null, - pairs: pairs, - set: set, - timestamp: timestamp, - bool: bool, - int: int, - merge: merge, - omap: omap, - seq: seq, - str: str - }; - - // Removed functions from JS-YAML 3.0.x - var safeLoad = renamed('safeLoad', 'load'); - var safeLoadAll = renamed('safeLoadAll', 'loadAll'); - var safeDump = renamed('safeDump', 'dump'); - - var jsYaml = { - Type: Type, - Schema: Schema, - FAILSAFE_SCHEMA: FAILSAFE_SCHEMA, - JSON_SCHEMA: JSON_SCHEMA, - CORE_SCHEMA: CORE_SCHEMA, - DEFAULT_SCHEMA: DEFAULT_SCHEMA, - load: load, - loadAll: loadAll, - dump: dump, - YAMLException: YAMLException, - types: types, - safeLoad: safeLoad, - safeLoadAll: safeLoadAll, - safeDump: safeDump - }; - - exports.CORE_SCHEMA = CORE_SCHEMA; - exports.DEFAULT_SCHEMA = DEFAULT_SCHEMA; - exports.FAILSAFE_SCHEMA = FAILSAFE_SCHEMA; - exports.JSON_SCHEMA = JSON_SCHEMA; - exports.Schema = Schema; - exports.Type = Type; - exports.YAMLException = YAMLException; - exports["default"] = jsYaml; - exports.dump = dump; - exports.load = load; - exports.loadAll = loadAll; - exports.safeDump = safeDump; - exports.safeLoad = safeLoad; - exports.safeLoadAll = safeLoadAll; - exports.types = types; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); diff --git a/dist/js-yaml.min.js b/dist/js-yaml.min.js deleted file mode 100644 index 8e7f7664..00000000 --- a/dist/js-yaml.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jsyaml={})}(this,function(e){"use strict";function t(e){return null==e}var n={isNothing:t,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:t(e)?[]:[e]},repeat:function(e,t){var n,i="";for(n=0;nl&&(t=i-l+(o=" ... ").length),n-i>l&&(n=i+l-(a=" ...").length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:i-t+o.length}}function l(e,t){return n.repeat(" ",t-e.length)+e}var c=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,r=/\r?\n|\r|\0/g,o=[0],c=[],s=-1;i=r.exec(e.buffer);)c.push(i.index),o.push(i.index+i[0].length),e.position<=i.index&&s<0&&(s=o.length-2);s<0&&(s=o.length-1);var u,p,f="",d=Math.min(e.line+t.linesAfter,c.length).toString().length,h=t.maxLength-(t.indent+d+3);for(u=1;u<=t.linesBefore&&!(s-u<0);u++)p=a(e.buffer,o[s-u],c[s-u],e.position-(o[s]-o[s-u]),h),f=n.repeat(" ",t.indent)+l((e.line-u+1).toString(),d)+" | "+p.str+"\n"+f;for(p=a(e.buffer,o[s],c[s],e.position,h),f+=n.repeat(" ",t.indent)+l((e.line+1).toString(),d)+" | "+p.str+"\n",f+=n.repeat("-",t.indent+d+3+p.pos)+"^\n",u=1;u<=t.linesAfter&&!(s+u>=c.length);u++)p=a(e.buffer,o[s+u],c[s+u],e.position-(o[s]-o[s+u]),h),f+=n.repeat(" ",t.indent)+l((e.line+u+1).toString(),d)+" | "+p.str+"\n";return f.replace(/\n$/,"")},s=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],u=["scalar","sequence","mapping"];var p=function(e,t){if(t=t||{},Object.keys(t).forEach(function(t){if(-1===s.indexOf(t))throw new o('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}(t.styleAliases||null),-1===u.indexOf(this.kind))throw new o('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function f(e,t){var n=[];return e[t].forEach(function(e){var t=n.length;n.forEach(function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)}),n[t]=e}),n}function d(e){return this.extend(e)}d.prototype.extend=function(e){var t=[],n=[];if(e instanceof p)n.push(e);else if(Array.isArray(e))n=n.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new o("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit))}t.forEach(function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new o("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new o("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),n.forEach(function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(d.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(n),i.compiledImplicit=f(i,"implicit"),i.compiledExplicit=f(i,"explicit"),i.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function i(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),I=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var S=/^[-+]?[0-9]+e/;var O=new p("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!I.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||n.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(n.isNegativeZero(e))return"-0.0";return i=e.toString(10),S.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),j=b.extend({implicit:[A,v,x,O]}),T=j,N=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),F=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var E=new p("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==N.exec(e)||null!==F.exec(e))},construct:function(e){var t,n,i,r,o,a,l,c,s=0,u=null;if(null===(t=N.exec(e))&&(t=F.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],i=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,i,r));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(s=t[7].slice(0,3);s.length<3;)s+="0";s=+s}return t[9]&&(u=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(u=-u)),c=new Date(Date.UTC(n,i,r,o,a,l,s)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(e){return e.toISOString()}});var M=new p("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),L="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var _=new p("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i=0,r=e.length,o=L;for(n=0;n64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),r=i.length,o=L,a=0,l=[];for(t=0;t>16&255),l.push(a>>8&255),l.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0===(n=r%4*6)?(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)):18===n?(l.push(a>>10&255),l.push(a>>2&255)):12===n&&l.push(a>>4&255),new Uint8Array(l)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=L;for(t=0;t>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0===(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2===n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1===n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}}),D=Object.prototype.hasOwnProperty,U=Object.prototype.toString;var q=new p("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=[],l=e;for(t=0,n=l.length;t>10),56320+(e-65536&1023))}function ae(e,t,n){"__proto__"===t?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var le=new Array(256),ce=new Array(256),se=0;se<256;se++)le[se]=re(se)?1:0,ce[se]=re(se);function ue(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||P,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function pe(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=c(n),new o(t,n)}function fe(e,t){throw pe(e,t)}function de(e,t){e.onWarning&&e.onWarning.call(null,pe(e,t))}var he={YAML:function(e,t,n){var i,r,o;null!==e.version&&fe(e,"duplication of %YAML directive"),1!==n.length&&fe(e,"YAML directive accepts exactly one argument"),null===(i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&fe(e,"ill-formed argument of the YAML directive"),r=parseInt(i[1],10),o=parseInt(i[2],10),1!==r&&fe(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&de(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var i,r;2!==n.length&&fe(e,"TAG directive accepts exactly two arguments"),i=n[0],r=n[1],V.test(i)||fe(e,"ill-formed tag handle (first argument) of the TAG directive"),W.call(e.tagMap,i)&&fe(e,'there is a previously declared suffix for "'+i+'" tag handle'),Z.test(r)||fe(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){fe(e,"tag prefix is malformed: "+r)}e.tagMap[i]=r}};function ge(e,t,n,i){var r,o,a,l;if(t1&&(e.result+=n.repeat("\n",t-1))}function ke(e,t){var n,i,r=e.tag,o=e.anchor,a=[],l=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),i=e.input.charCodeAt(e.position);0!==i&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,fe(e,"tab characters must not be used in indentation")),45===i)&&X(e.input.charCodeAt(e.position+1));)if(l=!0,e.position++,Ae(e,!0,-1)&&e.lineIndent<=t)a.push(null),i=e.input.charCodeAt(e.position);else if(n=e.line,Ie(e,t,3,!1,!0),a.push(e.result),Ae(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)fe(e,"bad indentation of a sequence entry");else if(e.lineIndentt?g=1:e.lineIndent===t?g=0:e.lineIndentt?g=1:e.lineIndent===t?g=0:e.lineIndentt)&&(y&&(a=e.line,l=e.lineStart,c=e.position),Ie(e,t,4,!0,r)&&(y?g=e.result:m=e.result),y||(ye(e,f,d,h,g,m,a,l,c),h=g=m=null),Ae(e,!0,-1),s=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&0!==s)fe(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===o?fe(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?fe(e,"repeat of an indentation width identifier"):(u=t+o-1,s=!0)}if(z(a)){do{a=e.input.charCodeAt(++e.position)}while(z(a));if(35===a)do{a=e.input.charCodeAt(++e.position)}while(!Q(a)&&0!==a)}for(;0!==a;){for(be(e),e.lineIndent=0,a=e.input.charCodeAt(e.position);(!s||e.lineIndentu&&(u=e.lineIndent),Q(a))p++;else{if(e.lineIndent0){for(r=a,o=0;r>0;r--)(a=te(l=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+a:fe(e,"expected hexadecimal character");e.result+=oe(o),e.position++}else fe(e,"unknown escape sequence");n=i=e.position}else Q(l)?(ge(e,n,i,!0),we(e,Ae(e,!1,t)),n=i=e.position):e.position===e.lineStart&&ve(e)?fe(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}fe(e,"unexpected end of the stream within a double quoted scalar")}(e,d)?y=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!X(i)&&!ee(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&fe(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),W.call(e.anchorMap,n)||fe(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Ae(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,l,c,s,u,p=e.kind,f=e.result;if(X(u=e.input.charCodeAt(e.position))||ee(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(X(i=e.input.charCodeAt(e.position+1))||n&&ee(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==u;){if(58===u){if(X(i=e.input.charCodeAt(e.position+1))||n&&ee(i))break}else if(35===u){if(X(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&ve(e)||n&&ee(u))break;if(Q(u)){if(l=e.line,c=e.lineStart,s=e.lineIndent,Ae(e,!1,-1),e.lineIndent>=t){a=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=l,e.lineStart=c,e.lineIndent=s;break}}a&&(ge(e,r,o,!1),we(e,e.line-l),r=o=e.position,a=!1),z(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return ge(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,d,1===i)&&(y=!0,null===e.tag&&(e.tag="?")):(y=!0,null===e.tag&&null===e.anchor||fe(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===g&&(y=c&&ke(e,h))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&fe(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),s=0,u=e.implicitTypes.length;s"),null!==e.result&&f.kind!==e.kind&&fe(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result,e.tag)?(e.result=f.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):fe(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||y}function Se(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(Ae(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!X(r);)r=e.input.charCodeAt(++e.position);for(i=[],(n=e.input.slice(t,e.position)).length<1&&fe(e,"directive name must not be less than one character in length");0!==r;){for(;z(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!Q(r));break}if(Q(r))break;for(t=e.position;0!==r&&!X(r);)r=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}0!==r&&be(e),W.call(he,n)?he[n](e,n,i):de(e,'unknown document directive "'+n+'"')}Ae(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,Ae(e,!0,-1)):a&&fe(e,"directives end mark is expected"),Ie(e,e.lineIndent-1,4,!1,!0),Ae(e,!0,-1),e.checkLineBreaks&&$.test(e.input.slice(o,e.position))&&de(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ve(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,Ae(e,!0,-1)):e.position=55296&&i<=56319&&t+1=56320&&n<=57343?1024*(i-55296)+n-56320+65536:i}function We(e){return/^\n* /.test(e)}function He(e,t,n,i,r,o,a,l){var c,s,u=0,p=null,f=!1,d=!1,h=-1!==i,g=-1,m=Re(s=Pe(e,0))&&s!==Fe&&!Ye(s)&&45!==s&&63!==s&&58!==s&&44!==s&&91!==s&&93!==s&&123!==s&&125!==s&&35!==s&&38!==s&&42!==s&&33!==s&&124!==s&&61!==s&&62!==s&&39!==s&&34!==s&&37!==s&&64!==s&&96!==s&&function(e){return!Ye(e)&&58!==e}(Pe(e,e.length-1));if(t||a)for(c=0;c=65536?c+=2:c++){if(!Re(u=Pe(e,c)))return 5;m=m&&Ke(u,p,l),p=u}else{for(c=0;c=65536?c+=2:c++){if(10===(u=Pe(e,c)))f=!0,h&&(d=d||c-g-1>i&&" "!==e[g+1],g=c);else if(!Re(u))return 5;m=m&&Ke(u,p,l),p=u}d=d||h&&c-g-1>i&&" "!==e[g+1]}return f||d?n>9&&We(e)?5:a?2===o?5:2:d?4:3:!m||a||r(e)?2===o?5:2:1}function $e(e,t,n,i,r){e.dump=function(){if(0===t.length)return 2===e.quotingType?'""':"''";if(!e.noCompatMode&&(-1!==Me.indexOf(t)||Le.test(t)))return 2===e.quotingType?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,n),l=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),c=i||e.flowLevel>-1&&n>=e.flowLevel;switch(He(t,c,e.indent,l,function(t){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n"+Ge(t,e.indent)+Ve(Ue(function(e,t){var n,i,r=/(\n+)([^\n]*)/g,o=(l=e.indexOf("\n"),l=-1!==l?l:e.length,r.lastIndex=l,Ze(e.slice(0,l),t)),a="\n"===e[0]||" "===e[0];var l;for(;i=r.exec(e);){var c=i[1],s=i[2];n=" "===s[0],o+=c+(a||n||""===s?"":"\n")+Ze(s,t),a=n}return o}(t,l),a));case 5:return'"'+function(e){for(var t,n="",i=0,r=0;r=65536?r+=2:r++)i=Pe(e,r),!(t=Ee[i])&&Re(i)?(n+=e[r],i>=65536&&(n+=e[r+1])):n+=t||_e(i);return n}(t)+'"';default:throw new o("impossible error: invalid scalar style")}}()}function Ge(e,t){var n=We(e)?String(t):"",i="\n"===e[e.length-1];return n+(i&&("\n"===e[e.length-2]||"\n"===e)?"+":i?"":"-")+"\n"}function Ve(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function Ze(e,t){if(""===e||" "===e[0])return e;for(var n,i,r=/ [^ ]/g,o=0,a=0,l=0,c="";n=r.exec(e);)(l=n.index)-o>t&&(i=a>o?a:l,c+="\n"+e.slice(o,i),o=i+1),a=l;return c+="\n",e.length-o>t&&a>o?c+=e.slice(o,a)+"\n"+e.slice(a+1):c+=e.slice(o),c.slice(1)}function Je(e,t,n,i){var r,o,a,l="",c=e.tag;for(r=0,o=n.length;r tag resolver accepts not "'+s+'" style');i=c.represent[s](t,s)}e.dump=i}return!0}return!1}function ze(e,t,n,i,r,a,l){e.tag=null,e.dump=n,Qe(e,n,!1)||Qe(e,n,!0);var c,s=Te.call(e.dump),u=i;i&&(i=e.flowLevel<0||e.flowLevel>t);var p,f,d="[object Object]"===s||"[object Array]"===s;if(d&&(f=-1!==(p=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||f||2!==e.indent&&t>0)&&(r=!1),f&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(d&&f&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),"[object Object]"===s)i&&0!==Object.keys(e.dump).length?(!function(e,t,n,i){var r,a,l,c,s,u,p="",f=e.tag,d=Object.keys(n);if(!0===e.sortKeys)d.sort();else if("function"==typeof e.sortKeys)d.sort(e.sortKeys);else if(e.sortKeys)throw new o("sortKeys must be a boolean or a function");for(r=0,a=d.length;r1024)&&(e.dump&&10===e.dump.charCodeAt(0)?u+="?":u+="? "),u+=e.dump,s&&(u+=qe(e,t)),ze(e,t+1,c,!0,s)&&(e.dump&&10===e.dump.charCodeAt(0)?u+=":":u+=": ",p+=u+=e.dump));e.tag=f,e.dump=p||"{}"}(e,t,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(!function(e,t,n){var i,r,o,a,l,c="",s=e.tag,u=Object.keys(n);for(i=0,r=u.length;i1024&&(l+="? "),l+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ze(e,t,a,!1,!1)&&(c+=l+=e.dump));e.tag=s,e.dump="{"+c+"}"}(e,t,e.dump),f&&(e.dump="&ref_"+p+" "+e.dump));else if("[object Array]"===s)i&&0!==e.dump.length?(e.noArrayIndent&&!l&&t>0?Je(e,t-1,e.dump,r):Je(e,t,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(!function(e,t,n){var i,r,o,a="",l=e.tag;for(i=0,r=n.length;i",e.dump=c+" "+e.dump)}return!0}function Xe(e,t){var n,i,r=[],o=[];for(et(e,r,o),n=0,i=o.length;n maxHalfLength) { - head = ' ... '; - lineStart = position - maxHalfLength + head.length; - } - - if (lineEnd - position > maxHalfLength) { - tail = ' ...'; - lineEnd = position + maxHalfLength - tail.length; - } - - return { - str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, - pos: position - lineStart + head.length // relative position - }; -} - - -function padStart(string, max) { - return common.repeat(' ', max - string.length) + string; -} - - -function makeSnippet(mark, options) { - options = Object.create(options || null); - - if (!mark.buffer) return null; - - if (!options.maxLength) options.maxLength = 79; - if (typeof options.indent !== 'number') options.indent = 1; - if (typeof options.linesBefore !== 'number') options.linesBefore = 3; - if (typeof options.linesAfter !== 'number') options.linesAfter = 2; - - var re = /\r?\n|\r|\0/g; - var lineStarts = [ 0 ]; - var lineEnds = []; - var match; - var foundLineNo = -1; - - while ((match = re.exec(mark.buffer))) { - lineEnds.push(match.index); - lineStarts.push(match.index + match[0].length); - - if (mark.position <= match.index && foundLineNo < 0) { - foundLineNo = lineStarts.length - 2; - } - } - - if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; - - var result = '', i, line; - var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; - var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); - - for (i = 1; i <= options.linesBefore; i++) { - if (foundLineNo - i < 0) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo - i], - lineEnds[foundLineNo - i], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), - maxLineLength - ); - result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n' + result; - } - - line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); - result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; - result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; - - for (i = 1; i <= options.linesAfter; i++) { - if (foundLineNo + i >= lineEnds.length) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo + i], - lineEnds[foundLineNo + i], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), - maxLineLength - ); - result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; - } - - return result.replace(/\n$/, ''); -} - - -var snippet = makeSnippet; - -var TYPE_CONSTRUCTOR_OPTIONS = [ - 'kind', - 'multi', - 'resolve', - 'construct', - 'instanceOf', - 'predicate', - 'represent', - 'representName', - 'defaultStyle', - 'styleAliases' -]; - -var YAML_NODE_KINDS = [ - 'scalar', - 'sequence', - 'mapping' -]; - -function compileStyleAliases(map) { - var result = {}; - - if (map !== null) { - Object.keys(map).forEach(function (style) { - map[style].forEach(function (alias) { - result[String(alias)] = style; - }); - }); - } - - return result; -} - -function Type$1(tag, options) { - options = options || {}; - - Object.keys(options).forEach(function (name) { - if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { - throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); - } - }); - - // TODO: Add tag format check. - this.options = options; // keep original options in case user wants to extend this type later - this.tag = tag; - this.kind = options['kind'] || null; - this.resolve = options['resolve'] || function () { return true; }; - this.construct = options['construct'] || function (data) { return data; }; - this.instanceOf = options['instanceOf'] || null; - this.predicate = options['predicate'] || null; - this.represent = options['represent'] || null; - this.representName = options['representName'] || null; - this.defaultStyle = options['defaultStyle'] || null; - this.multi = options['multi'] || false; - this.styleAliases = compileStyleAliases(options['styleAliases'] || null); - - if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { - throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); - } -} - -var type = Type$1; - -/*eslint-disable max-len*/ - - - - - -function compileList(schema, name) { - var result = []; - - schema[name].forEach(function (currentType) { - var newIndex = result.length; - - result.forEach(function (previousType, previousIndex) { - if (previousType.tag === currentType.tag && - previousType.kind === currentType.kind && - previousType.multi === currentType.multi) { - - newIndex = previousIndex; - } - }); - - result[newIndex] = currentType; - }); - - return result; -} - - -function compileMap(/* lists... */) { - var result = { - scalar: {}, - sequence: {}, - mapping: {}, - fallback: {}, - multi: { - scalar: [], - sequence: [], - mapping: [], - fallback: [] - } - }, index, length; - - function collectType(type) { - if (type.multi) { - result.multi[type.kind].push(type); - result.multi['fallback'].push(type); - } else { - result[type.kind][type.tag] = result['fallback'][type.tag] = type; - } - } - - for (index = 0, length = arguments.length; index < length; index += 1) { - arguments[index].forEach(collectType); - } - return result; -} - - -function Schema$1(definition) { - return this.extend(definition); -} - - -Schema$1.prototype.extend = function extend(definition) { - var implicit = []; - var explicit = []; - - if (definition instanceof type) { - // Schema.extend(type) - explicit.push(definition); - - } else if (Array.isArray(definition)) { - // Schema.extend([ type1, type2, ... ]) - explicit = explicit.concat(definition); - - } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { - // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) - if (definition.implicit) implicit = implicit.concat(definition.implicit); - if (definition.explicit) explicit = explicit.concat(definition.explicit); - - } else { - throw new exception('Schema.extend argument should be a Type, [ Type ], ' + - 'or a schema definition ({ implicit: [...], explicit: [...] })'); - } - - implicit.forEach(function (type$1) { - if (!(type$1 instanceof type)) { - throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); - } - - if (type$1.loadKind && type$1.loadKind !== 'scalar') { - throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); - } - - if (type$1.multi) { - throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); - } - }); - - explicit.forEach(function (type$1) { - if (!(type$1 instanceof type)) { - throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); - } - }); - - var result = Object.create(Schema$1.prototype); - - result.implicit = (this.implicit || []).concat(implicit); - result.explicit = (this.explicit || []).concat(explicit); - - result.compiledImplicit = compileList(result, 'implicit'); - result.compiledExplicit = compileList(result, 'explicit'); - result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); - - return result; -}; - - -var schema = Schema$1; - -var str = new type('tag:yaml.org,2002:str', { - kind: 'scalar', - construct: function (data) { return data !== null ? data : ''; } -}); - -var seq = new type('tag:yaml.org,2002:seq', { - kind: 'sequence', - construct: function (data) { return data !== null ? data : []; } -}); - -var map = new type('tag:yaml.org,2002:map', { - kind: 'mapping', - construct: function (data) { return data !== null ? data : {}; } -}); - -var failsafe = new schema({ - explicit: [ - str, - seq, - map - ] -}); - -function resolveYamlNull(data) { - if (data === null) return true; - - var max = data.length; - - return (max === 1 && data === '~') || - (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); -} - -function constructYamlNull() { - return null; -} - -function isNull(object) { - return object === null; -} - -var _null = new type('tag:yaml.org,2002:null', { - kind: 'scalar', - resolve: resolveYamlNull, - construct: constructYamlNull, - predicate: isNull, - represent: { - canonical: function () { return '~'; }, - lowercase: function () { return 'null'; }, - uppercase: function () { return 'NULL'; }, - camelcase: function () { return 'Null'; }, - empty: function () { return ''; } - }, - defaultStyle: 'lowercase' -}); - -function resolveYamlBoolean(data) { - if (data === null) return false; - - var max = data.length; - - return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || - (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); -} - -function constructYamlBoolean(data) { - return data === 'true' || - data === 'True' || - data === 'TRUE'; -} - -function isBoolean(object) { - return Object.prototype.toString.call(object) === '[object Boolean]'; -} - -var bool = new type('tag:yaml.org,2002:bool', { - kind: 'scalar', - resolve: resolveYamlBoolean, - construct: constructYamlBoolean, - predicate: isBoolean, - represent: { - lowercase: function (object) { return object ? 'true' : 'false'; }, - uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, - camelcase: function (object) { return object ? 'True' : 'False'; } - }, - defaultStyle: 'lowercase' -}); - -function isHexCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || - ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || - ((0x61/* a */ <= c) && (c <= 0x66/* f */)); -} - -function isOctCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); -} - -function isDecCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); -} - -function resolveYamlInteger(data) { - if (data === null) return false; - - var max = data.length, - index = 0, - hasDigits = false, - ch; - - if (!max) return false; - - ch = data[index]; - - // sign - if (ch === '-' || ch === '+') { - ch = data[++index]; - } - - if (ch === '0') { - // 0 - if (index + 1 === max) return true; - ch = data[++index]; - - // base 2, base 8, base 16 - - if (ch === 'b') { - // base 2 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (ch !== '0' && ch !== '1') return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } - - - if (ch === 'x') { - // base 16 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isHexCode(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } - - - if (ch === 'o') { - // base 8 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isOctCode(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; - } - } - - // base 10 (except 0) - - // value should not start with `_`; - if (ch === '_') return false; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isDecCode(data.charCodeAt(index))) { - return false; - } - hasDigits = true; - } - - // Should have digits and should not end with `_` - if (!hasDigits || ch === '_') return false; - - return true; -} - -function constructYamlInteger(data) { - var value = data, sign = 1, ch; - - if (value.indexOf('_') !== -1) { - value = value.replace(/_/g, ''); - } - - ch = value[0]; - - if (ch === '-' || ch === '+') { - if (ch === '-') sign = -1; - value = value.slice(1); - ch = value[0]; - } - - if (value === '0') return 0; - - if (ch === '0') { - if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); - if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); - if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); - } - - return sign * parseInt(value, 10); -} - -function isInteger(object) { - return (Object.prototype.toString.call(object)) === '[object Number]' && - (object % 1 === 0 && !common.isNegativeZero(object)); -} - -var int = new type('tag:yaml.org,2002:int', { - kind: 'scalar', - resolve: resolveYamlInteger, - construct: constructYamlInteger, - predicate: isInteger, - represent: { - binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, - octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, - decimal: function (obj) { return obj.toString(10); }, - /* eslint-disable max-len */ - hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } - }, - defaultStyle: 'decimal', - styleAliases: { - binary: [ 2, 'bin' ], - octal: [ 8, 'oct' ], - decimal: [ 10, 'dec' ], - hexadecimal: [ 16, 'hex' ] - } -}); - -var YAML_FLOAT_PATTERN = new RegExp( - // 2.5e4, 2.5 and integers - '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + - // .2e4, .2 - // special case, seems not from spec - '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + - // .inf - '|[-+]?\\.(?:inf|Inf|INF)' + - // .nan - '|\\.(?:nan|NaN|NAN))$'); - -function resolveYamlFloat(data) { - if (data === null) return false; - - if (!YAML_FLOAT_PATTERN.test(data) || - // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === '_') { - return false; - } - - return true; -} - -function constructYamlFloat(data) { - var value, sign; - - value = data.replace(/_/g, '').toLowerCase(); - sign = value[0] === '-' ? -1 : 1; - - if ('+-'.indexOf(value[0]) >= 0) { - value = value.slice(1); - } - - if (value === '.inf') { - return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; - - } else if (value === '.nan') { - return NaN; - } - return sign * parseFloat(value, 10); -} - - -var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; - -function representYamlFloat(object, style) { - var res; - - if (isNaN(object)) { - switch (style) { - case 'lowercase': return '.nan'; - case 'uppercase': return '.NAN'; - case 'camelcase': return '.NaN'; - } - } else if (Number.POSITIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '.inf'; - case 'uppercase': return '.INF'; - case 'camelcase': return '.Inf'; - } - } else if (Number.NEGATIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '-.inf'; - case 'uppercase': return '-.INF'; - case 'camelcase': return '-.Inf'; - } - } else if (common.isNegativeZero(object)) { - return '-0.0'; - } - - res = object.toString(10); - - // JS stringifier can build scientific format without dots: 5e-100, - // while YAML requres dot: 5.e-100. Fix it with simple hack - - return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; -} - -function isFloat(object) { - return (Object.prototype.toString.call(object) === '[object Number]') && - (object % 1 !== 0 || common.isNegativeZero(object)); -} - -var float = new type('tag:yaml.org,2002:float', { - kind: 'scalar', - resolve: resolveYamlFloat, - construct: constructYamlFloat, - predicate: isFloat, - represent: representYamlFloat, - defaultStyle: 'lowercase' -}); - -var json = failsafe.extend({ - implicit: [ - _null, - bool, - int, - float - ] -}); - -var core = json; - -var YAML_DATE_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9])' + // [2] month - '-([0-9][0-9])$'); // [3] day - -var YAML_TIMESTAMP_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9]?)' + // [2] month - '-([0-9][0-9]?)' + // [3] day - '(?:[Tt]|[ \\t]+)' + // ... - '([0-9][0-9]?)' + // [4] hour - ':([0-9][0-9])' + // [5] minute - ':([0-9][0-9])' + // [6] second - '(?:\\.([0-9]*))?' + // [7] fraction - '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour - '(?::([0-9][0-9]))?))?$'); // [11] tz_minute - -function resolveYamlTimestamp(data) { - if (data === null) return false; - if (YAML_DATE_REGEXP.exec(data) !== null) return true; - if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; - return false; -} - -function constructYamlTimestamp(data) { - var match, year, month, day, hour, minute, second, fraction = 0, - delta = null, tz_hour, tz_minute, date; - - match = YAML_DATE_REGEXP.exec(data); - if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); - - if (match === null) throw new Error('Date resolve error'); - - // match: [1] year [2] month [3] day - - year = +(match[1]); - month = +(match[2]) - 1; // JS month starts with 0 - day = +(match[3]); - - if (!match[4]) { // no hour - return new Date(Date.UTC(year, month, day)); - } - - // match: [4] hour [5] minute [6] second [7] fraction - - hour = +(match[4]); - minute = +(match[5]); - second = +(match[6]); - - if (match[7]) { - fraction = match[7].slice(0, 3); - while (fraction.length < 3) { // milli-seconds - fraction += '0'; - } - fraction = +fraction; - } - - // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute - - if (match[9]) { - tz_hour = +(match[10]); - tz_minute = +(match[11] || 0); - delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds - if (match[9] === '-') delta = -delta; - } - - date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); - - if (delta) date.setTime(date.getTime() - delta); - - return date; -} - -function representYamlTimestamp(object /*, style*/) { - return object.toISOString(); -} - -var timestamp = new type('tag:yaml.org,2002:timestamp', { - kind: 'scalar', - resolve: resolveYamlTimestamp, - construct: constructYamlTimestamp, - instanceOf: Date, - represent: representYamlTimestamp -}); - -function resolveYamlMerge(data) { - return data === '<<' || data === null; -} - -var merge = new type('tag:yaml.org,2002:merge', { - kind: 'scalar', - resolve: resolveYamlMerge -}); - -/*eslint-disable no-bitwise*/ - - - - - -// [ 64, 65, 66 ] -> [ padding, CR, LF ] -var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; - - -function resolveYamlBinary(data) { - if (data === null) return false; - - var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; - - // Convert one by one. - for (idx = 0; idx < max; idx++) { - code = map.indexOf(data.charAt(idx)); - - // Skip CR/LF - if (code > 64) continue; - - // Fail on illegal characters - if (code < 0) return false; - - bitlen += 6; - } - - // If there are any bits left, source was corrupted - return (bitlen % 8) === 0; -} - -function constructYamlBinary(data) { - var idx, tailbits, - input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan - max = input.length, - map = BASE64_MAP, - bits = 0, - result = []; - - // Collect by 6*4 bits (3 bytes) - - for (idx = 0; idx < max; idx++) { - if ((idx % 4 === 0) && idx) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } - - bits = (bits << 6) | map.indexOf(input.charAt(idx)); - } - - // Dump tail - - tailbits = (max % 4) * 6; - - if (tailbits === 0) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } else if (tailbits === 18) { - result.push((bits >> 10) & 0xFF); - result.push((bits >> 2) & 0xFF); - } else if (tailbits === 12) { - result.push((bits >> 4) & 0xFF); - } - - return new Uint8Array(result); -} - -function representYamlBinary(object /*, style*/) { - var result = '', bits = 0, idx, tail, - max = object.length, - map = BASE64_MAP; - - // Convert every three bytes to 4 ASCII characters. - - for (idx = 0; idx < max; idx++) { - if ((idx % 3 === 0) && idx) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } - - bits = (bits << 8) + object[idx]; - } - - // Dump tail - - tail = max % 3; - - if (tail === 0) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } else if (tail === 2) { - result += map[(bits >> 10) & 0x3F]; - result += map[(bits >> 4) & 0x3F]; - result += map[(bits << 2) & 0x3F]; - result += map[64]; - } else if (tail === 1) { - result += map[(bits >> 2) & 0x3F]; - result += map[(bits << 4) & 0x3F]; - result += map[64]; - result += map[64]; - } - - return result; -} - -function isBinary(obj) { - return Object.prototype.toString.call(obj) === '[object Uint8Array]'; -} - -var binary = new type('tag:yaml.org,2002:binary', { - kind: 'scalar', - resolve: resolveYamlBinary, - construct: constructYamlBinary, - predicate: isBinary, - represent: representYamlBinary -}); - -var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; -var _toString$2 = Object.prototype.toString; - -function resolveYamlOmap(data) { - if (data === null) return true; - - var objectKeys = [], index, length, pair, pairKey, pairHasKey, - object = data; - - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - pairHasKey = false; - - if (_toString$2.call(pair) !== '[object Object]') return false; - - for (pairKey in pair) { - if (_hasOwnProperty$3.call(pair, pairKey)) { - if (!pairHasKey) pairHasKey = true; - else return false; - } - } - - if (!pairHasKey) return false; - - if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); - else return false; - } - - return true; -} - -function constructYamlOmap(data) { - return data !== null ? data : []; -} - -var omap = new type('tag:yaml.org,2002:omap', { - kind: 'sequence', - resolve: resolveYamlOmap, - construct: constructYamlOmap -}); - -var _toString$1 = Object.prototype.toString; - -function resolveYamlPairs(data) { - if (data === null) return true; - - var index, length, pair, keys, result, - object = data; - - result = new Array(object.length); - - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - - if (_toString$1.call(pair) !== '[object Object]') return false; - - keys = Object.keys(pair); - - if (keys.length !== 1) return false; - - result[index] = [ keys[0], pair[keys[0]] ]; - } - - return true; -} - -function constructYamlPairs(data) { - if (data === null) return []; - - var index, length, pair, keys, result, - object = data; - - result = new Array(object.length); - - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - - keys = Object.keys(pair); - - result[index] = [ keys[0], pair[keys[0]] ]; - } - - return result; -} - -var pairs = new type('tag:yaml.org,2002:pairs', { - kind: 'sequence', - resolve: resolveYamlPairs, - construct: constructYamlPairs -}); - -var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; - -function resolveYamlSet(data) { - if (data === null) return true; - - var key, object = data; - - for (key in object) { - if (_hasOwnProperty$2.call(object, key)) { - if (object[key] !== null) return false; - } - } - - return true; -} - -function constructYamlSet(data) { - return data !== null ? data : {}; -} - -var set = new type('tag:yaml.org,2002:set', { - kind: 'mapping', - resolve: resolveYamlSet, - construct: constructYamlSet -}); - -var _default = core.extend({ - implicit: [ - timestamp, - merge - ], - explicit: [ - binary, - omap, - pairs, - set - ] -}); - -/*eslint-disable max-len,no-use-before-define*/ - - - - - - - -var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; - - -var CONTEXT_FLOW_IN = 1; -var CONTEXT_FLOW_OUT = 2; -var CONTEXT_BLOCK_IN = 3; -var CONTEXT_BLOCK_OUT = 4; - - -var CHOMPING_CLIP = 1; -var CHOMPING_STRIP = 2; -var CHOMPING_KEEP = 3; - - -var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; -var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; -var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; -var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; -var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; - - -function _class(obj) { return Object.prototype.toString.call(obj); } - -function is_EOL(c) { - return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); -} - -function is_WHITE_SPACE(c) { - return (c === 0x09/* Tab */) || (c === 0x20/* Space */); -} - -function is_WS_OR_EOL(c) { - return (c === 0x09/* Tab */) || - (c === 0x20/* Space */) || - (c === 0x0A/* LF */) || - (c === 0x0D/* CR */); -} - -function is_FLOW_INDICATOR(c) { - return c === 0x2C/* , */ || - c === 0x5B/* [ */ || - c === 0x5D/* ] */ || - c === 0x7B/* { */ || - c === 0x7D/* } */; -} - -function fromHexCode(c) { - var lc; - - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - /*eslint-disable no-bitwise*/ - lc = c | 0x20; - - if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { - return lc - 0x61 + 10; - } - - return -1; -} - -function escapedHexLen(c) { - if (c === 0x78/* x */) { return 2; } - if (c === 0x75/* u */) { return 4; } - if (c === 0x55/* U */) { return 8; } - return 0; -} - -function fromDecimalCode(c) { - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - return -1; -} - -function simpleEscapeSequence(c) { - /* eslint-disable indent */ - return (c === 0x30/* 0 */) ? '\x00' : - (c === 0x61/* a */) ? '\x07' : - (c === 0x62/* b */) ? '\x08' : - (c === 0x74/* t */) ? '\x09' : - (c === 0x09/* Tab */) ? '\x09' : - (c === 0x6E/* n */) ? '\x0A' : - (c === 0x76/* v */) ? '\x0B' : - (c === 0x66/* f */) ? '\x0C' : - (c === 0x72/* r */) ? '\x0D' : - (c === 0x65/* e */) ? '\x1B' : - (c === 0x20/* Space */) ? ' ' : - (c === 0x22/* " */) ? '\x22' : - (c === 0x2F/* / */) ? '/' : - (c === 0x5C/* \ */) ? '\x5C' : - (c === 0x4E/* N */) ? '\x85' : - (c === 0x5F/* _ */) ? '\xA0' : - (c === 0x4C/* L */) ? '\u2028' : - (c === 0x50/* P */) ? '\u2029' : ''; -} - -function charFromCodepoint(c) { - if (c <= 0xFFFF) { - return String.fromCharCode(c); - } - // Encode UTF-16 surrogate pair - // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF - return String.fromCharCode( - ((c - 0x010000) >> 10) + 0xD800, - ((c - 0x010000) & 0x03FF) + 0xDC00 - ); -} - -// set a property of a literal object, while protecting against prototype pollution, -// see https://github.com/nodeca/js-yaml/issues/164 for more details -function setProperty(object, key, value) { - // used for this specific key only because Object.defineProperty is slow - if (key === '__proto__') { - Object.defineProperty(object, key, { - configurable: true, - enumerable: true, - writable: true, - value: value - }); - } else { - object[key] = value; - } -} - -var simpleEscapeCheck = new Array(256); // integer, for fast access -var simpleEscapeMap = new Array(256); -for (var i = 0; i < 256; i++) { - simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; - simpleEscapeMap[i] = simpleEscapeSequence(i); -} - - -function State$1(input, options) { - this.input = input; - - this.filename = options['filename'] || null; - this.schema = options['schema'] || _default; - this.onWarning = options['onWarning'] || null; - // (Hidden) Remove? makes the loader to expect YAML 1.1 documents - // if such documents have no explicit %YAML directive - this.legacy = options['legacy'] || false; - - this.json = options['json'] || false; - this.listener = options['listener'] || null; - - this.implicitTypes = this.schema.compiledImplicit; - this.typeMap = this.schema.compiledTypeMap; - - this.length = input.length; - this.position = 0; - this.line = 0; - this.lineStart = 0; - this.lineIndent = 0; - - // position of first leading tab in the current line, - // used to make sure there are no tabs in the indentation - this.firstTabInLine = -1; - - this.documents = []; - - /* - this.version; - this.checkLineBreaks; - this.tagMap; - this.anchorMap; - this.tag; - this.anchor; - this.kind; - this.result;*/ - -} - - -function generateError(state, message) { - var mark = { - name: state.filename, - buffer: state.input.slice(0, -1), // omit trailing \0 - position: state.position, - line: state.line, - column: state.position - state.lineStart - }; - - mark.snippet = snippet(mark); - - return new exception(message, mark); -} - -function throwError(state, message) { - throw generateError(state, message); -} - -function throwWarning(state, message) { - if (state.onWarning) { - state.onWarning.call(null, generateError(state, message)); - } -} - - -var directiveHandlers = { - - YAML: function handleYamlDirective(state, name, args) { - - var match, major, minor; - - if (state.version !== null) { - throwError(state, 'duplication of %YAML directive'); - } - - if (args.length !== 1) { - throwError(state, 'YAML directive accepts exactly one argument'); - } - - match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); - - if (match === null) { - throwError(state, 'ill-formed argument of the YAML directive'); - } - - major = parseInt(match[1], 10); - minor = parseInt(match[2], 10); - - if (major !== 1) { - throwError(state, 'unacceptable YAML version of the document'); - } - - state.version = args[0]; - state.checkLineBreaks = (minor < 2); - - if (minor !== 1 && minor !== 2) { - throwWarning(state, 'unsupported YAML version of the document'); - } - }, - - TAG: function handleTagDirective(state, name, args) { - - var handle, prefix; - - if (args.length !== 2) { - throwError(state, 'TAG directive accepts exactly two arguments'); - } - - handle = args[0]; - prefix = args[1]; - - if (!PATTERN_TAG_HANDLE.test(handle)) { - throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); - } - - if (_hasOwnProperty$1.call(state.tagMap, handle)) { - throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); - } - - if (!PATTERN_TAG_URI.test(prefix)) { - throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); - } - - try { - prefix = decodeURIComponent(prefix); - } catch (err) { - throwError(state, 'tag prefix is malformed: ' + prefix); - } - - state.tagMap[handle] = prefix; - } -}; - - -function captureSegment(state, start, end, checkJson) { - var _position, _length, _character, _result; - - if (start < end) { - _result = state.input.slice(start, end); - - if (checkJson) { - for (_position = 0, _length = _result.length; _position < _length; _position += 1) { - _character = _result.charCodeAt(_position); - if (!(_character === 0x09 || - (0x20 <= _character && _character <= 0x10FFFF))) { - throwError(state, 'expected valid JSON character'); - } - } - } else if (PATTERN_NON_PRINTABLE.test(_result)) { - throwError(state, 'the stream contains non-printable characters'); - } - - state.result += _result; - } -} - -function mergeMappings(state, destination, source, overridableKeys) { - var sourceKeys, key, index, quantity; - - if (!common.isObject(source)) { - throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); - } - - sourceKeys = Object.keys(source); - - for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { - key = sourceKeys[index]; - - if (!_hasOwnProperty$1.call(destination, key)) { - setProperty(destination, key, source[key]); - overridableKeys[key] = true; - } - } -} - -function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, - startLine, startLineStart, startPos) { - - var index, quantity; - - // The output is a plain object here, so keys can only be strings. - // We need to convert keyNode to a string, but doing so can hang the process - // (deeply nested arrays that explode exponentially using aliases). - if (Array.isArray(keyNode)) { - keyNode = Array.prototype.slice.call(keyNode); - - for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { - if (Array.isArray(keyNode[index])) { - throwError(state, 'nested arrays are not supported inside keys'); - } - - if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { - keyNode[index] = '[object Object]'; - } - } - } - - // Avoid code execution in load() via toString property - // (still use its own toString for arrays, timestamps, - // and whatever user schema extensions happen to have @@toStringTag) - if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { - keyNode = '[object Object]'; - } - - - keyNode = String(keyNode); - - if (_result === null) { - _result = {}; - } - - if (keyTag === 'tag:yaml.org,2002:merge') { - if (Array.isArray(valueNode)) { - for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { - mergeMappings(state, _result, valueNode[index], overridableKeys); - } - } else { - mergeMappings(state, _result, valueNode, overridableKeys); - } - } else { - if (!state.json && - !_hasOwnProperty$1.call(overridableKeys, keyNode) && - _hasOwnProperty$1.call(_result, keyNode)) { - state.line = startLine || state.line; - state.lineStart = startLineStart || state.lineStart; - state.position = startPos || state.position; - throwError(state, 'duplicated mapping key'); - } - - setProperty(_result, keyNode, valueNode); - delete overridableKeys[keyNode]; - } - - return _result; -} - -function readLineBreak(state) { - var ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x0A/* LF */) { - state.position++; - } else if (ch === 0x0D/* CR */) { - state.position++; - if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { - state.position++; - } - } else { - throwError(state, 'a line break is expected'); - } - - state.line += 1; - state.lineStart = state.position; - state.firstTabInLine = -1; -} - -function skipSeparationSpace(state, allowComments, checkIndent) { - var lineBreaks = 0, - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { - state.firstTabInLine = state.position; - } - ch = state.input.charCodeAt(++state.position); - } - - if (allowComments && ch === 0x23/* # */) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); - } - - if (is_EOL(ch)) { - readLineBreak(state); - - ch = state.input.charCodeAt(state.position); - lineBreaks++; - state.lineIndent = 0; - - while (ch === 0x20/* Space */) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - } else { - break; - } - } - - if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { - throwWarning(state, 'deficient indentation'); - } - - return lineBreaks; -} - -function testDocumentSeparator(state) { - var _position = state.position, - ch; - - ch = state.input.charCodeAt(_position); - - // Condition state.position === state.lineStart is tested - // in parent on each call, for efficiency. No needs to test here again. - if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && - ch === state.input.charCodeAt(_position + 1) && - ch === state.input.charCodeAt(_position + 2)) { - - _position += 3; - - ch = state.input.charCodeAt(_position); - - if (ch === 0 || is_WS_OR_EOL(ch)) { - return true; - } - } - - return false; -} - -function writeFoldedLines(state, count) { - if (count === 1) { - state.result += ' '; - } else if (count > 1) { - state.result += common.repeat('\n', count - 1); - } -} - - -function readPlainScalar(state, nodeIndent, withinFlowCollection) { - var preceding, - following, - captureStart, - captureEnd, - hasPendingContent, - _line, - _lineStart, - _lineIndent, - _kind = state.kind, - _result = state.result, - ch; - - ch = state.input.charCodeAt(state.position); - - if (is_WS_OR_EOL(ch) || - is_FLOW_INDICATOR(ch) || - ch === 0x23/* # */ || - ch === 0x26/* & */ || - ch === 0x2A/* * */ || - ch === 0x21/* ! */ || - ch === 0x7C/* | */ || - ch === 0x3E/* > */ || - ch === 0x27/* ' */ || - ch === 0x22/* " */ || - ch === 0x25/* % */ || - ch === 0x40/* @ */ || - ch === 0x60/* ` */) { - return false; - } - - if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - return false; - } - } - - state.kind = 'scalar'; - state.result = ''; - captureStart = captureEnd = state.position; - hasPendingContent = false; - - while (ch !== 0) { - if (ch === 0x3A/* : */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - break; - } - - } else if (ch === 0x23/* # */) { - preceding = state.input.charCodeAt(state.position - 1); - - if (is_WS_OR_EOL(preceding)) { - break; - } - - } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || - withinFlowCollection && is_FLOW_INDICATOR(ch)) { - break; - - } else if (is_EOL(ch)) { - _line = state.line; - _lineStart = state.lineStart; - _lineIndent = state.lineIndent; - skipSeparationSpace(state, false, -1); - - if (state.lineIndent >= nodeIndent) { - hasPendingContent = true; - ch = state.input.charCodeAt(state.position); - continue; - } else { - state.position = captureEnd; - state.line = _line; - state.lineStart = _lineStart; - state.lineIndent = _lineIndent; - break; - } - } - - if (hasPendingContent) { - captureSegment(state, captureStart, captureEnd, false); - writeFoldedLines(state, state.line - _line); - captureStart = captureEnd = state.position; - hasPendingContent = false; - } - - if (!is_WHITE_SPACE(ch)) { - captureEnd = state.position + 1; - } - - ch = state.input.charCodeAt(++state.position); - } - - captureSegment(state, captureStart, captureEnd, false); - - if (state.result) { - return true; - } - - state.kind = _kind; - state.result = _result; - return false; -} - -function readSingleQuotedScalar(state, nodeIndent) { - var ch, - captureStart, captureEnd; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x27/* ' */) { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x27/* ' */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x27/* ' */) { - captureStart = state.position; - state.position++; - captureEnd = state.position; - } else { - return true; - } - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a single quoted scalar'); - - } else { - state.position++; - captureEnd = state.position; - } - } - - throwError(state, 'unexpected end of the stream within a single quoted scalar'); -} - -function readDoubleQuotedScalar(state, nodeIndent) { - var captureStart, - captureEnd, - hexLength, - hexResult, - tmp, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x22/* " */) { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x22/* " */) { - captureSegment(state, captureStart, state.position, true); - state.position++; - return true; - - } else if (ch === 0x5C/* \ */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - - if (is_EOL(ch)) { - skipSeparationSpace(state, false, nodeIndent); - - // TODO: rework to inline fn with no type cast? - } else if (ch < 256 && simpleEscapeCheck[ch]) { - state.result += simpleEscapeMap[ch]; - state.position++; - - } else if ((tmp = escapedHexLen(ch)) > 0) { - hexLength = tmp; - hexResult = 0; - - for (; hexLength > 0; hexLength--) { - ch = state.input.charCodeAt(++state.position); - - if ((tmp = fromHexCode(ch)) >= 0) { - hexResult = (hexResult << 4) + tmp; - - } else { - throwError(state, 'expected hexadecimal character'); - } - } - - state.result += charFromCodepoint(hexResult); - - state.position++; - - } else { - throwError(state, 'unknown escape sequence'); - } - - captureStart = captureEnd = state.position; - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a double quoted scalar'); - - } else { - state.position++; - captureEnd = state.position; - } - } - - throwError(state, 'unexpected end of the stream within a double quoted scalar'); -} - -function readFlowCollection(state, nodeIndent) { - var readNext = true, - _line, - _lineStart, - _pos, - _tag = state.tag, - _result, - _anchor = state.anchor, - following, - terminator, - isPair, - isExplicitPair, - isMapping, - overridableKeys = Object.create(null), - keyNode, - keyTag, - valueNode, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x5B/* [ */) { - terminator = 0x5D;/* ] */ - isMapping = false; - _result = []; - } else if (ch === 0x7B/* { */) { - terminator = 0x7D;/* } */ - isMapping = true; - _result = {}; - } else { - return false; - } - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(++state.position); - - while (ch !== 0) { - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if (ch === terminator) { - state.position++; - state.tag = _tag; - state.anchor = _anchor; - state.kind = isMapping ? 'mapping' : 'sequence'; - state.result = _result; - return true; - } else if (!readNext) { - throwError(state, 'missed comma between flow collection entries'); - } else if (ch === 0x2C/* , */) { - // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 - throwError(state, "expected the node content, but found ','"); - } - - keyTag = keyNode = valueNode = null; - isPair = isExplicitPair = false; - - if (ch === 0x3F/* ? */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following)) { - isPair = isExplicitPair = true; - state.position++; - skipSeparationSpace(state, true, nodeIndent); - } - } - - _line = state.line; // Save the current line. - _lineStart = state.lineStart; - _pos = state.position; - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - keyTag = state.tag; - keyNode = state.result; - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { - isPair = true; - ch = state.input.charCodeAt(++state.position); - skipSeparationSpace(state, true, nodeIndent); - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - valueNode = state.result; - } - - if (isMapping) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); - } else if (isPair) { - _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); - } else { - _result.push(keyNode); - } - - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x2C/* , */) { - readNext = true; - ch = state.input.charCodeAt(++state.position); - } else { - readNext = false; - } - } - - throwError(state, 'unexpected end of the stream within a flow collection'); -} - -function readBlockScalar(state, nodeIndent) { - var captureStart, - folding, - chomping = CHOMPING_CLIP, - didReadContent = false, - detectedIndent = false, - textIndent = nodeIndent, - emptyLines = 0, - atMoreIndented = false, - tmp, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x7C/* | */) { - folding = false; - } else if (ch === 0x3E/* > */) { - folding = true; - } else { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - - while (ch !== 0) { - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { - if (CHOMPING_CLIP === chomping) { - chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; - } else { - throwError(state, 'repeat of a chomping mode identifier'); - } - - } else if ((tmp = fromDecimalCode(ch)) >= 0) { - if (tmp === 0) { - throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); - } else if (!detectedIndent) { - textIndent = nodeIndent + tmp - 1; - detectedIndent = true; - } else { - throwError(state, 'repeat of an indentation width identifier'); - } - - } else { - break; - } - } - - if (is_WHITE_SPACE(ch)) { - do { ch = state.input.charCodeAt(++state.position); } - while (is_WHITE_SPACE(ch)); - - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (!is_EOL(ch) && (ch !== 0)); - } - } - - while (ch !== 0) { - readLineBreak(state); - state.lineIndent = 0; - - ch = state.input.charCodeAt(state.position); - - while ((!detectedIndent || state.lineIndent < textIndent) && - (ch === 0x20/* Space */)) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - - if (!detectedIndent && state.lineIndent > textIndent) { - textIndent = state.lineIndent; - } - - if (is_EOL(ch)) { - emptyLines++; - continue; - } - - // End of the scalar. - if (state.lineIndent < textIndent) { - - // Perform the chomping. - if (chomping === CHOMPING_KEEP) { - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } else if (chomping === CHOMPING_CLIP) { - if (didReadContent) { // i.e. only if the scalar is not empty. - state.result += '\n'; - } - } - - // Break this `while` cycle and go to the funciton's epilogue. - break; - } - - // Folded style: use fancy rules to handle line breaks. - if (folding) { - - // Lines starting with white space characters (more-indented lines) are not folded. - if (is_WHITE_SPACE(ch)) { - atMoreIndented = true; - // except for the first content line (cf. Example 8.1) - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - - // End of more-indented block. - } else if (atMoreIndented) { - atMoreIndented = false; - state.result += common.repeat('\n', emptyLines + 1); - - // Just one line break - perceive as the same line. - } else if (emptyLines === 0) { - if (didReadContent) { // i.e. only if we have already read some scalar content. - state.result += ' '; - } - - // Several line breaks - perceive as different lines. - } else { - state.result += common.repeat('\n', emptyLines); - } - - // Literal style: just add exact number of line breaks between content lines. - } else { - // Keep all line breaks except the header line break. - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } - - didReadContent = true; - detectedIndent = true; - emptyLines = 0; - captureStart = state.position; - - while (!is_EOL(ch) && (ch !== 0)) { - ch = state.input.charCodeAt(++state.position); - } - - captureSegment(state, captureStart, state.position, false); - } - - return true; -} - -function readBlockSequence(state, nodeIndent) { - var _line, - _tag = state.tag, - _anchor = state.anchor, - _result = [], - following, - detected = false, - ch; - - // there is a leading tab before this token, so it can't be a block sequence/mapping; - // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - if (state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); - } - - if (ch !== 0x2D/* - */) { - break; - } - - following = state.input.charCodeAt(state.position + 1); - - if (!is_WS_OR_EOL(following)) { - break; - } - - detected = true; - state.position++; - - if (skipSeparationSpace(state, true, -1)) { - if (state.lineIndent <= nodeIndent) { - _result.push(null); - ch = state.input.charCodeAt(state.position); - continue; - } - } - - _line = state.line; - composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); - _result.push(state.result); - skipSeparationSpace(state, true, -1); - - ch = state.input.charCodeAt(state.position); - - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a sequence entry'); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'sequence'; - state.result = _result; - return true; - } - return false; -} - -function readBlockMapping(state, nodeIndent, flowIndent) { - var following, - allowCompact, - _line, - _keyLine, - _keyLineStart, - _keyPos, - _tag = state.tag, - _anchor = state.anchor, - _result = {}, - overridableKeys = Object.create(null), - keyTag = null, - keyNode = null, - valueNode = null, - atExplicitKey = false, - detected = false, - ch; - - // there is a leading tab before this token, so it can't be a block sequence/mapping; - // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - if (!atExplicitKey && state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); - } - - following = state.input.charCodeAt(state.position + 1); - _line = state.line; // Save the current line. - - // - // Explicit notation case. There are two separate blocks: - // first for the key (denoted by "?") and second for the value (denoted by ":") - // - if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { - - if (ch === 0x3F/* ? */) { - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - - detected = true; - atExplicitKey = true; - allowCompact = true; - - } else if (atExplicitKey) { - // i.e. 0x3A/* : */ === character after the explicit key. - atExplicitKey = false; - allowCompact = true; - - } else { - throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); - } - - state.position += 1; - ch = following; - - // - // Implicit notation case. Flow-style node as the key first, then ":", and the value. - // - } else { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - - if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { - // Neither implicit nor explicit notation. - // Reading is done. Go to the epilogue. - break; - } - - if (state.line === _line) { - ch = state.input.charCodeAt(state.position); - - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (ch === 0x3A/* : */) { - ch = state.input.charCodeAt(++state.position); - - if (!is_WS_OR_EOL(ch)) { - throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); - } - - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - - detected = true; - atExplicitKey = false; - allowCompact = false; - keyTag = state.tag; - keyNode = state.result; - - } else if (detected) { - throwError(state, 'can not read an implicit mapping pair; a colon is missed'); - - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. - } - - } else if (detected) { - throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); - - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. - } - } - - // - // Common reading code for both explicit and implicit notations. - // - if (state.line === _line || state.lineIndent > nodeIndent) { - if (atExplicitKey) { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - } - - if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { - if (atExplicitKey) { - keyNode = state.result; - } else { - valueNode = state.result; - } - } - - if (!atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } - - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); - } - - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a mapping entry'); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - - // - // Epilogue. - // - - // Special case: last mapping's node contains only the key in explicit notation. - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - } - - // Expose the resulting mapping. - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'mapping'; - state.result = _result; - } - - return detected; -} - -function readTagProperty(state) { - var _position, - isVerbatim = false, - isNamed = false, - tagHandle, - tagName, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x21/* ! */) return false; - - if (state.tag !== null) { - throwError(state, 'duplication of a tag property'); - } - - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x3C/* < */) { - isVerbatim = true; - ch = state.input.charCodeAt(++state.position); - - } else if (ch === 0x21/* ! */) { - isNamed = true; - tagHandle = '!!'; - ch = state.input.charCodeAt(++state.position); - - } else { - tagHandle = '!'; - } - - _position = state.position; - - if (isVerbatim) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && ch !== 0x3E/* > */); - - if (state.position < state.length) { - tagName = state.input.slice(_position, state.position); - ch = state.input.charCodeAt(++state.position); - } else { - throwError(state, 'unexpected end of the stream within a verbatim tag'); - } - } else { - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - - if (ch === 0x21/* ! */) { - if (!isNamed) { - tagHandle = state.input.slice(_position - 1, state.position + 1); - - if (!PATTERN_TAG_HANDLE.test(tagHandle)) { - throwError(state, 'named tag handle cannot contain such characters'); - } - - isNamed = true; - _position = state.position + 1; - } else { - throwError(state, 'tag suffix cannot contain exclamation marks'); - } - } - - ch = state.input.charCodeAt(++state.position); - } - - tagName = state.input.slice(_position, state.position); - - if (PATTERN_FLOW_INDICATORS.test(tagName)) { - throwError(state, 'tag suffix cannot contain flow indicator characters'); - } - } - - if (tagName && !PATTERN_TAG_URI.test(tagName)) { - throwError(state, 'tag name cannot contain such characters: ' + tagName); - } - - try { - tagName = decodeURIComponent(tagName); - } catch (err) { - throwError(state, 'tag name is malformed: ' + tagName); - } - - if (isVerbatim) { - state.tag = tagName; - - } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { - state.tag = state.tagMap[tagHandle] + tagName; - - } else if (tagHandle === '!') { - state.tag = '!' + tagName; - - } else if (tagHandle === '!!') { - state.tag = 'tag:yaml.org,2002:' + tagName; - - } else { - throwError(state, 'undeclared tag handle "' + tagHandle + '"'); - } - - return true; -} - -function readAnchorProperty(state) { - var _position, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x26/* & */) return false; - - if (state.anchor !== null) { - throwError(state, 'duplication of an anchor property'); - } - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an anchor node must contain at least one character'); - } - - state.anchor = state.input.slice(_position, state.position); - return true; -} - -function readAlias(state) { - var _position, alias, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x2A/* * */) return false; - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an alias node must contain at least one character'); - } - - alias = state.input.slice(_position, state.position); - - if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { - throwError(state, 'unidentified alias "' + alias + '"'); - } - - state.result = state.anchorMap[alias]; - skipSeparationSpace(state, true, -1); - return true; -} - -function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { - var allowBlockStyles, - allowBlockScalars, - allowBlockCollections, - indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } - } - - if (indentStatus === 1) { - while (readTagProperty(state) || readAnchorProperty(state)) { - if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; - allowBlockCollections = allowBlockStyles; - - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } else { - allowBlockCollections = false; - } - } - } - - if (allowBlockCollections) { - allowBlockCollections = atNewLine || allowCompact; - } - - if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { - if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { - flowIndent = parentIndent; - } else { - flowIndent = parentIndent + 1; - } - - blockIndent = state.position - state.lineStart; - - if (indentStatus === 1) { - if (allowBlockCollections && - (readBlockSequence(state, blockIndent) || - readBlockMapping(state, blockIndent, flowIndent)) || - readFlowCollection(state, flowIndent)) { - hasContent = true; - } else { - if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || - readSingleQuotedScalar(state, flowIndent) || - readDoubleQuotedScalar(state, flowIndent)) { - hasContent = true; - - } else if (readAlias(state)) { - hasContent = true; - - if (state.tag !== null || state.anchor !== null) { - throwError(state, 'alias node should not have any properties'); - } - - } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { - hasContent = true; - - if (state.tag === null) { - state.tag = '?'; - } - } - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } - } else if (indentStatus === 0) { - // Special case: block sequences are allowed to have same indentation level as the parent. - // http://www.yaml.org/spec/1.2/spec.html#id2799784 - hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); - } - } - - if (state.tag === null) { - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - - } else if (state.tag === '?') { - // Implicit resolving is not allowed for non-scalar types, and '?' - // non-specific tag is only automatically assigned to plain scalars. - // - // We only need to check kind conformity in case user explicitly assigns '?' - // tag, for example like this: "! [0]" - // - if (state.result !== null && state.kind !== 'scalar') { - throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); - } - - for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { - type = state.implicitTypes[typeIndex]; - - if (type.resolve(state.result)) { // `state.result` updated in resolver if matched - state.result = type.construct(state.result); - state.tag = type.tag; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - break; - } - } - } else if (state.tag !== '!') { - if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) { - type = state.typeMap[state.kind || 'fallback'][state.tag]; - } else { - // looking for multi type - type = null; - typeList = state.typeMap.multi[state.kind || 'fallback']; - - for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { - if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { - type = typeList[typeIndex]; - break; - } - } - } - - if (!type) { - throwError(state, 'unknown tag !<' + state.tag + '>'); - } - - if (state.result !== null && type.kind !== state.kind) { - throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); - } - - if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched - throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); - } else { - state.result = type.construct(state.result, state.tag); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } - } - - if (state.listener !== null) { - state.listener('close', state); - } - return state.tag !== null || state.anchor !== null || hasContent; -} - -function readDocument(state) { - var documentStart = state.position, - _position, - directiveName, - directiveArgs, - hasDirectives = false, - ch; - - state.version = null; - state.checkLineBreaks = state.legacy; - state.tagMap = Object.create(null); - state.anchorMap = Object.create(null); - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - skipSeparationSpace(state, true, -1); - - ch = state.input.charCodeAt(state.position); - - if (state.lineIndent > 0 || ch !== 0x25/* % */) { - break; - } - - hasDirectives = true; - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - directiveName = state.input.slice(_position, state.position); - directiveArgs = []; - - if (directiveName.length < 1) { - throwError(state, 'directive name must not be less than one character in length'); - } - - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && !is_EOL(ch)); - break; - } - - if (is_EOL(ch)) break; - - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - directiveArgs.push(state.input.slice(_position, state.position)); - } - - if (ch !== 0) readLineBreak(state); - - if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { - directiveHandlers[directiveName](state, directiveName, directiveArgs); - } else { - throwWarning(state, 'unknown document directive "' + directiveName + '"'); - } - } - - skipSeparationSpace(state, true, -1); - - if (state.lineIndent === 0 && - state.input.charCodeAt(state.position) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - - } else if (hasDirectives) { - throwError(state, 'directives end mark is expected'); - } - - composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); - skipSeparationSpace(state, true, -1); - - if (state.checkLineBreaks && - PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { - throwWarning(state, 'non-ASCII line breaks are interpreted as content'); - } - - state.documents.push(state.result); - - if (state.position === state.lineStart && testDocumentSeparator(state)) { - - if (state.input.charCodeAt(state.position) === 0x2E/* . */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - } - return; - } - - if (state.position < (state.length - 1)) { - throwError(state, 'end of the stream or a document separator is expected'); - } else { - return; - } -} - - -function loadDocuments(input, options) { - input = String(input); - options = options || {}; - - if (input.length !== 0) { - - // Add tailing `\n` if not exists - if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && - input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { - input += '\n'; - } - - // Strip BOM - if (input.charCodeAt(0) === 0xFEFF) { - input = input.slice(1); - } - } - - var state = new State$1(input, options); - - var nullpos = input.indexOf('\0'); - - if (nullpos !== -1) { - state.position = nullpos; - throwError(state, 'null byte is not allowed in input'); - } - - // Use 0 as string terminator. That significantly simplifies bounds check. - state.input += '\0'; - - while (state.input.charCodeAt(state.position) === 0x20/* Space */) { - state.lineIndent += 1; - state.position += 1; - } - - while (state.position < (state.length - 1)) { - readDocument(state); - } - - return state.documents; -} - - -function loadAll$1(input, iterator, options) { - if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { - options = iterator; - iterator = null; - } - - var documents = loadDocuments(input, options); - - if (typeof iterator !== 'function') { - return documents; - } - - for (var index = 0, length = documents.length; index < length; index += 1) { - iterator(documents[index]); - } -} - - -function load$1(input, options) { - var documents = loadDocuments(input, options); - - if (documents.length === 0) { - /*eslint-disable no-undefined*/ - return undefined; - } else if (documents.length === 1) { - return documents[0]; - } - throw new exception('expected a single document in the stream, but found more'); -} - - -var loadAll_1 = loadAll$1; -var load_1 = load$1; - -var loader = { - loadAll: loadAll_1, - load: load_1 -}; - -/*eslint-disable no-use-before-define*/ - - - - - -var _toString = Object.prototype.toString; -var _hasOwnProperty = Object.prototype.hasOwnProperty; - -var CHAR_BOM = 0xFEFF; -var CHAR_TAB = 0x09; /* Tab */ -var CHAR_LINE_FEED = 0x0A; /* LF */ -var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ -var CHAR_SPACE = 0x20; /* Space */ -var CHAR_EXCLAMATION = 0x21; /* ! */ -var CHAR_DOUBLE_QUOTE = 0x22; /* " */ -var CHAR_SHARP = 0x23; /* # */ -var CHAR_PERCENT = 0x25; /* % */ -var CHAR_AMPERSAND = 0x26; /* & */ -var CHAR_SINGLE_QUOTE = 0x27; /* ' */ -var CHAR_ASTERISK = 0x2A; /* * */ -var CHAR_COMMA = 0x2C; /* , */ -var CHAR_MINUS = 0x2D; /* - */ -var CHAR_COLON = 0x3A; /* : */ -var CHAR_EQUALS = 0x3D; /* = */ -var CHAR_GREATER_THAN = 0x3E; /* > */ -var CHAR_QUESTION = 0x3F; /* ? */ -var CHAR_COMMERCIAL_AT = 0x40; /* @ */ -var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ -var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ -var CHAR_GRAVE_ACCENT = 0x60; /* ` */ -var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ -var CHAR_VERTICAL_LINE = 0x7C; /* | */ -var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ - -var ESCAPE_SEQUENCES = {}; - -ESCAPE_SEQUENCES[0x00] = '\\0'; -ESCAPE_SEQUENCES[0x07] = '\\a'; -ESCAPE_SEQUENCES[0x08] = '\\b'; -ESCAPE_SEQUENCES[0x09] = '\\t'; -ESCAPE_SEQUENCES[0x0A] = '\\n'; -ESCAPE_SEQUENCES[0x0B] = '\\v'; -ESCAPE_SEQUENCES[0x0C] = '\\f'; -ESCAPE_SEQUENCES[0x0D] = '\\r'; -ESCAPE_SEQUENCES[0x1B] = '\\e'; -ESCAPE_SEQUENCES[0x22] = '\\"'; -ESCAPE_SEQUENCES[0x5C] = '\\\\'; -ESCAPE_SEQUENCES[0x85] = '\\N'; -ESCAPE_SEQUENCES[0xA0] = '\\_'; -ESCAPE_SEQUENCES[0x2028] = '\\L'; -ESCAPE_SEQUENCES[0x2029] = '\\P'; - -var DEPRECATED_BOOLEANS_SYNTAX = [ - 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', - 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' -]; - -var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; - -function compileStyleMap(schema, map) { - var result, keys, index, length, tag, style, type; - - if (map === null) return {}; - - result = {}; - keys = Object.keys(map); - - for (index = 0, length = keys.length; index < length; index += 1) { - tag = keys[index]; - style = String(map[tag]); - - if (tag.slice(0, 2) === '!!') { - tag = 'tag:yaml.org,2002:' + tag.slice(2); - } - type = schema.compiledTypeMap['fallback'][tag]; - - if (type && _hasOwnProperty.call(type.styleAliases, style)) { - style = type.styleAliases[style]; - } - - result[tag] = style; - } - - return result; -} - -function encodeHex(character) { - var string, handle, length; - - string = character.toString(16).toUpperCase(); - - if (character <= 0xFF) { - handle = 'x'; - length = 2; - } else if (character <= 0xFFFF) { - handle = 'u'; - length = 4; - } else if (character <= 0xFFFFFFFF) { - handle = 'U'; - length = 8; - } else { - throw new exception('code point within a string may not be greater than 0xFFFFFFFF'); - } - - return '\\' + handle + common.repeat('0', length - string.length) + string; -} - - -var QUOTING_TYPE_SINGLE = 1, - QUOTING_TYPE_DOUBLE = 2; - -function State(options) { - this.schema = options['schema'] || _default; - this.indent = Math.max(1, (options['indent'] || 2)); - this.noArrayIndent = options['noArrayIndent'] || false; - this.skipInvalid = options['skipInvalid'] || false; - this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); - this.styleMap = compileStyleMap(this.schema, options['styles'] || null); - this.sortKeys = options['sortKeys'] || false; - this.lineWidth = options['lineWidth'] || 80; - this.noRefs = options['noRefs'] || false; - this.noCompatMode = options['noCompatMode'] || false; - this.condenseFlow = options['condenseFlow'] || false; - this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; - this.forceQuotes = options['forceQuotes'] || false; - this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; - - this.implicitTypes = this.schema.compiledImplicit; - this.explicitTypes = this.schema.compiledExplicit; - - this.tag = null; - this.result = ''; - - this.duplicates = []; - this.usedDuplicates = null; -} - -// Indents every line in a string. Empty lines (\n only) are not indented. -function indentString(string, spaces) { - var ind = common.repeat(' ', spaces), - position = 0, - next = -1, - result = '', - line, - length = string.length; - - while (position < length) { - next = string.indexOf('\n', position); - if (next === -1) { - line = string.slice(position); - position = length; - } else { - line = string.slice(position, next + 1); - position = next + 1; - } - - if (line.length && line !== '\n') result += ind; - - result += line; - } - - return result; -} - -function generateNextLine(state, level) { - return '\n' + common.repeat(' ', state.indent * level); -} - -function testImplicitResolving(state, str) { - var index, length, type; - - for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { - type = state.implicitTypes[index]; - - if (type.resolve(str)) { - return true; - } - } - - return false; -} - -// [33] s-white ::= s-space | s-tab -function isWhitespace(c) { - return c === CHAR_SPACE || c === CHAR_TAB; -} - -// Returns true if the character can be printed without escaping. -// From YAML 1.2: "any allowed characters known to be non-printable -// should also be escaped. [However,] This isn’t mandatory" -// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. -function isPrintable(c) { - return (0x00020 <= c && c <= 0x00007E) - || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) - || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) - || (0x10000 <= c && c <= 0x10FFFF); -} - -// [34] ns-char ::= nb-char - s-white -// [27] nb-char ::= c-printable - b-char - c-byte-order-mark -// [26] b-char ::= b-line-feed | b-carriage-return -// Including s-white (for some reason, examples doesn't match specs in this aspect) -// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark -function isNsCharOrWhitespace(c) { - return isPrintable(c) - && c !== CHAR_BOM - // - b-char - && c !== CHAR_CARRIAGE_RETURN - && c !== CHAR_LINE_FEED; -} - -// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out -// c = flow-in ⇒ ns-plain-safe-in -// c = block-key ⇒ ns-plain-safe-out -// c = flow-key ⇒ ns-plain-safe-in -// [128] ns-plain-safe-out ::= ns-char -// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator -// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) -// | ( /* An ns-char preceding */ “#” ) -// | ( “:” /* Followed by an ns-plain-safe(c) */ ) -function isPlainSafe(c, prev, inblock) { - var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); - var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); - return ( - // ns-plain-safe - inblock ? // c = flow-in - cIsNsCharOrWhitespace - : cIsNsCharOrWhitespace - // - c-flow-indicator - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET - ) - // ns-plain-char - && c !== CHAR_SHARP // false on '#' - && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' - || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' - || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' -} - -// Simplified test for values allowed as the first character in plain style. -function isPlainSafeFirst(c) { - // Uses a subset of ns-char - c-indicator - // where ns-char = nb-char - s-white. - // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part - return isPrintable(c) && c !== CHAR_BOM - && !isWhitespace(c) // - s-white - // - (c-indicator ::= - // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” - && c !== CHAR_MINUS - && c !== CHAR_QUESTION - && c !== CHAR_COLON - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET - // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” - && c !== CHAR_SHARP - && c !== CHAR_AMPERSAND - && c !== CHAR_ASTERISK - && c !== CHAR_EXCLAMATION - && c !== CHAR_VERTICAL_LINE - && c !== CHAR_EQUALS - && c !== CHAR_GREATER_THAN - && c !== CHAR_SINGLE_QUOTE - && c !== CHAR_DOUBLE_QUOTE - // | “%” | “@” | “`”) - && c !== CHAR_PERCENT - && c !== CHAR_COMMERCIAL_AT - && c !== CHAR_GRAVE_ACCENT; -} - -// Simplified test for values allowed as the last character in plain style. -function isPlainSafeLast(c) { - // just not whitespace or colon, it will be checked to be plain character later - return !isWhitespace(c) && c !== CHAR_COLON; -} - -// Same as 'string'.codePointAt(pos), but works in older browsers. -function codePointAt(string, pos) { - var first = string.charCodeAt(pos), second; - if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { - second = string.charCodeAt(pos + 1); - if (second >= 0xDC00 && second <= 0xDFFF) { - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; - } - } - return first; -} - -// Determines whether block indentation indicator is required. -function needIndentIndicator(string) { - var leadingSpaceRe = /^\n* /; - return leadingSpaceRe.test(string); -} - -var STYLE_PLAIN = 1, - STYLE_SINGLE = 2, - STYLE_LITERAL = 3, - STYLE_FOLDED = 4, - STYLE_DOUBLE = 5; - -// Determines which scalar styles are possible and returns the preferred style. -// lineWidth = -1 => no limit. -// Pre-conditions: str.length > 0. -// Post-conditions: -// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. -// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). -// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). -function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, - testAmbiguousType, quotingType, forceQuotes, inblock) { - - var i; - var char = 0; - var prevChar = null; - var hasLineBreak = false; - var hasFoldableLine = false; // only checked if shouldTrackWidth - var shouldTrackWidth = lineWidth !== -1; - var previousLineBreak = -1; // count the first line correctly - var plain = isPlainSafeFirst(codePointAt(string, 0)) - && isPlainSafeLast(codePointAt(string, string.length - 1)); - - if (singleLineOnly || forceQuotes) { - // Case: no block styles. - // Check for disallowed characters to rule out plain and single. - for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - if (!isPrintable(char)) { - return STYLE_DOUBLE; - } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; - } - } else { - // Case: block styles permitted. - for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - if (char === CHAR_LINE_FEED) { - hasLineBreak = true; - // Check if any line can be folded. - if (shouldTrackWidth) { - hasFoldableLine = hasFoldableLine || - // Foldable line = too long, and not more-indented. - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' '); - previousLineBreak = i; - } - } else if (!isPrintable(char)) { - return STYLE_DOUBLE; - } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; - } - // in case the end is missing a \n - hasFoldableLine = hasFoldableLine || (shouldTrackWidth && - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' ')); - } - // Although every style can represent \n without escaping, prefer block styles - // for multiline, since they're more readable and they don't add empty lines. - // Also prefer folding a super-long line. - if (!hasLineBreak && !hasFoldableLine) { - // Strings interpretable as another type have to be quoted; - // e.g. the string 'true' vs. the boolean true. - if (plain && !forceQuotes && !testAmbiguousType(string)) { - return STYLE_PLAIN; - } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; - } - // Edge case: block indentation indicator can only have one digit. - if (indentPerLevel > 9 && needIndentIndicator(string)) { - return STYLE_DOUBLE; - } - // At this point we know block styles are valid. - // Prefer literal style unless we want to fold. - if (!forceQuotes) { - return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; - } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; -} - -// Note: line breaking/folding is implemented for only the folded style. -// NB. We drop the last trailing newline (if any) of a returned block scalar -// since the dumper adds its own newline. This always works: -// • No ending newline => unaffected; already using strip "-" chomping. -// • Ending newline => removed then restored. -// Importantly, this keeps the "+" chomp indicator from gaining an extra line. -function writeScalar(state, string, level, iskey, inblock) { - state.dump = (function () { - if (string.length === 0) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; - } - if (!state.noCompatMode) { - if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); - } - } - - var indent = state.indent * Math.max(1, level); // no 0-indent scalars - // As indentation gets deeper, let the width decrease monotonically - // to the lower bound min(state.lineWidth, 40). - // Note that this implies - // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. - // state.lineWidth > 40 + state.indent: width decreases until the lower bound. - // This behaves better than a constant minimum width which disallows narrower options, - // or an indent threshold which causes the width to suddenly increase. - var lineWidth = state.lineWidth === -1 - ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); - - // Without knowing if keys are implicit/explicit, assume implicit for safety. - var singleLineOnly = iskey - // No block styles in flow mode. - || (state.flowLevel > -1 && level >= state.flowLevel); - function testAmbiguity(string) { - return testImplicitResolving(state, string); - } - - switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, - testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { - - case STYLE_PLAIN: - return string; - case STYLE_SINGLE: - return "'" + string.replace(/'/g, "''") + "'"; - case STYLE_LITERAL: - return '|' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(string, indent)); - case STYLE_FOLDED: - return '>' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); - case STYLE_DOUBLE: - return '"' + escapeString(string) + '"'; - default: - throw new exception('impossible error: invalid scalar style'); - } - }()); -} - -// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. -function blockHeader(string, indentPerLevel) { - var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; - - // note the special case: the string '\n' counts as a "trailing" empty line. - var clip = string[string.length - 1] === '\n'; - var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); - var chomp = keep ? '+' : (clip ? '' : '-'); - - return indentIndicator + chomp + '\n'; -} - -// (See the note for writeScalar.) -function dropEndingNewline(string) { - return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; -} - -// Note: a long line without a suitable break point will exceed the width limit. -// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. -function foldString(string, width) { - // In folded style, $k$ consecutive newlines output as $k+1$ newlines— - // unless they're before or after a more-indented line, or at the very - // beginning or end, in which case $k$ maps to $k$. - // Therefore, parse each chunk as newline(s) followed by a content line. - var lineRe = /(\n+)([^\n]*)/g; - - // first line (possibly an empty line) - var result = (function () { - var nextLF = string.indexOf('\n'); - nextLF = nextLF !== -1 ? nextLF : string.length; - lineRe.lastIndex = nextLF; - return foldLine(string.slice(0, nextLF), width); - }()); - // If we haven't reached the first content line yet, don't add an extra \n. - var prevMoreIndented = string[0] === '\n' || string[0] === ' '; - var moreIndented; - - // rest of the lines - var match; - while ((match = lineRe.exec(string))) { - var prefix = match[1], line = match[2]; - moreIndented = (line[0] === ' '); - result += prefix - + (!prevMoreIndented && !moreIndented && line !== '' - ? '\n' : '') - + foldLine(line, width); - prevMoreIndented = moreIndented; - } - - return result; -} - -// Greedy line breaking. -// Picks the longest line under the limit each time, -// otherwise settles for the shortest line over the limit. -// NB. More-indented lines *cannot* be folded, as that would add an extra \n. -function foldLine(line, width) { - if (line === '' || line[0] === ' ') return line; - - // Since a more-indented line adds a \n, breaks can't be followed by a space. - var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. - var match; - // start is an inclusive index. end, curr, and next are exclusive. - var start = 0, end, curr = 0, next = 0; - var result = ''; - - // Invariants: 0 <= start <= length-1. - // 0 <= curr <= next <= max(0, length-2). curr - start <= width. - // Inside the loop: - // A match implies length >= 2, so curr and next are <= length-2. - while ((match = breakRe.exec(line))) { - next = match.index; - // maintain invariant: curr - start <= width - if (next - start > width) { - end = (curr > start) ? curr : next; // derive end <= length-2 - result += '\n' + line.slice(start, end); - // skip the space that was output as \n - start = end + 1; // derive start <= length-1 - } - curr = next; - } - - // By the invariants, start <= length-1, so there is something left over. - // It is either the whole string or a part starting from non-whitespace. - result += '\n'; - // Insert a break if the remainder is too long and there is a break available. - if (line.length - start > width && curr > start) { - result += line.slice(start, curr) + '\n' + line.slice(curr + 1); - } else { - result += line.slice(start); - } - - return result.slice(1); // drop extra \n joiner -} - -// Escapes a double-quoted string. -function escapeString(string) { - var result = ''; - var char = 0; - var escapeSeq; - - for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - escapeSeq = ESCAPE_SEQUENCES[char]; - - if (!escapeSeq && isPrintable(char)) { - result += string[i]; - if (char >= 0x10000) result += string[i + 1]; - } else { - result += escapeSeq || encodeHex(char); - } - } - - return result; -} - -function writeFlowSequence(state, level, object) { - var _result = '', - _tag = state.tag, - index, - length, - value; - - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; - - if (state.replacer) { - value = state.replacer.call(object, String(index), value); - } - - // Write only valid elements, put null instead of invalid elements. - if (writeNode(state, level, value, false, false) || - (typeof value === 'undefined' && - writeNode(state, level, null, false, false))) { - - if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); - _result += state.dump; - } - } - - state.tag = _tag; - state.dump = '[' + _result + ']'; -} - -function writeBlockSequence(state, level, object, compact) { - var _result = '', - _tag = state.tag, - index, - length, - value; - - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; - - if (state.replacer) { - value = state.replacer.call(object, String(index), value); - } - - // Write only valid elements, put null instead of invalid elements. - if (writeNode(state, level + 1, value, true, true, false, true) || - (typeof value === 'undefined' && - writeNode(state, level + 1, null, true, true, false, true))) { - - if (!compact || _result !== '') { - _result += generateNextLine(state, level); - } - - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - _result += '-'; - } else { - _result += '- '; - } - - _result += state.dump; - } - } - - state.tag = _tag; - state.dump = _result || '[]'; // Empty sequence if no valid values. -} - -function writeFlowMapping(state, level, object) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - pairBuffer; - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - - pairBuffer = ''; - if (_result !== '') pairBuffer += ', '; - - if (state.condenseFlow) pairBuffer += '"'; - - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; - - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); - } - - if (!writeNode(state, level, objectKey, false, false)) { - continue; // Skip this pair because of invalid key; - } - - if (state.dump.length > 1024) pairBuffer += '? '; - - pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); - - if (!writeNode(state, level, objectValue, false, false)) { - continue; // Skip this pair because of invalid value. - } - - pairBuffer += state.dump; - - // Both key and value are valid. - _result += pairBuffer; - } - - state.tag = _tag; - state.dump = '{' + _result + '}'; -} - -function writeBlockMapping(state, level, object, compact) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - explicitPair, - pairBuffer; - - // Allow sorting keys so that the output file is deterministic - if (state.sortKeys === true) { - // Default sorting - objectKeyList.sort(); - } else if (typeof state.sortKeys === 'function') { - // Custom sort function - objectKeyList.sort(state.sortKeys); - } else if (state.sortKeys) { - // Something is wrong - throw new exception('sortKeys must be a boolean or a function'); - } - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ''; - - if (!compact || _result !== '') { - pairBuffer += generateNextLine(state, level); - } - - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; - - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); - } - - if (!writeNode(state, level + 1, objectKey, true, true, true)) { - continue; // Skip this pair because of invalid key. - } - - explicitPair = (state.tag !== null && state.tag !== '?') || - (state.dump && state.dump.length > 1024); - - if (explicitPair) { - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += '?'; - } else { - pairBuffer += '? '; - } - } - - pairBuffer += state.dump; - - if (explicitPair) { - pairBuffer += generateNextLine(state, level); - } - - if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { - continue; // Skip this pair because of invalid value. - } - - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += ':'; - } else { - pairBuffer += ': '; - } - - pairBuffer += state.dump; - - // Both key and value are valid. - _result += pairBuffer; - } - - state.tag = _tag; - state.dump = _result || '{}'; // Empty mapping if no valid pairs. -} - -function detectType(state, object, explicit) { - var _result, typeList, index, length, type, style; - - typeList = explicit ? state.explicitTypes : state.implicitTypes; - - for (index = 0, length = typeList.length; index < length; index += 1) { - type = typeList[index]; - - if ((type.instanceOf || type.predicate) && - (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && - (!type.predicate || type.predicate(object))) { - - if (explicit) { - if (type.multi && type.representName) { - state.tag = type.representName(object); - } else { - state.tag = type.tag; - } - } else { - state.tag = '?'; - } - - if (type.represent) { - style = state.styleMap[type.tag] || type.defaultStyle; - - if (_toString.call(type.represent) === '[object Function]') { - _result = type.represent(object, style); - } else if (_hasOwnProperty.call(type.represent, style)) { - _result = type.represent[style](object, style); - } else { - throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); - } - - state.dump = _result; - } - - return true; - } - } - - return false; -} - -// Serializes `object` and writes it to global `result`. -// Returns true on success, or false on invalid object. -// -function writeNode(state, level, object, block, compact, iskey, isblockseq) { - state.tag = null; - state.dump = object; - - if (!detectType(state, object, false)) { - detectType(state, object, true); - } - - var type = _toString.call(state.dump); - var inblock = block; - var tagStr; - - if (block) { - block = (state.flowLevel < 0 || state.flowLevel > level); - } - - var objectOrArray = type === '[object Object]' || type === '[object Array]', - duplicateIndex, - duplicate; - - if (objectOrArray) { - duplicateIndex = state.duplicates.indexOf(object); - duplicate = duplicateIndex !== -1; - } - - if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { - compact = false; - } - - if (duplicate && state.usedDuplicates[duplicateIndex]) { - state.dump = '*ref_' + duplicateIndex; - } else { - if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { - state.usedDuplicates[duplicateIndex] = true; - } - if (type === '[object Object]') { - if (block && (Object.keys(state.dump).length !== 0)) { - writeBlockMapping(state, level, state.dump, compact); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; - } - } else { - writeFlowMapping(state, level, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; - } - } - } else if (type === '[object Array]') { - if (block && (state.dump.length !== 0)) { - if (state.noArrayIndent && !isblockseq && level > 0) { - writeBlockSequence(state, level - 1, state.dump, compact); - } else { - writeBlockSequence(state, level, state.dump, compact); - } - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; - } - } else { - writeFlowSequence(state, level, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; - } - } - } else if (type === '[object String]') { - if (state.tag !== '?') { - writeScalar(state, state.dump, level, iskey, inblock); - } - } else if (type === '[object Undefined]') { - return false; - } else { - if (state.skipInvalid) return false; - throw new exception('unacceptable kind of an object to dump ' + type); - } - - if (state.tag !== null && state.tag !== '?') { - // Need to encode all characters except those allowed by the spec: - // - // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ - // [36] ns-hex-digit ::= ns-dec-digit - // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ - // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ - // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” - // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” - // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” - // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” - // - // Also need to encode '!' because it has special meaning (end of tag prefix). - // - tagStr = encodeURI( - state.tag[0] === '!' ? state.tag.slice(1) : state.tag - ).replace(/!/g, '%21'); - - if (state.tag[0] === '!') { - tagStr = '!' + tagStr; - } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { - tagStr = '!!' + tagStr.slice(18); - } else { - tagStr = '!<' + tagStr + '>'; - } - - state.dump = tagStr + ' ' + state.dump; - } - } - - return true; -} - -function getDuplicateReferences(object, state) { - var objects = [], - duplicatesIndexes = [], - index, - length; - - inspectNode(object, objects, duplicatesIndexes); - - for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { - state.duplicates.push(objects[duplicatesIndexes[index]]); - } - state.usedDuplicates = new Array(length); -} - -function inspectNode(object, objects, duplicatesIndexes) { - var objectKeyList, - index, - length; - - if (object !== null && typeof object === 'object') { - index = objects.indexOf(object); - if (index !== -1) { - if (duplicatesIndexes.indexOf(index) === -1) { - duplicatesIndexes.push(index); - } - } else { - objects.push(object); - - if (Array.isArray(object)) { - for (index = 0, length = object.length; index < length; index += 1) { - inspectNode(object[index], objects, duplicatesIndexes); - } - } else { - objectKeyList = Object.keys(object); - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); - } - } - } - } -} - -function dump$1(input, options) { - options = options || {}; - - var state = new State(options); - - if (!state.noRefs) getDuplicateReferences(input, state); - - var value = input; - - if (state.replacer) { - value = state.replacer.call({ '': value }, '', value); - } - - if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; - - return ''; -} - -var dump_1 = dump$1; - -var dumper = { - dump: dump_1 -}; - -function renamed(from, to) { - return function () { - throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + - 'Use yaml.' + to + ' instead, which is now safe by default.'); - }; -} - - -var Type = type; -var Schema = schema; -var FAILSAFE_SCHEMA = failsafe; -var JSON_SCHEMA = json; -var CORE_SCHEMA = core; -var DEFAULT_SCHEMA = _default; -var load = loader.load; -var loadAll = loader.loadAll; -var dump = dumper.dump; -var YAMLException = exception; - -// Re-export all types in case user wants to create custom schema -var types = { - binary: binary, - float: float, - map: map, - null: _null, - pairs: pairs, - set: set, - timestamp: timestamp, - bool: bool, - int: int, - merge: merge, - omap: omap, - seq: seq, - str: str -}; - -// Removed functions from JS-YAML 3.0.x -var safeLoad = renamed('safeLoad', 'load'); -var safeLoadAll = renamed('safeLoadAll', 'loadAll'); -var safeDump = renamed('safeDump', 'dump'); - -var jsYaml = { - Type: Type, - Schema: Schema, - FAILSAFE_SCHEMA: FAILSAFE_SCHEMA, - JSON_SCHEMA: JSON_SCHEMA, - CORE_SCHEMA: CORE_SCHEMA, - DEFAULT_SCHEMA: DEFAULT_SCHEMA, - load: load, - loadAll: loadAll, - dump: dump, - YAMLException: YAMLException, - types: types, - safeLoad: safeLoad, - safeLoadAll: safeLoadAll, - safeDump: safeDump -}; - -export { CORE_SCHEMA, DEFAULT_SCHEMA, FAILSAFE_SCHEMA, JSON_SCHEMA, Schema, Type, YAMLException, jsYaml as default, dump, load, loadAll, safeDump, safeLoad, safeLoadAll, types }; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..0af9359d --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,21 @@ +import neostandard from 'neostandard' + +export default [ + ...neostandard({ + env: ['browser', 'node'], + ignores: [ + 'coverage/**', + 'demo/**', + 'dist/**' + ] + }), + + { + rules: { + camelcase: 'off', + '@stylistic/key-spacing': 'off', + 'no-useless-escape': 'off', + 'object-shorthand': 'off', + } + } +] diff --git a/examples/custom_types.js b/examples/custom_types.js index c4fa7471..7fc27538 100644 --- a/examples/custom_types.js +++ b/examples/custom_types.js @@ -1,40 +1,35 @@ -'use strict'; - -/*eslint-disable no-console*/ - -var fs = require('fs'); -var path = require('path'); -var util = require('util'); -var yaml = require('../'); +'use strict' +const fs = require('fs') +const path = require('path') +const util = require('util') +const yaml = require('../') // Let's define a couple of classes. -function Point(x, y, z) { - this.klass = 'Point'; - this.x = x; - this.y = y; - this.z = z; +function Point (x, y, z) { + this.klass = 'Point' + this.x = x + this.y = y + this.z = z } - -function Space(height, width, points) { +function Space (height, width, points) { if (points) { - if (!points.every(function (point) { return point instanceof Point; })) { - throw new Error('A non-Point inside a points array!'); + if (!points.every(function (point) { return point instanceof Point })) { + throw new Error('A non-Point inside a points array!') } } - this.klass = 'Space'; - this.height = height; - this.width = width; - this.points = points; + this.klass = 'Space' + this.height = height + this.width = width + this.points = points } - // Then define YAML types to load and dump our Point/Space objects. -var PointYamlType = new yaml.Type('!point', { +const PointYamlType = new yaml.Type('!point', { // Loader must parse sequence nodes only for this type (i.e. arrays in JS terminology). // Other available kinds are 'scalar' (string) and 'mapping' (object). // http://www.yaml.org/spec/1.2/spec.html#kind// @@ -45,12 +40,12 @@ var PointYamlType = new yaml.Type('!point', { // `data` may be either: // - Null in case of an "empty node" (http://www.yaml.org/spec/1.2/spec.html#id2786563) // - Array since we specified `kind` to 'sequence' - return data !== null && data.length === 3; + return data !== null && data.length === 3 }, // If a node is resolved, use it to create a Point instance. construct: function (data) { - return new Point(data[0], data[1], data[2]); + return new Point(data[0], data[1], data[2]) }, // Dumper must process instances of Point by rules of this YAML type. @@ -58,46 +53,43 @@ var PointYamlType = new yaml.Type('!point', { // Dumper must represent Point objects as three-element sequence in YAML. represent: function (point) { - return [ point.x, point.y, point.z ]; + return [point.x, point.y, point.z] } -}); +}) - -var SpaceYamlType = new yaml.Type('!space', { +const SpaceYamlType = new yaml.Type('!space', { kind: 'mapping', construct: function (data) { - data = data || {}; // in case of empty node - return new Space(data.height || 0, data.width || 0, data.points || []); + data = data || {} // in case of empty node + return new Space(data.height || 0, data.width || 0, data.points || []) }, instanceOf: Space // `represent` is omitted here. So, Space objects will be dumped as is. // That is regular mapping with three key-value pairs but with !space tag. -}); - +}) // After our types are defined, it's time to join them into a schema. -var SPACE_SCHEMA = yaml.DEFAULT_SCHEMA.extend([ SpaceYamlType, PointYamlType ]); +const SPACE_SCHEMA = yaml.DEFAULT_SCHEMA.extend([SpaceYamlType, PointYamlType]) // do not execute the following if file is required (http://stackoverflow.com/a/6398335) if (require.main === module) { - // And read a document using that schema. fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) { - var loaded; + let loaded if (!error) { - loaded = yaml.load(data, { schema: SPACE_SCHEMA }); - console.log(util.inspect(loaded, false, 20, true)); + loaded = yaml.load(data, { schema: SPACE_SCHEMA }) + console.log(util.inspect(loaded, false, 20, true)) } else { - console.error(error.stack || error.message || String(error)); + console.error(error.stack || error.message || String(error)) } - }); + }) } // There are some exports to play with this example interactively. -module.exports.Point = Point; -module.exports.Space = Space; -module.exports.PointYamlType = PointYamlType; -module.exports.SpaceYamlType = SpaceYamlType; -module.exports.SPACE_SCHEMA = SPACE_SCHEMA; +module.exports.Point = Point +module.exports.Space = Space +module.exports.PointYamlType = PointYamlType +module.exports.SpaceYamlType = SpaceYamlType +module.exports.SPACE_SCHEMA = SPACE_SCHEMA diff --git a/examples/dumper.js b/examples/dumper.js index bb42c60c..d3fa3af6 100644 --- a/examples/dumper.js +++ b/examples/dumper.js @@ -1,10 +1,7 @@ -'use strict'; - -/*eslint-disable no-console*/ - -var yaml = require('../'); -var object = require('./dumper.json'); +'use strict' +const yaml = require('../') +const object = require('./dumper.json') console.log(yaml.dump(object, { flowLevel: 3, @@ -12,11 +9,10 @@ console.log(yaml.dump(object, { '!!int' : 'hexadecimal', '!!null' : 'camelcase' } -})); - +})) // Output: -//============================================================================== +//= ============================================================================= // name: Wizzard // level: 0x11 // sanity: Null diff --git a/examples/handle_unknown_types.js b/examples/handle_unknown_types.js index 6faf7415..efc18206 100644 --- a/examples/handle_unknown_types.js +++ b/examples/handle_unknown_types.js @@ -1,54 +1,50 @@ -'use strict'; - -/*eslint-disable no-console*/ - -const util = require('util'); -const yaml = require('../'); +'use strict' +const util = require('util') +const yaml = require('../') class CustomTag { - constructor(type, data) { - this.type = type; - this.data = data; + constructor (type, data) { + this.type = type + this.data = data } } - -const tags = [ 'scalar', 'sequence', 'mapping' ].map(function (kind) { +const tags = ['scalar', 'sequence', 'mapping'].map(function (kind) { // first argument here is a prefix, so this type will handle anything starting with ! return new yaml.Type('!', { kind: kind, multi: true, representName: function (object) { - return object.type; + return object.type }, represent: function (object) { - return object.data; + return object.data }, instanceOf: CustomTag, construct: function (data, type) { - return new CustomTag(type, data); + return new CustomTag(type, data) } - }); -}); + }) +}) -const SCHEMA = yaml.DEFAULT_SCHEMA.extend(tags); +const SCHEMA = yaml.DEFAULT_SCHEMA.extend(tags) const data = ` subject: Handling unknown types in JS-YAML scalar: !unknown_scalar_tag foo bar sequence: !unknown_sequence_tag [ 1, 2, 3 ] mapping: !unknown_mapping_tag { foo: 1, bar: 2 } -`; +` -const loaded = yaml.load(data, { schema: SCHEMA }); +const loaded = yaml.load(data, { schema: SCHEMA }) -console.log('Parsed as:'); -console.log('-'.repeat(70)); -console.log(util.inspect(loaded, false, 20, true)); +console.log('Parsed as:') +console.log('-'.repeat(70)) +console.log(util.inspect(loaded, false, 20, true)) -console.log(''); -console.log(''); -console.log('Dumped as:'); -console.log('-'.repeat(70)); -console.log(yaml.dump(loaded, { schema: SCHEMA })); +console.log('') +console.log('') +console.log('Dumped as:') +console.log('-'.repeat(70)) +console.log(yaml.dump(loaded, { schema: SCHEMA })) diff --git a/examples/int_type_override.js b/examples/int_type_override.js index b495fe49..caf06c9f 100644 --- a/examples/int_type_override.js +++ b/examples/int_type_override.js @@ -1,59 +1,56 @@ // This example overrides built-in !!int type to return BigInt instead of a Number // -'use strict'; - -/*global BigInt*/ -/*eslint-disable no-console*/ - -const util = require('util'); -const yaml = require('../'); +'use strict' +/* global BigInt */ +const util = require('util') +const yaml = require('../') // keep most of the original `int` options as is -let options = Object.assign({}, yaml.types.int.options); +const options = Object.assign({}, yaml.types.int.options) options.construct = data => { - let value = data, sign = 1n, ch; + let value = data + let sign = 1n + let ch if (value.indexOf('_') !== -1) { - value = value.replace(/_/g, ''); + value = value.replace(/_/g, '') } - ch = value[0]; + ch = value[0] if (ch === '-' || ch === '+') { - if (ch === '-') sign = -1n; - value = value.slice(1); - ch = value[0]; + if (ch === '-') sign = -1n + value = value.slice(1) + ch = value[0] } - return sign * BigInt(value); -}; - + return sign * BigInt(value) +} options.predicate = object => { return Object.prototype.toString.call(object) === '[object BigInt]' || - yaml.types.int.options.predicate(object); -}; - + yaml.types.int.options.predicate(object) +} -let BigIntType = new yaml.Type('tag:yaml.org,2002:int', options); +const BigIntType = new yaml.Type('tag:yaml.org,2002:int', options) -const SCHEMA = yaml.DEFAULT_SCHEMA.extend({ implicit: [ BigIntType ] }); +const SCHEMA = yaml.DEFAULT_SCHEMA.extend({ implicit: [BigIntType] }) const data = ` bigint: -12_345_678_901_234_567_890 -`; +` -const loaded = yaml.load(data, { schema: SCHEMA }); +const loaded = yaml.load(data, { schema: SCHEMA }) -console.log('Parsed as:'); -console.log('-'.repeat(70)); -console.log(util.inspect(loaded, false, 20, true)); +console.log('Parsed as:') +console.log('-'.repeat(70)) +console.log(util.inspect(loaded, false, 20, true)) -console.log(''); -console.log(''); -console.log('Dumped as:'); -console.log('-'.repeat(70)); -console.log(yaml.dump(loaded, { schema: SCHEMA })); +console.log('') +console.log('') +console.log('Dumped as:') +console.log('-'.repeat(70)) +console.log(yaml.dump(loaded, { schema: SCHEMA })) diff --git a/examples/sample_document.js b/examples/sample_document.js index 1c707fd9..23b93f3b 100644 --- a/examples/sample_document.js +++ b/examples/sample_document.js @@ -1,19 +1,16 @@ -'use strict'; - -/*eslint-disable no-console*/ - -var fs = require('fs'); -var path = require('path'); -var util = require('util'); -var yaml = require('../'); +'use strict' +const fs = require('fs') +const path = require('path') +const util = require('util') +const yaml = require('../') try { - var filename = path.join(__dirname, 'sample_document.yml'), - contents = fs.readFileSync(filename, 'utf8'), - data = yaml.load(contents); + const filename = path.join(__dirname, 'sample_document.yml') + const contents = fs.readFileSync(filename, 'utf8') + const data = yaml.load(contents) - console.log(util.inspect(data, false, 10, true)); + console.log(util.inspect(data, false, 10, true)) } catch (err) { - console.log(err.stack || String(err)); + console.log(err.stack || String(err)) } diff --git a/index.js b/index.js index bcb7eba7..3d5d4142 100644 --- a/index.js +++ b/index.js @@ -1,28 +1,25 @@ -'use strict'; +'use strict' +const loader = require('./lib/loader') +const dumper = require('./lib/dumper') -var loader = require('./lib/loader'); -var dumper = require('./lib/dumper'); - - -function renamed(from, to) { +function renamed (from, to) { return function () { throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + - 'Use yaml.' + to + ' instead, which is now safe by default.'); - }; + 'Use yaml.' + to + ' instead, which is now safe by default.') + } } - -module.exports.Type = require('./lib/type'); -module.exports.Schema = require('./lib/schema'); -module.exports.FAILSAFE_SCHEMA = require('./lib/schema/failsafe'); -module.exports.JSON_SCHEMA = require('./lib/schema/json'); -module.exports.CORE_SCHEMA = require('./lib/schema/core'); -module.exports.DEFAULT_SCHEMA = require('./lib/schema/default'); -module.exports.load = loader.load; -module.exports.loadAll = loader.loadAll; -module.exports.dump = dumper.dump; -module.exports.YAMLException = require('./lib/exception'); +module.exports.Type = require('./lib/type') +module.exports.Schema = require('./lib/schema') +module.exports.FAILSAFE_SCHEMA = require('./lib/schema/failsafe') +module.exports.JSON_SCHEMA = require('./lib/schema/json') +module.exports.CORE_SCHEMA = require('./lib/schema/core') +module.exports.DEFAULT_SCHEMA = require('./lib/schema/default') +module.exports.load = loader.load +module.exports.loadAll = loader.loadAll +module.exports.dump = dumper.dump +module.exports.YAMLException = require('./lib/exception') // Re-export all types in case user wants to create custom schema module.exports.types = { @@ -39,9 +36,9 @@ module.exports.types = { omap: require('./lib/type/omap'), seq: require('./lib/type/seq'), str: require('./lib/type/str') -}; +} // Removed functions from JS-YAML 3.0.x -module.exports.safeLoad = renamed('safeLoad', 'load'); -module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll'); -module.exports.safeDump = renamed('safeDump', 'dump'); +module.exports.safeLoad = renamed('safeLoad', 'load') +module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll') +module.exports.safeDump = renamed('safeDump', 'dump') diff --git a/lib/common.js b/lib/common.js index 25ef7d8e..d1fd4dc2 100644 --- a/lib/common.js +++ b/lib/common.js @@ -1,59 +1,50 @@ -'use strict'; +'use strict' - -function isNothing(subject) { - return (typeof subject === 'undefined') || (subject === null); +function isNothing (subject) { + return (typeof subject === 'undefined') || (subject === null) } - -function isObject(subject) { - return (typeof subject === 'object') && (subject !== null); +function isObject (subject) { + return (typeof subject === 'object') && (subject !== null) } +function toArray (sequence) { + if (Array.isArray(sequence)) return sequence + else if (isNothing(sequence)) return [] -function toArray(sequence) { - if (Array.isArray(sequence)) return sequence; - else if (isNothing(sequence)) return []; - - return [ sequence ]; + return [sequence] } - -function extend(target, source) { - var index, length, key, sourceKeys; - +function extend (target, source) { if (source) { - sourceKeys = Object.keys(source); + const sourceKeys = Object.keys(source) - for (index = 0, length = sourceKeys.length; index < length; index += 1) { - key = sourceKeys[index]; - target[key] = source[key]; + for (let index = 0, length = sourceKeys.length; index < length; index += 1) { + const key = sourceKeys[index] + target[key] = source[key] } } - return target; + return target } +function repeat (string, count) { + let result = '' -function repeat(string, count) { - var result = '', cycle; - - for (cycle = 0; cycle < count; cycle += 1) { - result += string; + for (let cycle = 0; cycle < count; cycle += 1) { + result += string } - return result; + return result } - -function isNegativeZero(number) { - return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); +function isNegativeZero (number) { + return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number) } - -module.exports.isNothing = isNothing; -module.exports.isObject = isObject; -module.exports.toArray = toArray; -module.exports.repeat = repeat; -module.exports.isNegativeZero = isNegativeZero; -module.exports.extend = extend; +module.exports.isNothing = isNothing +module.exports.isObject = isObject +module.exports.toArray = toArray +module.exports.repeat = repeat +module.exports.isNegativeZero = isNegativeZero +module.exports.extend = extend diff --git a/lib/dumper.js b/lib/dumper.js index f357a6ae..a5b6acd6 100644 --- a/lib/dumper.js +++ b/lib/dumper.js @@ -1,202 +1,195 @@ -'use strict'; - -/*eslint-disable no-use-before-define*/ - -var common = require('./common'); -var YAMLException = require('./exception'); -var DEFAULT_SCHEMA = require('./schema/default'); - -var _toString = Object.prototype.toString; -var _hasOwnProperty = Object.prototype.hasOwnProperty; - -var CHAR_BOM = 0xFEFF; -var CHAR_TAB = 0x09; /* Tab */ -var CHAR_LINE_FEED = 0x0A; /* LF */ -var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ -var CHAR_SPACE = 0x20; /* Space */ -var CHAR_EXCLAMATION = 0x21; /* ! */ -var CHAR_DOUBLE_QUOTE = 0x22; /* " */ -var CHAR_SHARP = 0x23; /* # */ -var CHAR_PERCENT = 0x25; /* % */ -var CHAR_AMPERSAND = 0x26; /* & */ -var CHAR_SINGLE_QUOTE = 0x27; /* ' */ -var CHAR_ASTERISK = 0x2A; /* * */ -var CHAR_COMMA = 0x2C; /* , */ -var CHAR_MINUS = 0x2D; /* - */ -var CHAR_COLON = 0x3A; /* : */ -var CHAR_EQUALS = 0x3D; /* = */ -var CHAR_GREATER_THAN = 0x3E; /* > */ -var CHAR_QUESTION = 0x3F; /* ? */ -var CHAR_COMMERCIAL_AT = 0x40; /* @ */ -var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ -var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ -var CHAR_GRAVE_ACCENT = 0x60; /* ` */ -var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ -var CHAR_VERTICAL_LINE = 0x7C; /* | */ -var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ - -var ESCAPE_SEQUENCES = {}; - -ESCAPE_SEQUENCES[0x00] = '\\0'; -ESCAPE_SEQUENCES[0x07] = '\\a'; -ESCAPE_SEQUENCES[0x08] = '\\b'; -ESCAPE_SEQUENCES[0x09] = '\\t'; -ESCAPE_SEQUENCES[0x0A] = '\\n'; -ESCAPE_SEQUENCES[0x0B] = '\\v'; -ESCAPE_SEQUENCES[0x0C] = '\\f'; -ESCAPE_SEQUENCES[0x0D] = '\\r'; -ESCAPE_SEQUENCES[0x1B] = '\\e'; -ESCAPE_SEQUENCES[0x22] = '\\"'; -ESCAPE_SEQUENCES[0x5C] = '\\\\'; -ESCAPE_SEQUENCES[0x85] = '\\N'; -ESCAPE_SEQUENCES[0xA0] = '\\_'; -ESCAPE_SEQUENCES[0x2028] = '\\L'; -ESCAPE_SEQUENCES[0x2029] = '\\P'; - -var DEPRECATED_BOOLEANS_SYNTAX = [ +'use strict' + +const common = require('./common') +const YAMLException = require('./exception') +const DEFAULT_SCHEMA = require('./schema/default') + +const _toString = Object.prototype.toString +const _hasOwnProperty = Object.prototype.hasOwnProperty + +const CHAR_BOM = 0xFEFF +const CHAR_TAB = 0x09 /* Tab */ +const CHAR_LINE_FEED = 0x0A /* LF */ +const CHAR_CARRIAGE_RETURN = 0x0D /* CR */ +const CHAR_SPACE = 0x20 /* Space */ +const CHAR_EXCLAMATION = 0x21 /* ! */ +const CHAR_DOUBLE_QUOTE = 0x22 /* " */ +const CHAR_SHARP = 0x23 /* # */ +const CHAR_PERCENT = 0x25 /* % */ +const CHAR_AMPERSAND = 0x26 /* & */ +const CHAR_SINGLE_QUOTE = 0x27 /* ' */ +const CHAR_ASTERISK = 0x2A /* * */ +const CHAR_COMMA = 0x2C /* , */ +const CHAR_MINUS = 0x2D /* - */ +const CHAR_COLON = 0x3A /* : */ +const CHAR_EQUALS = 0x3D /* = */ +const CHAR_GREATER_THAN = 0x3E /* > */ +const CHAR_QUESTION = 0x3F /* ? */ +const CHAR_COMMERCIAL_AT = 0x40 /* @ */ +const CHAR_LEFT_SQUARE_BRACKET = 0x5B /* [ */ +const CHAR_RIGHT_SQUARE_BRACKET = 0x5D /* ] */ +const CHAR_GRAVE_ACCENT = 0x60 /* ` */ +const CHAR_LEFT_CURLY_BRACKET = 0x7B /* { */ +const CHAR_VERTICAL_LINE = 0x7C /* | */ +const CHAR_RIGHT_CURLY_BRACKET = 0x7D /* } */ + +const ESCAPE_SEQUENCES = {} + +ESCAPE_SEQUENCES[0x00] = '\\0' +ESCAPE_SEQUENCES[0x07] = '\\a' +ESCAPE_SEQUENCES[0x08] = '\\b' +ESCAPE_SEQUENCES[0x09] = '\\t' +ESCAPE_SEQUENCES[0x0A] = '\\n' +ESCAPE_SEQUENCES[0x0B] = '\\v' +ESCAPE_SEQUENCES[0x0C] = '\\f' +ESCAPE_SEQUENCES[0x0D] = '\\r' +ESCAPE_SEQUENCES[0x1B] = '\\e' +ESCAPE_SEQUENCES[0x22] = '\\"' +ESCAPE_SEQUENCES[0x5C] = '\\\\' +ESCAPE_SEQUENCES[0x85] = '\\N' +ESCAPE_SEQUENCES[0xA0] = '\\_' +ESCAPE_SEQUENCES[0x2028] = '\\L' +ESCAPE_SEQUENCES[0x2029] = '\\P' + +const DEPRECATED_BOOLEANS_SYNTAX = [ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' -]; +] -var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; +const DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/ -function compileStyleMap(schema, map) { - var result, keys, index, length, tag, style, type; +function compileStyleMap (schema, map) { + if (map === null) return {} - if (map === null) return {}; + const result = {} + const keys = Object.keys(map) - result = {}; - keys = Object.keys(map); - - for (index = 0, length = keys.length; index < length; index += 1) { - tag = keys[index]; - style = String(map[tag]); + for (let index = 0, length = keys.length; index < length; index += 1) { + let tag = keys[index] + let style = String(map[tag]) if (tag.slice(0, 2) === '!!') { - tag = 'tag:yaml.org,2002:' + tag.slice(2); + tag = 'tag:yaml.org,2002:' + tag.slice(2) } - type = schema.compiledTypeMap['fallback'][tag]; + const type = schema.compiledTypeMap['fallback'][tag] if (type && _hasOwnProperty.call(type.styleAliases, style)) { - style = type.styleAliases[style]; + style = type.styleAliases[style] } - result[tag] = style; + result[tag] = style } - return result; + return result } -function encodeHex(character) { - var string, handle, length; +function encodeHex (character) { + let handle + let length - string = character.toString(16).toUpperCase(); + const string = character.toString(16).toUpperCase() if (character <= 0xFF) { - handle = 'x'; - length = 2; + handle = 'x' + length = 2 } else if (character <= 0xFFFF) { - handle = 'u'; - length = 4; + handle = 'u' + length = 4 } else if (character <= 0xFFFFFFFF) { - handle = 'U'; - length = 8; + handle = 'U' + length = 8 } else { - throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); + throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF') } - return '\\' + handle + common.repeat('0', length - string.length) + string; + return '\\' + handle + common.repeat('0', length - string.length) + string } - -var QUOTING_TYPE_SINGLE = 1, - QUOTING_TYPE_DOUBLE = 2; - -function State(options) { - this.schema = options['schema'] || DEFAULT_SCHEMA; - this.indent = Math.max(1, (options['indent'] || 2)); - this.noArrayIndent = options['noArrayIndent'] || false; - this.skipInvalid = options['skipInvalid'] || false; - this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); - this.styleMap = compileStyleMap(this.schema, options['styles'] || null); - this.sortKeys = options['sortKeys'] || false; - this.lineWidth = options['lineWidth'] || 80; - this.noRefs = options['noRefs'] || false; - this.noCompatMode = options['noCompatMode'] || false; - this.condenseFlow = options['condenseFlow'] || false; - this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; - this.forceQuotes = options['forceQuotes'] || false; - this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; - - this.implicitTypes = this.schema.compiledImplicit; - this.explicitTypes = this.schema.compiledExplicit; - - this.tag = null; - this.result = ''; - - this.duplicates = []; - this.usedDuplicates = null; +const QUOTING_TYPE_SINGLE = 1 +const QUOTING_TYPE_DOUBLE = 2 + +function State (options) { + this.schema = options['schema'] || DEFAULT_SCHEMA + this.indent = Math.max(1, (options['indent'] || 2)) + this.noArrayIndent = options['noArrayIndent'] || false + this.skipInvalid = options['skipInvalid'] || false + this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']) + this.styleMap = compileStyleMap(this.schema, options['styles'] || null) + this.sortKeys = options['sortKeys'] || false + this.lineWidth = options['lineWidth'] || 80 + this.noRefs = options['noRefs'] || false + this.noCompatMode = options['noCompatMode'] || false + this.condenseFlow = options['condenseFlow'] || false + this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE + this.forceQuotes = options['forceQuotes'] || false + this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null + + this.implicitTypes = this.schema.compiledImplicit + this.explicitTypes = this.schema.compiledExplicit + + this.tag = null + this.result = '' + + this.duplicates = [] + this.usedDuplicates = null } // Indents every line in a string. Empty lines (\n only) are not indented. -function indentString(string, spaces) { - var ind = common.repeat(' ', spaces), - position = 0, - next = -1, - result = '', - line, - length = string.length; +function indentString (string, spaces) { + const ind = common.repeat(' ', spaces) + let position = 0 + let result = '' + const length = string.length while (position < length) { - next = string.indexOf('\n', position); + let line + const next = string.indexOf('\n', position) if (next === -1) { - line = string.slice(position); - position = length; + line = string.slice(position) + position = length } else { - line = string.slice(position, next + 1); - position = next + 1; + line = string.slice(position, next + 1) + position = next + 1 } - if (line.length && line !== '\n') result += ind; + if (line.length && line !== '\n') result += ind - result += line; + result += line } - return result; + return result } -function generateNextLine(state, level) { - return '\n' + common.repeat(' ', state.indent * level); +function generateNextLine (state, level) { + return '\n' + common.repeat(' ', state.indent * level) } -function testImplicitResolving(state, str) { - var index, length, type; - - for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { - type = state.implicitTypes[index]; +function testImplicitResolving (state, str) { + for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) { + const type = state.implicitTypes[index] if (type.resolve(str)) { - return true; + return true } } - return false; + return false } // [33] s-white ::= s-space | s-tab -function isWhitespace(c) { - return c === CHAR_SPACE || c === CHAR_TAB; +function isWhitespace (c) { + return c === CHAR_SPACE || c === CHAR_TAB } // Returns true if the character can be printed without escaping. // From YAML 1.2: "any allowed characters known to be non-printable // should also be escaped. [However,] This isn’t mandatory" // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. -function isPrintable(c) { - return (0x00020 <= c && c <= 0x00007E) - || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) - || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) - || (0x10000 <= c && c <= 0x10FFFF); +function isPrintable (c) { + return (c >= 0x00020 && c <= 0x00007E) || + ((c >= 0x000A1 && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) || + ((c >= 0x0E000 && c <= 0x00FFFD) && c !== CHAR_BOM) || + (c >= 0x10000 && c <= 0x10FFFF) } // [34] ns-char ::= nb-char - s-white @@ -204,12 +197,12 @@ function isPrintable(c) { // [26] b-char ::= b-line-feed | b-carriage-return // Including s-white (for some reason, examples doesn't match specs in this aspect) // ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark -function isNsCharOrWhitespace(c) { - return isPrintable(c) - && c !== CHAR_BOM +function isNsCharOrWhitespace (c) { + return isPrintable(c) && + c !== CHAR_BOM && // - b-char - && c !== CHAR_CARRIAGE_RETURN - && c !== CHAR_LINE_FEED; + c !== CHAR_CARRIAGE_RETURN && + c !== CHAR_LINE_FEED } // [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out @@ -221,91 +214,96 @@ function isNsCharOrWhitespace(c) { // [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) // | ( /* An ns-char preceding */ “#” ) // | ( “:” /* Followed by an ns-plain-safe(c) */ ) -function isPlainSafe(c, prev, inblock) { - var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); - var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); +function isPlainSafe (c, prev, inblock) { + const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c) + const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c) return ( - // ns-plain-safe - inblock ? // c = flow-in - cIsNsCharOrWhitespace - : cIsNsCharOrWhitespace - // - c-flow-indicator - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET - ) + ( + // ns-plain-safe + inblock // c = flow-in + ? cIsNsCharOrWhitespace + : cIsNsCharOrWhitespace && + // - c-flow-indicator + c !== CHAR_COMMA && + c !== CHAR_LEFT_SQUARE_BRACKET && + c !== CHAR_RIGHT_SQUARE_BRACKET && + c !== CHAR_LEFT_CURLY_BRACKET && + c !== CHAR_RIGHT_CURLY_BRACKET + ) && // ns-plain-char - && c !== CHAR_SHARP // false on '#' - && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' - || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' - || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' + c !== CHAR_SHARP && // false on '#' + !(prev === CHAR_COLON && !cIsNsChar) + ) || // false on ': ' + (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) || // change to true on '[^ ]#' + (prev === CHAR_COLON && cIsNsChar) // change to true on ':[^ ]' } // Simplified test for values allowed as the first character in plain style. -function isPlainSafeFirst(c) { +function isPlainSafeFirst (c) { // Uses a subset of ns-char - c-indicator // where ns-char = nb-char - s-white. // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part - return isPrintable(c) && c !== CHAR_BOM - && !isWhitespace(c) // - s-white + return isPrintable(c) && + c !== CHAR_BOM && + !isWhitespace(c) && // - s-white // - (c-indicator ::= // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” - && c !== CHAR_MINUS - && c !== CHAR_QUESTION - && c !== CHAR_COLON - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET + c !== CHAR_MINUS && + c !== CHAR_QUESTION && + c !== CHAR_COLON && + c !== CHAR_COMMA && + c !== CHAR_LEFT_SQUARE_BRACKET && + c !== CHAR_RIGHT_SQUARE_BRACKET && + c !== CHAR_LEFT_CURLY_BRACKET && + c !== CHAR_RIGHT_CURLY_BRACKET && // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” - && c !== CHAR_SHARP - && c !== CHAR_AMPERSAND - && c !== CHAR_ASTERISK - && c !== CHAR_EXCLAMATION - && c !== CHAR_VERTICAL_LINE - && c !== CHAR_EQUALS - && c !== CHAR_GREATER_THAN - && c !== CHAR_SINGLE_QUOTE - && c !== CHAR_DOUBLE_QUOTE + c !== CHAR_SHARP && + c !== CHAR_AMPERSAND && + c !== CHAR_ASTERISK && + c !== CHAR_EXCLAMATION && + c !== CHAR_VERTICAL_LINE && + c !== CHAR_EQUALS && + c !== CHAR_GREATER_THAN && + c !== CHAR_SINGLE_QUOTE && + c !== CHAR_DOUBLE_QUOTE && // | “%” | “@” | “`”) - && c !== CHAR_PERCENT - && c !== CHAR_COMMERCIAL_AT - && c !== CHAR_GRAVE_ACCENT; + c !== CHAR_PERCENT && + c !== CHAR_COMMERCIAL_AT && + c !== CHAR_GRAVE_ACCENT } // Simplified test for values allowed as the last character in plain style. -function isPlainSafeLast(c) { +function isPlainSafeLast (c) { // just not whitespace or colon, it will be checked to be plain character later - return !isWhitespace(c) && c !== CHAR_COLON; + return !isWhitespace(c) && c !== CHAR_COLON } // Same as 'string'.codePointAt(pos), but works in older browsers. -function codePointAt(string, pos) { - var first = string.charCodeAt(pos), second; +function codePointAt (string, pos) { + const first = string.charCodeAt(pos) + let second + if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { - second = string.charCodeAt(pos + 1); + second = string.charCodeAt(pos + 1) if (second >= 0xDC00 && second <= 0xDFFF) { // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000 } } - return first; + return first } // Determines whether block indentation indicator is required. -function needIndentIndicator(string) { - var leadingSpaceRe = /^\n* /; - return leadingSpaceRe.test(string); +function needIndentIndicator (string) { + const leadingSpaceRe = /^\n* / + return leadingSpaceRe.test(string) } -var STYLE_PLAIN = 1, - STYLE_SINGLE = 2, - STYLE_LITERAL = 3, - STYLE_FOLDED = 4, - STYLE_DOUBLE = 5; +const STYLE_PLAIN = 1 +const STYLE_SINGLE = 2 +const STYLE_LITERAL = 3 +const STYLE_FOLDED = 4 +const STYLE_DOUBLE = 5 // Determines which scalar styles are possible and returns the preferred style. // lineWidth = -1 => no limit. @@ -314,54 +312,53 @@ var STYLE_PLAIN = 1, // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). -function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, +function chooseScalarStyle (string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) { - - var i; - var char = 0; - var prevChar = null; - var hasLineBreak = false; - var hasFoldableLine = false; // only checked if shouldTrackWidth - var shouldTrackWidth = lineWidth !== -1; - var previousLineBreak = -1; // count the first line correctly - var plain = isPlainSafeFirst(codePointAt(string, 0)) - && isPlainSafeLast(codePointAt(string, string.length - 1)); + let i + let char = 0 + let prevChar = null + let hasLineBreak = false + let hasFoldableLine = false // only checked if shouldTrackWidth + const shouldTrackWidth = lineWidth !== -1 + let previousLineBreak = -1 // count the first line correctly + let plain = isPlainSafeFirst(codePointAt(string, 0)) && + isPlainSafeLast(codePointAt(string, string.length - 1)) if (singleLineOnly || forceQuotes) { // Case: no block styles. // Check for disallowed characters to rule out plain and single. for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); + char = codePointAt(string, i) if (!isPrintable(char)) { - return STYLE_DOUBLE; + return STYLE_DOUBLE } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; + plain = plain && isPlainSafe(char, prevChar, inblock) + prevChar = char } } else { // Case: block styles permitted. for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); + char = codePointAt(string, i) if (char === CHAR_LINE_FEED) { - hasLineBreak = true; + hasLineBreak = true // Check if any line can be folded. if (shouldTrackWidth) { hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented. (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' '); - previousLineBreak = i; + string[previousLineBreak + 1] !== ' ') + previousLineBreak = i } } else if (!isPrintable(char)) { - return STYLE_DOUBLE; + return STYLE_DOUBLE } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; + plain = plain && isPlainSafe(char, prevChar, inblock) + prevChar = char } // in case the end is missing a \n hasFoldableLine = hasFoldableLine || (shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' ')); + string[previousLineBreak + 1] !== ' ')) } // Although every style can represent \n without escaping, prefer block styles // for multiline, since they're more readable and they don't add empty lines. @@ -370,20 +367,20 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, // Strings interpretable as another type have to be quoted; // e.g. the string 'true' vs. the boolean true. if (plain && !forceQuotes && !testAmbiguousType(string)) { - return STYLE_PLAIN; + return STYLE_PLAIN } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE } // Edge case: block indentation indicator can only have one digit. if (indentPerLevel > 9 && needIndentIndicator(string)) { - return STYLE_DOUBLE; + return STYLE_DOUBLE } // At this point we know block styles are valid. // Prefer literal style unless we want to fold. if (!forceQuotes) { - return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE } // Note: line breaking/folding is implemented for only the folded style. @@ -392,18 +389,18 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, // • No ending newline => unaffected; already using strip "-" chomping. // • Ending newline => removed then restored. // Importantly, this keeps the "+" chomp indicator from gaining an extra line. -function writeScalar(state, string, level, iskey, inblock) { +function writeScalar (state, string, level, iskey, inblock) { state.dump = (function () { if (string.length === 0) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; + return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''" } if (!state.noCompatMode) { if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); + return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'") } } - var indent = state.indent * Math.max(1, level); // no 0-indent scalars + const indent = state.indent * Math.max(1, level) // no 0-indent scalars // As indentation gets deeper, let the width decrease monotonically // to the lower bound min(state.lineWidth, 40). // Note that this implies @@ -411,461 +408,441 @@ function writeScalar(state, string, level, iskey, inblock) { // state.lineWidth > 40 + state.indent: width decreases until the lower bound. // This behaves better than a constant minimum width which disallows narrower options, // or an indent threshold which causes the width to suddenly increase. - var lineWidth = state.lineWidth === -1 - ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + const lineWidth = (state.lineWidth === -1) + ? -1 + : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent) // Without knowing if keys are implicit/explicit, assume implicit for safety. - var singleLineOnly = iskey + const singleLineOnly = iskey || // No block styles in flow mode. - || (state.flowLevel > -1 && level >= state.flowLevel); - function testAmbiguity(string) { - return testImplicitResolving(state, string); + (state.flowLevel > -1 && level >= state.flowLevel) + function testAmbiguity (string) { + return testImplicitResolving(state, string) } switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { - case STYLE_PLAIN: - return string; + return string case STYLE_SINGLE: - return "'" + string.replace(/'/g, "''") + "'"; + return "'" + string.replace(/'/g, "''") + "'" case STYLE_LITERAL: - return '|' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(string, indent)); + return '|' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(string, indent)) case STYLE_FOLDED: - return '>' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); + return '>' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(foldString(string, lineWidth), indent)) case STYLE_DOUBLE: - return '"' + escapeString(string, lineWidth) + '"'; + return '"' + escapeString(string, lineWidth) + '"' default: - throw new YAMLException('impossible error: invalid scalar style'); + throw new YAMLException('impossible error: invalid scalar style') } - }()); + }()) } // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. -function blockHeader(string, indentPerLevel) { - var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; +function blockHeader (string, indentPerLevel) { + const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '' // note the special case: the string '\n' counts as a "trailing" empty line. - var clip = string[string.length - 1] === '\n'; - var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); - var chomp = keep ? '+' : (clip ? '' : '-'); + const clip = string[string.length - 1] === '\n' + const keep = clip && (string[string.length - 2] === '\n' || string === '\n') + const chomp = keep ? '+' : (clip ? '' : '-') - return indentIndicator + chomp + '\n'; + return indentIndicator + chomp + '\n' } // (See the note for writeScalar.) -function dropEndingNewline(string) { - return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; +function dropEndingNewline (string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string } // Note: a long line without a suitable break point will exceed the width limit. // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. -function foldString(string, width) { +function foldString (string, width) { // In folded style, $k$ consecutive newlines output as $k+1$ newlines— // unless they're before or after a more-indented line, or at the very // beginning or end, in which case $k$ maps to $k$. // Therefore, parse each chunk as newline(s) followed by a content line. - var lineRe = /(\n+)([^\n]*)/g; + const lineRe = /(\n+)([^\n]*)/g // first line (possibly an empty line) - var result = (function () { - var nextLF = string.indexOf('\n'); - nextLF = nextLF !== -1 ? nextLF : string.length; - lineRe.lastIndex = nextLF; - return foldLine(string.slice(0, nextLF), width); - }()); + let result = (function () { + let nextLF = string.indexOf('\n') + nextLF = nextLF !== -1 ? nextLF : string.length + lineRe.lastIndex = nextLF + return foldLine(string.slice(0, nextLF), width) + }()) // If we haven't reached the first content line yet, don't add an extra \n. - var prevMoreIndented = string[0] === '\n' || string[0] === ' '; - var moreIndented; + let prevMoreIndented = string[0] === '\n' || string[0] === ' ' + let moreIndented // rest of the lines - var match; + let match while ((match = lineRe.exec(string))) { - var prefix = match[1], line = match[2]; - moreIndented = (line[0] === ' '); - result += prefix - + (!prevMoreIndented && !moreIndented && line !== '' - ? '\n' : '') - + foldLine(line, width); - prevMoreIndented = moreIndented; + const prefix = match[1] + const line = match[2] + + moreIndented = (line[0] === ' ') + result += prefix + + ((!prevMoreIndented && !moreIndented && line !== '') ? '\n' : '') + + foldLine(line, width) + prevMoreIndented = moreIndented } - return result; + return result } // Greedy line breaking. // Picks the longest line under the limit each time, // otherwise settles for the shortest line over the limit. // NB. More-indented lines *cannot* be folded, as that would add an extra \n. -function foldLine(line, width) { - if (line === '' || line[0] === ' ') return line; +function foldLine (line, width) { + if (line === '' || line[0] === ' ') return line // Since a more-indented line adds a \n, breaks can't be followed by a space. - var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. - var match; + const breakRe = / [^ ]/g // note: the match index will always be <= length-2. + let match // start is an inclusive index. end, curr, and next are exclusive. - var start = 0, end, curr = 0, next = 0; - var result = ''; + let start = 0 + let end + let curr = 0 + let next = 0 + let result = '' // Invariants: 0 <= start <= length-1. // 0 <= curr <= next <= max(0, length-2). curr - start <= width. // Inside the loop: // A match implies length >= 2, so curr and next are <= length-2. while ((match = breakRe.exec(line))) { - next = match.index; + next = match.index // maintain invariant: curr - start <= width if (next - start > width) { - end = (curr > start) ? curr : next; // derive end <= length-2 - result += '\n' + line.slice(start, end); + end = (curr > start) ? curr : next // derive end <= length-2 + result += '\n' + line.slice(start, end) // skip the space that was output as \n - start = end + 1; // derive start <= length-1 + start = end + 1 // derive start <= length-1 } - curr = next; + curr = next } // By the invariants, start <= length-1, so there is something left over. // It is either the whole string or a part starting from non-whitespace. - result += '\n'; + result += '\n' // Insert a break if the remainder is too long and there is a break available. if (line.length - start > width && curr > start) { - result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + result += line.slice(start, curr) + '\n' + line.slice(curr + 1) } else { - result += line.slice(start); + result += line.slice(start) } - return result.slice(1); // drop extra \n joiner + return result.slice(1) // drop extra \n joiner } // Escapes a double-quoted string. -function escapeString(string) { - var result = ''; - var char = 0; - var escapeSeq; +function escapeString (string) { + let result = '' + let char = 0 - for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - escapeSeq = ESCAPE_SEQUENCES[char]; + for (let i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i) + const escapeSeq = ESCAPE_SEQUENCES[char] if (!escapeSeq && isPrintable(char)) { - result += string[i]; - if (char >= 0x10000) result += string[i + 1]; + result += string[i] + if (char >= 0x10000) result += string[i + 1] } else { - result += escapeSeq || encodeHex(char); + result += escapeSeq || encodeHex(char) } } - return result; + return result } -function writeFlowSequence(state, level, object) { - var _result = '', - _tag = state.tag, - index, - length, - value; +function writeFlowSequence (state, level, object) { + let _result = '' + const _tag = state.tag - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; + for (let index = 0, length = object.length; index < length; index += 1) { + let value = object[index] if (state.replacer) { - value = state.replacer.call(object, String(index), value); + value = state.replacer.call(object, String(index), value) } // Write only valid elements, put null instead of invalid elements. if (writeNode(state, level, value, false, false) || (typeof value === 'undefined' && writeNode(state, level, null, false, false))) { - - if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); - _result += state.dump; + if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : '') + _result += state.dump } } - state.tag = _tag; - state.dump = '[' + _result + ']'; + state.tag = _tag + state.dump = '[' + _result + ']' } -function writeBlockSequence(state, level, object, compact) { - var _result = '', - _tag = state.tag, - index, - length, - value; +function writeBlockSequence (state, level, object, compact) { + let _result = '' + const _tag = state.tag - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; + for (let index = 0, length = object.length; index < length; index += 1) { + let value = object[index] if (state.replacer) { - value = state.replacer.call(object, String(index), value); + value = state.replacer.call(object, String(index), value) } // Write only valid elements, put null instead of invalid elements. if (writeNode(state, level + 1, value, true, true, false, true) || (typeof value === 'undefined' && writeNode(state, level + 1, null, true, true, false, true))) { - if (!compact || _result !== '') { - _result += generateNextLine(state, level); + _result += generateNextLine(state, level) } if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - _result += '-'; + _result += '-' } else { - _result += '- '; + _result += '- ' } - _result += state.dump; + _result += state.dump } } - state.tag = _tag; - state.dump = _result || '[]'; // Empty sequence if no valid values. + state.tag = _tag + state.dump = _result || '[]' // Empty sequence if no valid values. } -function writeFlowMapping(state, level, object) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - pairBuffer; - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { +function writeFlowMapping (state, level, object) { + let _result = '' + const _tag = state.tag + const objectKeyList = Object.keys(object) - pairBuffer = ''; - if (_result !== '') pairBuffer += ', '; + for (let index = 0, length = objectKeyList.length; index < length; index += 1) { + let pairBuffer = '' + if (_result !== '') pairBuffer += ', ' - if (state.condenseFlow) pairBuffer += '"'; + if (state.condenseFlow) pairBuffer += '"' - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; + const objectKey = objectKeyList[index] + let objectValue = object[objectKey] if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); + objectValue = state.replacer.call(object, objectKey, objectValue) } if (!writeNode(state, level, objectKey, false, false)) { - continue; // Skip this pair because of invalid key; + continue // Skip this pair because of invalid key; } - if (state.dump.length > 1024) pairBuffer += '? '; + if (state.dump.length > 1024) pairBuffer += '? ' - pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ') if (!writeNode(state, level, objectValue, false, false)) { - continue; // Skip this pair because of invalid value. + continue // Skip this pair because of invalid value. } - pairBuffer += state.dump; + pairBuffer += state.dump // Both key and value are valid. - _result += pairBuffer; + _result += pairBuffer } - state.tag = _tag; - state.dump = '{' + _result + '}'; + state.tag = _tag + state.dump = '{' + _result + '}' } -function writeBlockMapping(state, level, object, compact) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - explicitPair, - pairBuffer; +function writeBlockMapping (state, level, object, compact) { + let _result = '' + const _tag = state.tag + const objectKeyList = Object.keys(object) // Allow sorting keys so that the output file is deterministic if (state.sortKeys === true) { // Default sorting - objectKeyList.sort(); + objectKeyList.sort() } else if (typeof state.sortKeys === 'function') { // Custom sort function - objectKeyList.sort(state.sortKeys); + objectKeyList.sort(state.sortKeys) } else if (state.sortKeys) { // Something is wrong - throw new YAMLException('sortKeys must be a boolean or a function'); + throw new YAMLException('sortKeys must be a boolean or a function') } - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ''; + for (let index = 0, length = objectKeyList.length; index < length; index += 1) { + let pairBuffer = '' if (!compact || _result !== '') { - pairBuffer += generateNextLine(state, level); + pairBuffer += generateNextLine(state, level) } - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; + const objectKey = objectKeyList[index] + let objectValue = object[objectKey] if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); + objectValue = state.replacer.call(object, objectKey, objectValue) } if (!writeNode(state, level + 1, objectKey, true, true, true)) { - continue; // Skip this pair because of invalid key. + continue // Skip this pair because of invalid key. } - explicitPair = (state.tag !== null && state.tag !== '?') || - (state.dump && state.dump.length > 1024); + const explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024) if (explicitPair) { if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += '?'; + pairBuffer += '?' } else { - pairBuffer += '? '; + pairBuffer += '? ' } } - pairBuffer += state.dump; + pairBuffer += state.dump if (explicitPair) { - pairBuffer += generateNextLine(state, level); + pairBuffer += generateNextLine(state, level) } if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { - continue; // Skip this pair because of invalid value. + continue // Skip this pair because of invalid value. } if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += ':'; + pairBuffer += ':' } else { - pairBuffer += ': '; + pairBuffer += ': ' } - pairBuffer += state.dump; + pairBuffer += state.dump // Both key and value are valid. - _result += pairBuffer; + _result += pairBuffer } - state.tag = _tag; - state.dump = _result || '{}'; // Empty mapping if no valid pairs. + state.tag = _tag + state.dump = _result || '{}' // Empty mapping if no valid pairs. } -function detectType(state, object, explicit) { - var _result, typeList, index, length, type, style; +function detectType (state, object, explicit) { + const typeList = explicit ? state.explicitTypes : state.implicitTypes - typeList = explicit ? state.explicitTypes : state.implicitTypes; + for (let index = 0, length = typeList.length; index < length; index += 1) { + const type = typeList[index] - for (index = 0, length = typeList.length; index < length; index += 1) { - type = typeList[index]; - - if ((type.instanceOf || type.predicate) && + if ((type.instanceOf || type.predicate) && (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && - (!type.predicate || type.predicate(object))) { - + (!type.predicate || type.predicate(object))) { if (explicit) { if (type.multi && type.representName) { - state.tag = type.representName(object); + state.tag = type.representName(object) } else { - state.tag = type.tag; + state.tag = type.tag } } else { - state.tag = '?'; + state.tag = '?' } if (type.represent) { - style = state.styleMap[type.tag] || type.defaultStyle; + const style = state.styleMap[type.tag] || type.defaultStyle + let _result if (_toString.call(type.represent) === '[object Function]') { - _result = type.represent(object, style); + _result = type.represent(object, style) } else if (_hasOwnProperty.call(type.represent, style)) { - _result = type.represent[style](object, style); + _result = type.represent[style](object, style) } else { - throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style') } - state.dump = _result; + state.dump = _result } - return true; + return true } } - return false; + return false } // Serializes `object` and writes it to global `result`. // Returns true on success, or false on invalid object. // -function writeNode(state, level, object, block, compact, iskey, isblockseq) { - state.tag = null; - state.dump = object; +function writeNode (state, level, object, block, compact, iskey, isblockseq) { + state.tag = null + state.dump = object if (!detectType(state, object, false)) { - detectType(state, object, true); + detectType(state, object, true) } - var type = _toString.call(state.dump); - var inblock = block; - var tagStr; + const type = _toString.call(state.dump) + const inblock = block if (block) { - block = (state.flowLevel < 0 || state.flowLevel > level); + block = (state.flowLevel < 0 || state.flowLevel > level) } - var objectOrArray = type === '[object Object]' || type === '[object Array]', - duplicateIndex, - duplicate; + const objectOrArray = type === '[object Object]' || type === '[object Array]' + let duplicateIndex + let duplicate if (objectOrArray) { - duplicateIndex = state.duplicates.indexOf(object); - duplicate = duplicateIndex !== -1; + duplicateIndex = state.duplicates.indexOf(object) + duplicate = duplicateIndex !== -1 } if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { - compact = false; + compact = false } if (duplicate && state.usedDuplicates[duplicateIndex]) { - state.dump = '*ref_' + duplicateIndex; + state.dump = '*ref_' + duplicateIndex } else { if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { - state.usedDuplicates[duplicateIndex] = true; + state.usedDuplicates[duplicateIndex] = true } if (type === '[object Object]') { if (block && (Object.keys(state.dump).length !== 0)) { - writeBlockMapping(state, level, state.dump, compact); + writeBlockMapping(state, level, state.dump, compact) if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; + state.dump = '&ref_' + duplicateIndex + state.dump } } else { - writeFlowMapping(state, level, state.dump); + writeFlowMapping(state, level, state.dump) if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump } } } else if (type === '[object Array]') { if (block && (state.dump.length !== 0)) { if (state.noArrayIndent && !isblockseq && level > 0) { - writeBlockSequence(state, level - 1, state.dump, compact); + writeBlockSequence(state, level - 1, state.dump, compact) } else { - writeBlockSequence(state, level, state.dump, compact); + writeBlockSequence(state, level, state.dump, compact) } if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; + state.dump = '&ref_' + duplicateIndex + state.dump } } else { - writeFlowSequence(state, level, state.dump); + writeFlowSequence(state, level, state.dump) if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump } } } else if (type === '[object String]') { if (state.tag !== '?') { - writeScalar(state, state.dump, level, iskey, inblock); + writeScalar(state, state.dump, level, iskey, inblock) } } else if (type === '[object Undefined]') { - return false; + return false } else { - if (state.skipInvalid) return false; - throw new YAMLException('unacceptable kind of an object to dump ' + type); + if (state.skipInvalid) return false + throw new YAMLException('unacceptable kind of an object to dump ' + type) } if (state.tag !== null && state.tag !== '?') { @@ -882,84 +859,79 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) { // // Also need to encode '!' because it has special meaning (end of tag prefix). // - tagStr = encodeURI( + let tagStr = encodeURI( state.tag[0] === '!' ? state.tag.slice(1) : state.tag - ).replace(/!/g, '%21'); + ).replace(/!/g, '%21') if (state.tag[0] === '!') { - tagStr = '!' + tagStr; + tagStr = '!' + tagStr } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { - tagStr = '!!' + tagStr.slice(18); + tagStr = '!!' + tagStr.slice(18) } else { - tagStr = '!<' + tagStr + '>'; + tagStr = '!<' + tagStr + '>' } - state.dump = tagStr + ' ' + state.dump; + state.dump = tagStr + ' ' + state.dump } } - return true; + return true } -function getDuplicateReferences(object, state) { - var objects = [], - duplicatesIndexes = [], - index, - length; +function getDuplicateReferences (object, state) { + const objects = [] + const duplicatesIndexes = [] - inspectNode(object, objects, duplicatesIndexes); + inspectNode(object, objects, duplicatesIndexes) - for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { - state.duplicates.push(objects[duplicatesIndexes[index]]); + const length = duplicatesIndexes.length + for (let index = 0; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]) } - state.usedDuplicates = new Array(length); + state.usedDuplicates = new Array(length) } -function inspectNode(object, objects, duplicatesIndexes) { - var objectKeyList, - index, - length; - +function inspectNode (object, objects, duplicatesIndexes) { if (object !== null && typeof object === 'object') { - index = objects.indexOf(object); + const index = objects.indexOf(object) if (index !== -1) { if (duplicatesIndexes.indexOf(index) === -1) { - duplicatesIndexes.push(index); + duplicatesIndexes.push(index) } } else { - objects.push(object); + objects.push(object) if (Array.isArray(object)) { - for (index = 0, length = object.length; index < length; index += 1) { - inspectNode(object[index], objects, duplicatesIndexes); + for (let i = 0, length = object.length; i < length; i += 1) { + inspectNode(object[i], objects, duplicatesIndexes) } } else { - objectKeyList = Object.keys(object); + const objectKeyList = Object.keys(object) - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + for (let i = 0, length = objectKeyList.length; i < length; i += 1) { + inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes) } } } } } -function dump(input, options) { - options = options || {}; +function dump (input, options) { + options = options || {} - var state = new State(options); + const state = new State(options) - if (!state.noRefs) getDuplicateReferences(input, state); + if (!state.noRefs) getDuplicateReferences(input, state) - var value = input; + let value = input if (state.replacer) { - value = state.replacer.call({ '': value }, '', value); + value = state.replacer.call({ '': value }, '', value) } - if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; + if (writeNode(state, 0, value, true, true)) return state.dump + '\n' - return ''; + return '' } -module.exports.dump = dump; +module.exports.dump = dump diff --git a/lib/exception.js b/lib/exception.js index 7f62daae..8571562e 100644 --- a/lib/exception.js +++ b/lib/exception.js @@ -1,55 +1,51 @@ // YAML error class. http://stackoverflow.com/questions/8458984 // -'use strict'; +'use strict' +function formatError (exception, compact) { + let where = '' + const message = exception.reason || '(unknown reason)' -function formatError(exception, compact) { - var where = '', message = exception.reason || '(unknown reason)'; - - if (!exception.mark) return message; + if (!exception.mark) return message if (exception.mark.name) { - where += 'in "' + exception.mark.name + '" '; + where += 'in "' + exception.mark.name + '" ' } - where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; + where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')' if (!compact && exception.mark.snippet) { - where += '\n\n' + exception.mark.snippet; + where += '\n\n' + exception.mark.snippet } - return message + ' ' + where; + return message + ' ' + where } - -function YAMLException(reason, mark) { +function YAMLException (reason, mark) { // Super constructor - Error.call(this); + Error.call(this) - this.name = 'YAMLException'; - this.reason = reason; - this.mark = mark; - this.message = formatError(this, false); + this.name = 'YAMLException' + this.reason = reason + this.mark = mark + this.message = formatError(this, false) // Include stack trace in error object if (Error.captureStackTrace) { // Chrome and NodeJS - Error.captureStackTrace(this, this.constructor); + Error.captureStackTrace(this, this.constructor) } else { // FF, IE 10+ and Safari 6+. Fallback for others - this.stack = (new Error()).stack || ''; + this.stack = (new Error()).stack || '' } } - // Inherit from Error -YAMLException.prototype = Object.create(Error.prototype); -YAMLException.prototype.constructor = YAMLException; - - -YAMLException.prototype.toString = function toString(compact) { - return this.name + ': ' + formatError(this, compact); -}; +YAMLException.prototype = Object.create(Error.prototype) +YAMLException.prototype.constructor = YAMLException +YAMLException.prototype.toString = function toString (compact) { + return this.name + ': ' + formatError(this, compact) +} -module.exports = YAMLException; +module.exports = YAMLException diff --git a/lib/index_vite_proxy.tmp.mjs b/lib/index_vite_proxy.tmp.mjs new file mode 100644 index 00000000..303f2316 --- /dev/null +++ b/lib/index_vite_proxy.tmp.mjs @@ -0,0 +1,37 @@ +import yaml from '../index.js' + +const { + Type, + Schema, + FAILSAFE_SCHEMA, + JSON_SCHEMA, + CORE_SCHEMA, + DEFAULT_SCHEMA, + load, + loadAll, + dump, + YAMLException, + types, + safeLoad, + safeLoadAll, + safeDump +} = yaml + +export { + Type, + Schema, + FAILSAFE_SCHEMA, + JSON_SCHEMA, + CORE_SCHEMA, + DEFAULT_SCHEMA, + load, + loadAll, + dump, + YAMLException, + types, + safeLoad, + safeLoadAll, + safeDump +} + +export default yaml diff --git a/lib/loader.js b/lib/loader.js index 25abc808..8256c2d4 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -1,128 +1,121 @@ -'use strict'; +'use strict' -/*eslint-disable max-len,no-use-before-define*/ +const common = require('./common') +const YAMLException = require('./exception') +const makeSnippet = require('./snippet') +const DEFAULT_SCHEMA = require('./schema/default') -var common = require('./common'); -var YAMLException = require('./exception'); -var makeSnippet = require('./snippet'); -var DEFAULT_SCHEMA = require('./schema/default'); +const _hasOwnProperty = Object.prototype.hasOwnProperty +const CONTEXT_FLOW_IN = 1 +const CONTEXT_FLOW_OUT = 2 +const CONTEXT_BLOCK_IN = 3 +const CONTEXT_BLOCK_OUT = 4 -var _hasOwnProperty = Object.prototype.hasOwnProperty; +const CHOMPING_CLIP = 1 +const CHOMPING_STRIP = 2 +const CHOMPING_KEEP = 3 +// eslint-disable-next-line no-control-regex +const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/ +const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/ +const PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/ +const PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i +const PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i -var CONTEXT_FLOW_IN = 1; -var CONTEXT_FLOW_OUT = 2; -var CONTEXT_BLOCK_IN = 3; -var CONTEXT_BLOCK_OUT = 4; +function _class (obj) { return Object.prototype.toString.call(obj) } - -var CHOMPING_CLIP = 1; -var CHOMPING_STRIP = 2; -var CHOMPING_KEEP = 3; - - -var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; -var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; -var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; -var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; -var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; - - -function _class(obj) { return Object.prototype.toString.call(obj); } - -function is_EOL(c) { - return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +function is_EOL (c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */) } -function is_WHITE_SPACE(c) { - return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +function is_WHITE_SPACE (c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */) } -function is_WS_OR_EOL(c) { +function is_WS_OR_EOL (c) { return (c === 0x09/* Tab */) || (c === 0x20/* Space */) || (c === 0x0A/* LF */) || - (c === 0x0D/* CR */); + (c === 0x0D/* CR */) } -function is_FLOW_INDICATOR(c) { +function is_FLOW_INDICATOR (c) { return c === 0x2C/* , */ || c === 0x5B/* [ */ || c === 0x5D/* ] */ || c === 0x7B/* { */ || - c === 0x7D/* } */; + c === 0x7D/* } */ } -function fromHexCode(c) { - var lc; - - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; +function fromHexCode (c) { + if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) { + return c - 0x30 } - /*eslint-disable no-bitwise*/ - lc = c | 0x20; + const lc = c | 0x20 - if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { - return lc - 0x61 + 10; + if ((lc >= 0x61/* a */) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10 } - return -1; + return -1 } -function escapedHexLen(c) { - if (c === 0x78/* x */) { return 2; } - if (c === 0x75/* u */) { return 4; } - if (c === 0x55/* U */) { return 8; } - return 0; +function escapedHexLen (c) { + if (c === 0x78/* x */) { return 2 } + if (c === 0x75/* u */) { return 4 } + if (c === 0x55/* U */) { return 8 } + return 0 } -function fromDecimalCode(c) { - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; +function fromDecimalCode (c) { + if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) { + return c - 0x30 } - return -1; + return -1 } -function simpleEscapeSequence(c) { - /* eslint-disable indent */ - return (c === 0x30/* 0 */) ? '\x00' : - (c === 0x61/* a */) ? '\x07' : - (c === 0x62/* b */) ? '\x08' : - (c === 0x74/* t */) ? '\x09' : - (c === 0x09/* Tab */) ? '\x09' : - (c === 0x6E/* n */) ? '\x0A' : - (c === 0x76/* v */) ? '\x0B' : - (c === 0x66/* f */) ? '\x0C' : - (c === 0x72/* r */) ? '\x0D' : - (c === 0x65/* e */) ? '\x1B' : - (c === 0x20/* Space */) ? ' ' : - (c === 0x22/* " */) ? '\x22' : - (c === 0x2F/* / */) ? '/' : - (c === 0x5C/* \ */) ? '\x5C' : - (c === 0x4E/* N */) ? '\x85' : - (c === 0x5F/* _ */) ? '\xA0' : - (c === 0x4C/* L */) ? '\u2028' : - (c === 0x50/* P */) ? '\u2029' : ''; +function simpleEscapeSequence (c) { + switch (c) { + case 0x30/* 0 */: return '\x00' + case 0x61/* a */: return '\x07' + case 0x62/* b */: return '\x08' + case 0x74/* t */: return '\x09' + case 0x09/* Tab */: return '\x09' + case 0x6E/* n */: return '\x0A' + case 0x76/* v */: return '\x0B' + case 0x66/* f */: return '\x0C' + case 0x72/* r */: return '\x0D' + case 0x65/* e */: return '\x1B' + case 0x20/* Space */: return ' ' + case 0x22/* " */: return '\x22' + case 0x2F/* / */: return '/' + case 0x5C/* \ */: return '\x5C' + case 0x4E/* N */: return '\x85' + case 0x5F/* _ */: return '\xA0' + case 0x4C/* L */: return '\u2028' + case 0x50/* P */: return '\u2029' + default: return '' + } } -function charFromCodepoint(c) { +function charFromCodepoint (c) { if (c <= 0xFFFF) { - return String.fromCharCode(c); + return String.fromCharCode(c) } // Encode UTF-16 surrogate pair // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF return String.fromCharCode( ((c - 0x010000) >> 10) + 0xD800, ((c - 0x010000) & 0x03FF) + 0xDC00 - ); + ) } // set a property of a literal object, while protecting against prototype pollution, // see https://github.com/nodeca/js-yaml/issues/164 for more details -function setProperty(object, key, value) { +function setProperty (object, key, value) { // used for this specific key only because Object.defineProperty is slow if (key === '__proto__') { Object.defineProperty(object, key, { @@ -130,47 +123,46 @@ function setProperty(object, key, value) { enumerable: true, writable: true, value: value - }); + }) } else { - object[key] = value; + object[key] = value } } -var simpleEscapeCheck = new Array(256); // integer, for fast access -var simpleEscapeMap = new Array(256); -for (var i = 0; i < 256; i++) { - simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; - simpleEscapeMap[i] = simpleEscapeSequence(i); +const simpleEscapeCheck = new Array(256) // integer, for fast access +const simpleEscapeMap = new Array(256) +for (let i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0 + simpleEscapeMap[i] = simpleEscapeSequence(i) } +function State (input, options) { + this.input = input -function State(input, options) { - this.input = input; - - this.filename = options['filename'] || null; - this.schema = options['schema'] || DEFAULT_SCHEMA; - this.onWarning = options['onWarning'] || null; + this.filename = options['filename'] || null + this.schema = options['schema'] || DEFAULT_SCHEMA + this.onWarning = options['onWarning'] || null // (Hidden) Remove? makes the loader to expect YAML 1.1 documents // if such documents have no explicit %YAML directive - this.legacy = options['legacy'] || false; + this.legacy = options['legacy'] || false - this.json = options['json'] || false; - this.listener = options['listener'] || null; + this.json = options['json'] || false + this.listener = options['listener'] || null - this.implicitTypes = this.schema.compiledImplicit; - this.typeMap = this.schema.compiledTypeMap; + this.implicitTypes = this.schema.compiledImplicit + this.typeMap = this.schema.compiledTypeMap - this.length = input.length; - this.position = 0; - this.line = 0; - this.lineStart = 0; - this.lineIndent = 0; + this.length = input.length + this.position = 0 + this.line = 0 + this.lineStart = 0 + this.lineIndent = 0 // position of first leading tab in the current line, // used to make sure there are no tabs in the indentation - this.firstTabInLine = -1; + this.firstTabInLine = -1 - this.documents = []; + this.documents = [] /* this.version; @@ -180,164 +172,149 @@ function State(input, options) { this.tag; this.anchor; this.kind; - this.result;*/ - + this.result; */ } - -function generateError(state, message) { - var mark = { +function generateError (state, message) { + const mark = { name: state.filename, buffer: state.input.slice(0, -1), // omit trailing \0 position: state.position, line: state.line, column: state.position - state.lineStart - }; + } - mark.snippet = makeSnippet(mark); + mark.snippet = makeSnippet(mark) - return new YAMLException(message, mark); + return new YAMLException(message, mark) } -function throwError(state, message) { - throw generateError(state, message); +function throwError (state, message) { + throw generateError(state, message) } -function throwWarning(state, message) { +function throwWarning (state, message) { if (state.onWarning) { - state.onWarning.call(null, generateError(state, message)); + state.onWarning.call(null, generateError(state, message)) } } +const directiveHandlers = { -var directiveHandlers = { - - YAML: function handleYamlDirective(state, name, args) { - - var match, major, minor; - + YAML: function handleYamlDirective (state, name, args) { if (state.version !== null) { - throwError(state, 'duplication of %YAML directive'); + throwError(state, 'duplication of %YAML directive') } if (args.length !== 1) { - throwError(state, 'YAML directive accepts exactly one argument'); + throwError(state, 'YAML directive accepts exactly one argument') } - match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]) if (match === null) { - throwError(state, 'ill-formed argument of the YAML directive'); + throwError(state, 'ill-formed argument of the YAML directive') } - major = parseInt(match[1], 10); - minor = parseInt(match[2], 10); + const major = parseInt(match[1], 10) + const minor = parseInt(match[2], 10) if (major !== 1) { - throwError(state, 'unacceptable YAML version of the document'); + throwError(state, 'unacceptable YAML version of the document') } - state.version = args[0]; - state.checkLineBreaks = (minor < 2); + state.version = args[0] + state.checkLineBreaks = (minor < 2) if (minor !== 1 && minor !== 2) { - throwWarning(state, 'unsupported YAML version of the document'); + throwWarning(state, 'unsupported YAML version of the document') } }, - TAG: function handleTagDirective(state, name, args) { - - var handle, prefix; + TAG: function handleTagDirective (state, name, args) { + let prefix if (args.length !== 2) { - throwError(state, 'TAG directive accepts exactly two arguments'); + throwError(state, 'TAG directive accepts exactly two arguments') } - handle = args[0]; - prefix = args[1]; + const handle = args[0] + prefix = args[1] if (!PATTERN_TAG_HANDLE.test(handle)) { - throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive') } if (_hasOwnProperty.call(state.tagMap, handle)) { - throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle') } if (!PATTERN_TAG_URI.test(prefix)) { - throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive') } try { - prefix = decodeURIComponent(prefix); + prefix = decodeURIComponent(prefix) } catch (err) { - throwError(state, 'tag prefix is malformed: ' + prefix); + throwError(state, 'tag prefix is malformed: ' + prefix) } - state.tagMap[handle] = prefix; + state.tagMap[handle] = prefix } -}; - - -function captureSegment(state, start, end, checkJson) { - var _position, _length, _character, _result; +} +function captureSegment (state, start, end, checkJson) { if (start < end) { - _result = state.input.slice(start, end); + const _result = state.input.slice(start, end) if (checkJson) { - for (_position = 0, _length = _result.length; _position < _length; _position += 1) { - _character = _result.charCodeAt(_position); + for (let _position = 0, _length = _result.length; _position < _length; _position += 1) { + const _character = _result.charCodeAt(_position) if (!(_character === 0x09 || - (0x20 <= _character && _character <= 0x10FFFF))) { - throwError(state, 'expected valid JSON character'); + (_character >= 0x20 && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character') } } } else if (PATTERN_NON_PRINTABLE.test(_result)) { - throwError(state, 'the stream contains non-printable characters'); + throwError(state, 'the stream contains non-printable characters') } - state.result += _result; + state.result += _result } } -function mergeMappings(state, destination, source, overridableKeys) { - var sourceKeys, key, index, quantity; - +function mergeMappings (state, destination, source, overridableKeys) { if (!common.isObject(source)) { - throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + throwError(state, 'cannot merge mappings; the provided source object is unacceptable') } - sourceKeys = Object.keys(source); + const sourceKeys = Object.keys(source) - for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { - key = sourceKeys[index]; + for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + const key = sourceKeys[index] if (!_hasOwnProperty.call(destination, key)) { - setProperty(destination, key, source[key]); - overridableKeys[key] = true; + setProperty(destination, key, source[key]) + overridableKeys[key] = true } } } -function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, +function storeMappingPair (state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) { - - var index, quantity; - // The output is a plain object here, so keys can only be strings. // We need to convert keyNode to a string, but doing so can hang the process // (deeply nested arrays that explode exponentially using aliases). if (Array.isArray(keyNode)) { - keyNode = Array.prototype.slice.call(keyNode); + keyNode = Array.prototype.slice.call(keyNode) - for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) { if (Array.isArray(keyNode[index])) { - throwError(state, 'nested arrays are not supported inside keys'); + throwError(state, 'nested arrays are not supported inside keys') } if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { - keyNode[index] = '[object Object]'; + keyNode[index] = '[object Object]' } } } @@ -346,814 +323,768 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu // (still use its own toString for arrays, timestamps, // and whatever user schema extensions happen to have @@toStringTag) if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { - keyNode = '[object Object]'; + keyNode = '[object Object]' } - - keyNode = String(keyNode); + keyNode = String(keyNode) if (_result === null) { - _result = {}; + _result = {} } if (keyTag === 'tag:yaml.org,2002:merge') { if (Array.isArray(valueNode)) { - for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { - mergeMappings(state, _result, valueNode[index], overridableKeys); + for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys) } } else { - mergeMappings(state, _result, valueNode, overridableKeys); + mergeMappings(state, _result, valueNode, overridableKeys) } } else { if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) { - state.line = startLine || state.line; - state.lineStart = startLineStart || state.lineStart; - state.position = startPos || state.position; - throwError(state, 'duplicated mapping key'); + state.line = startLine || state.line + state.lineStart = startLineStart || state.lineStart + state.position = startPos || state.position + throwError(state, 'duplicated mapping key') } - setProperty(_result, keyNode, valueNode); - delete overridableKeys[keyNode]; + setProperty(_result, keyNode, valueNode) + delete overridableKeys[keyNode] } - return _result; + return _result } -function readLineBreak(state) { - var ch; - - ch = state.input.charCodeAt(state.position); +function readLineBreak (state) { + const ch = state.input.charCodeAt(state.position) if (ch === 0x0A/* LF */) { - state.position++; + state.position++ } else if (ch === 0x0D/* CR */) { - state.position++; + state.position++ if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { - state.position++; + state.position++ } } else { - throwError(state, 'a line break is expected'); + throwError(state, 'a line break is expected') } - state.line += 1; - state.lineStart = state.position; - state.firstTabInLine = -1; + state.line += 1 + state.lineStart = state.position + state.firstTabInLine = -1 } -function skipSeparationSpace(state, allowComments, checkIndent) { - var lineBreaks = 0, - ch = state.input.charCodeAt(state.position); +function skipSeparationSpace (state, allowComments, checkIndent) { + let lineBreaks = 0 + let ch = state.input.charCodeAt(state.position) while (ch !== 0) { while (is_WHITE_SPACE(ch)) { if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { - state.firstTabInLine = state.position; + state.firstTabInLine = state.position } - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } if (allowComments && ch === 0x23/* # */) { do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + ch = state.input.charCodeAt(++state.position) + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0) } if (is_EOL(ch)) { - readLineBreak(state); + readLineBreak(state) - ch = state.input.charCodeAt(state.position); - lineBreaks++; - state.lineIndent = 0; + ch = state.input.charCodeAt(state.position) + lineBreaks++ + state.lineIndent = 0 while (ch === 0x20/* Space */) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); + state.lineIndent++ + ch = state.input.charCodeAt(++state.position) } } else { - break; + break } } if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { - throwWarning(state, 'deficient indentation'); + throwWarning(state, 'deficient indentation') } - return lineBreaks; + return lineBreaks } -function testDocumentSeparator(state) { - var _position = state.position, - ch; - - ch = state.input.charCodeAt(_position); +function testDocumentSeparator (state) { + let _position = state.position + let ch = state.input.charCodeAt(_position) // Condition state.position === state.lineStart is tested // in parent on each call, for efficiency. No needs to test here again. if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) { + _position += 3 - _position += 3; - - ch = state.input.charCodeAt(_position); + ch = state.input.charCodeAt(_position) if (ch === 0 || is_WS_OR_EOL(ch)) { - return true; + return true } } - return false; + return false } -function writeFoldedLines(state, count) { +function writeFoldedLines (state, count) { if (count === 1) { - state.result += ' '; + state.result += ' ' } else if (count > 1) { - state.result += common.repeat('\n', count - 1); + state.result += common.repeat('\n', count - 1) } } +function readPlainScalar (state, nodeIndent, withinFlowCollection) { + let captureStart + let captureEnd + let hasPendingContent + let _line + let _lineStart + let _lineIndent + const _kind = state.kind + const _result = state.result -function readPlainScalar(state, nodeIndent, withinFlowCollection) { - var preceding, - following, - captureStart, - captureEnd, - hasPendingContent, - _line, - _lineStart, - _lineIndent, - _kind = state.kind, - _result = state.result, - ch; - - ch = state.input.charCodeAt(state.position); + let ch = state.input.charCodeAt(state.position) - if (is_WS_OR_EOL(ch) || + if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || - ch === 0x23/* # */ || - ch === 0x26/* & */ || - ch === 0x2A/* * */ || - ch === 0x21/* ! */ || - ch === 0x7C/* | */ || - ch === 0x3E/* > */ || - ch === 0x27/* ' */ || - ch === 0x22/* " */ || - ch === 0x25/* % */ || - ch === 0x40/* @ */ || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || ch === 0x60/* ` */) { - return false; + return false } if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { - following = state.input.charCodeAt(state.position + 1); + const following = state.input.charCodeAt(state.position + 1) if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - return false; + (withinFlowCollection && is_FLOW_INDICATOR(following))) { + return false } } - state.kind = 'scalar'; - state.result = ''; - captureStart = captureEnd = state.position; - hasPendingContent = false; + state.kind = 'scalar' + state.result = '' + captureStart = captureEnd = state.position + hasPendingContent = false while (ch !== 0) { if (ch === 0x3A/* : */) { - following = state.input.charCodeAt(state.position + 1); + const following = state.input.charCodeAt(state.position + 1) if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - break; + (withinFlowCollection && is_FLOW_INDICATOR(following))) { + break } - } else if (ch === 0x23/* # */) { - preceding = state.input.charCodeAt(state.position - 1); + const preceding = state.input.charCodeAt(state.position - 1) if (is_WS_OR_EOL(preceding)) { - break; + break } - } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || - withinFlowCollection && is_FLOW_INDICATOR(ch)) { - break; - + (withinFlowCollection && is_FLOW_INDICATOR(ch))) { + break } else if (is_EOL(ch)) { - _line = state.line; - _lineStart = state.lineStart; - _lineIndent = state.lineIndent; - skipSeparationSpace(state, false, -1); + _line = state.line + _lineStart = state.lineStart + _lineIndent = state.lineIndent + skipSeparationSpace(state, false, -1) if (state.lineIndent >= nodeIndent) { - hasPendingContent = true; - ch = state.input.charCodeAt(state.position); - continue; + hasPendingContent = true + ch = state.input.charCodeAt(state.position) + continue } else { - state.position = captureEnd; - state.line = _line; - state.lineStart = _lineStart; - state.lineIndent = _lineIndent; - break; + state.position = captureEnd + state.line = _line + state.lineStart = _lineStart + state.lineIndent = _lineIndent + break } } if (hasPendingContent) { - captureSegment(state, captureStart, captureEnd, false); - writeFoldedLines(state, state.line - _line); - captureStart = captureEnd = state.position; - hasPendingContent = false; + captureSegment(state, captureStart, captureEnd, false) + writeFoldedLines(state, state.line - _line) + captureStart = captureEnd = state.position + hasPendingContent = false } if (!is_WHITE_SPACE(ch)) { - captureEnd = state.position + 1; + captureEnd = state.position + 1 } - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } - captureSegment(state, captureStart, captureEnd, false); + captureSegment(state, captureStart, captureEnd, false) if (state.result) { - return true; + return true } - state.kind = _kind; - state.result = _result; - return false; + state.kind = _kind + state.result = _result + return false } -function readSingleQuotedScalar(state, nodeIndent) { - var ch, - captureStart, captureEnd; +function readSingleQuotedScalar (state, nodeIndent) { + let captureStart + let captureEnd - ch = state.input.charCodeAt(state.position); + let ch = state.input.charCodeAt(state.position) if (ch !== 0x27/* ' */) { - return false; + return false } - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; + state.kind = 'scalar' + state.result = '' + state.position++ + captureStart = captureEnd = state.position while ((ch = state.input.charCodeAt(state.position)) !== 0) { if (ch === 0x27/* ' */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); + captureSegment(state, captureStart, state.position, true) + ch = state.input.charCodeAt(++state.position) if (ch === 0x27/* ' */) { - captureStart = state.position; - state.position++; - captureEnd = state.position; + captureStart = state.position + state.position++ + captureEnd = state.position } else { - return true; + return true } - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - + captureSegment(state, captureStart, captureEnd, true) + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)) + captureStart = captureEnd = state.position } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a single quoted scalar'); - + throwError(state, 'unexpected end of the document within a single quoted scalar') } else { - state.position++; - captureEnd = state.position; + state.position++ + captureEnd = state.position } } - throwError(state, 'unexpected end of the stream within a single quoted scalar'); + throwError(state, 'unexpected end of the stream within a single quoted scalar') } -function readDoubleQuotedScalar(state, nodeIndent) { - var captureStart, - captureEnd, - hexLength, - hexResult, - tmp, - ch; +function readDoubleQuotedScalar (state, nodeIndent) { + let captureStart + let captureEnd + let tmp - ch = state.input.charCodeAt(state.position); + let ch = state.input.charCodeAt(state.position) if (ch !== 0x22/* " */) { - return false; + return false } - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; + state.kind = 'scalar' + state.result = '' + state.position++ + captureStart = captureEnd = state.position while ((ch = state.input.charCodeAt(state.position)) !== 0) { if (ch === 0x22/* " */) { - captureSegment(state, captureStart, state.position, true); - state.position++; - return true; - + captureSegment(state, captureStart, state.position, true) + state.position++ + return true } else if (ch === 0x5C/* \ */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); + captureSegment(state, captureStart, state.position, true) + ch = state.input.charCodeAt(++state.position) if (is_EOL(ch)) { - skipSeparationSpace(state, false, nodeIndent); + skipSeparationSpace(state, false, nodeIndent) // TODO: rework to inline fn with no type cast? } else if (ch < 256 && simpleEscapeCheck[ch]) { - state.result += simpleEscapeMap[ch]; - state.position++; - + state.result += simpleEscapeMap[ch] + state.position++ } else if ((tmp = escapedHexLen(ch)) > 0) { - hexLength = tmp; - hexResult = 0; + let hexLength = tmp + let hexResult = 0 for (; hexLength > 0; hexLength--) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) if ((tmp = fromHexCode(ch)) >= 0) { - hexResult = (hexResult << 4) + tmp; - + hexResult = (hexResult << 4) + tmp } else { - throwError(state, 'expected hexadecimal character'); + throwError(state, 'expected hexadecimal character') } } - state.result += charFromCodepoint(hexResult); - - state.position++; + state.result += charFromCodepoint(hexResult) + state.position++ } else { - throwError(state, 'unknown escape sequence'); + throwError(state, 'unknown escape sequence') } - captureStart = captureEnd = state.position; - + captureStart = captureEnd = state.position } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - + captureSegment(state, captureStart, captureEnd, true) + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)) + captureStart = captureEnd = state.position } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a double quoted scalar'); - + throwError(state, 'unexpected end of the document within a double quoted scalar') } else { - state.position++; - captureEnd = state.position; + state.position++ + captureEnd = state.position } } - throwError(state, 'unexpected end of the stream within a double quoted scalar'); + throwError(state, 'unexpected end of the stream within a double quoted scalar') } -function readFlowCollection(state, nodeIndent) { - var readNext = true, - _line, - _lineStart, - _pos, - _tag = state.tag, - _result, - _anchor = state.anchor, - following, - terminator, - isPair, - isExplicitPair, - isMapping, - overridableKeys = Object.create(null), - keyNode, - keyTag, - valueNode, - ch; - - ch = state.input.charCodeAt(state.position); +function readFlowCollection (state, nodeIndent) { + let readNext = true + let _line + let _lineStart + let _pos + const _tag = state.tag + let _result + const _anchor = state.anchor + let terminator + let isPair + let isExplicitPair + let isMapping + const overridableKeys = Object.create(null) + let keyNode + let keyTag + let valueNode + + let ch = state.input.charCodeAt(state.position) if (ch === 0x5B/* [ */) { - terminator = 0x5D;/* ] */ - isMapping = false; - _result = []; + terminator = 0x5D/* ] */ + isMapping = false + _result = [] } else if (ch === 0x7B/* { */) { - terminator = 0x7D;/* } */ - isMapping = true; - _result = {}; + terminator = 0x7D/* } */ + isMapping = true + _result = {} } else { - return false; + return false } if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; + state.anchorMap[state.anchor] = _result } - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) while (ch !== 0) { - skipSeparationSpace(state, true, nodeIndent); + skipSeparationSpace(state, true, nodeIndent) - ch = state.input.charCodeAt(state.position); + ch = state.input.charCodeAt(state.position) if (ch === terminator) { - state.position++; - state.tag = _tag; - state.anchor = _anchor; - state.kind = isMapping ? 'mapping' : 'sequence'; - state.result = _result; - return true; + state.position++ + state.tag = _tag + state.anchor = _anchor + state.kind = isMapping ? 'mapping' : 'sequence' + state.result = _result + return true } else if (!readNext) { - throwError(state, 'missed comma between flow collection entries'); + throwError(state, 'missed comma between flow collection entries') } else if (ch === 0x2C/* , */) { // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 - throwError(state, "expected the node content, but found ','"); + throwError(state, "expected the node content, but found ','") } - keyTag = keyNode = valueNode = null; - isPair = isExplicitPair = false; + keyTag = keyNode = valueNode = null + isPair = isExplicitPair = false if (ch === 0x3F/* ? */) { - following = state.input.charCodeAt(state.position + 1); + const following = state.input.charCodeAt(state.position + 1) if (is_WS_OR_EOL(following)) { - isPair = isExplicitPair = true; - state.position++; - skipSeparationSpace(state, true, nodeIndent); + isPair = isExplicitPair = true + state.position++ + skipSeparationSpace(state, true, nodeIndent) } } - _line = state.line; // Save the current line. - _lineStart = state.lineStart; - _pos = state.position; - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - keyTag = state.tag; - keyNode = state.result; - skipSeparationSpace(state, true, nodeIndent); + _line = state.line // Save the current line. + _lineStart = state.lineStart + _pos = state.position + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true) + keyTag = state.tag + keyNode = state.result + skipSeparationSpace(state, true, nodeIndent) - ch = state.input.charCodeAt(state.position); + ch = state.input.charCodeAt(state.position) if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { - isPair = true; - ch = state.input.charCodeAt(++state.position); - skipSeparationSpace(state, true, nodeIndent); - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - valueNode = state.result; + isPair = true + ch = state.input.charCodeAt(++state.position) + skipSeparationSpace(state, true, nodeIndent) + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true) + valueNode = state.result } if (isMapping) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos) } else if (isPair) { - _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)) } else { - _result.push(keyNode); + _result.push(keyNode) } - skipSeparationSpace(state, true, nodeIndent); + skipSeparationSpace(state, true, nodeIndent) - ch = state.input.charCodeAt(state.position); + ch = state.input.charCodeAt(state.position) if (ch === 0x2C/* , */) { - readNext = true; - ch = state.input.charCodeAt(++state.position); + readNext = true + ch = state.input.charCodeAt(++state.position) } else { - readNext = false; + readNext = false } } - throwError(state, 'unexpected end of the stream within a flow collection'); + throwError(state, 'unexpected end of the stream within a flow collection') } -function readBlockScalar(state, nodeIndent) { - var captureStart, - folding, - chomping = CHOMPING_CLIP, - didReadContent = false, - detectedIndent = false, - textIndent = nodeIndent, - emptyLines = 0, - atMoreIndented = false, - tmp, - ch; +function readBlockScalar (state, nodeIndent) { + let folding + let chomping = CHOMPING_CLIP + let didReadContent = false + let detectedIndent = false + let textIndent = nodeIndent + let emptyLines = 0 + let atMoreIndented = false + let tmp - ch = state.input.charCodeAt(state.position); + let ch = state.input.charCodeAt(state.position) if (ch === 0x7C/* | */) { - folding = false; + folding = false } else if (ch === 0x3E/* > */) { - folding = true; + folding = true } else { - return false; + return false } - state.kind = 'scalar'; - state.result = ''; + state.kind = 'scalar' + state.result = '' while (ch !== 0) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { if (CHOMPING_CLIP === chomping) { - chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP } else { - throwError(state, 'repeat of a chomping mode identifier'); + throwError(state, 'repeat of a chomping mode identifier') } - } else if ((tmp = fromDecimalCode(ch)) >= 0) { if (tmp === 0) { - throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one') } else if (!detectedIndent) { - textIndent = nodeIndent + tmp - 1; - detectedIndent = true; + textIndent = nodeIndent + tmp - 1 + detectedIndent = true } else { - throwError(state, 'repeat of an indentation width identifier'); + throwError(state, 'repeat of an indentation width identifier') } - } else { - break; + break } } if (is_WHITE_SPACE(ch)) { - do { ch = state.input.charCodeAt(++state.position); } - while (is_WHITE_SPACE(ch)); + do { ch = state.input.charCodeAt(++state.position) } + while (is_WHITE_SPACE(ch)) if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (!is_EOL(ch) && (ch !== 0)); + do { ch = state.input.charCodeAt(++state.position) } + while (!is_EOL(ch) && (ch !== 0)) } } while (ch !== 0) { - readLineBreak(state); - state.lineIndent = 0; + readLineBreak(state) + state.lineIndent = 0 - ch = state.input.charCodeAt(state.position); + ch = state.input.charCodeAt(state.position) + // eslint-disable-next-line no-unmodified-loop-condition while ((!detectedIndent || state.lineIndent < textIndent) && (ch === 0x20/* Space */)) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); + state.lineIndent++ + ch = state.input.charCodeAt(++state.position) } if (!detectedIndent && state.lineIndent > textIndent) { - textIndent = state.lineIndent; + textIndent = state.lineIndent } if (is_EOL(ch)) { - emptyLines++; - continue; + emptyLines++ + continue } // End of the scalar. if (state.lineIndent < textIndent) { - // Perform the chomping. if (chomping === CHOMPING_KEEP) { - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) } else if (chomping === CHOMPING_CLIP) { if (didReadContent) { // i.e. only if the scalar is not empty. - state.result += '\n'; + state.result += '\n' } } // Break this `while` cycle and go to the funciton's epilogue. - break; + break } // Folded style: use fancy rules to handle line breaks. if (folding) { - // Lines starting with white space characters (more-indented lines) are not folded. if (is_WHITE_SPACE(ch)) { - atMoreIndented = true; + atMoreIndented = true // except for the first content line (cf. Example 8.1) - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) // End of more-indented block. } else if (atMoreIndented) { - atMoreIndented = false; - state.result += common.repeat('\n', emptyLines + 1); + atMoreIndented = false + state.result += common.repeat('\n', emptyLines + 1) // Just one line break - perceive as the same line. } else if (emptyLines === 0) { if (didReadContent) { // i.e. only if we have already read some scalar content. - state.result += ' '; + state.result += ' ' } // Several line breaks - perceive as different lines. } else { - state.result += common.repeat('\n', emptyLines); + state.result += common.repeat('\n', emptyLines) } // Literal style: just add exact number of line breaks between content lines. } else { // Keep all line breaks except the header line break. - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) } - didReadContent = true; - detectedIndent = true; - emptyLines = 0; - captureStart = state.position; + didReadContent = true + detectedIndent = true + emptyLines = 0 + const captureStart = state.position while (!is_EOL(ch) && (ch !== 0)) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } - captureSegment(state, captureStart, state.position, false); + captureSegment(state, captureStart, state.position, false) } - return true; + return true } -function readBlockSequence(state, nodeIndent) { - var _line, - _tag = state.tag, - _anchor = state.anchor, - _result = [], - following, - detected = false, - ch; +function readBlockSequence (state, nodeIndent) { + const _tag = state.tag + const _anchor = state.anchor + const _result = [] + let detected = false // there is a leading tab before this token, so it can't be a block sequence/mapping; // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; + if (state.firstTabInLine !== -1) return false if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; + state.anchorMap[state.anchor] = _result } - ch = state.input.charCodeAt(state.position); + let ch = state.input.charCodeAt(state.position) while (ch !== 0) { if (state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); + state.position = state.firstTabInLine + throwError(state, 'tab characters must not be used in indentation') } if (ch !== 0x2D/* - */) { - break; + break } - following = state.input.charCodeAt(state.position + 1); + const following = state.input.charCodeAt(state.position + 1) if (!is_WS_OR_EOL(following)) { - break; + break } - detected = true; - state.position++; + detected = true + state.position++ if (skipSeparationSpace(state, true, -1)) { if (state.lineIndent <= nodeIndent) { - _result.push(null); - ch = state.input.charCodeAt(state.position); - continue; + _result.push(null) + ch = state.input.charCodeAt(state.position) + continue } } - _line = state.line; - composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); - _result.push(state.result); - skipSeparationSpace(state, true, -1); + const _line = state.line + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true) + _result.push(state.result) + skipSeparationSpace(state, true, -1) - ch = state.input.charCodeAt(state.position); + ch = state.input.charCodeAt(state.position) if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a sequence entry'); + throwError(state, 'bad indentation of a sequence entry') } else if (state.lineIndent < nodeIndent) { - break; + break } } if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'sequence'; - state.result = _result; - return true; + state.tag = _tag + state.anchor = _anchor + state.kind = 'sequence' + state.result = _result + return true } - return false; + return false } -function readBlockMapping(state, nodeIndent, flowIndent) { - var following, - allowCompact, - _line, - _keyLine, - _keyLineStart, - _keyPos, - _tag = state.tag, - _anchor = state.anchor, - _result = {}, - overridableKeys = Object.create(null), - keyTag = null, - keyNode = null, - valueNode = null, - atExplicitKey = false, - detected = false, - ch; +function readBlockMapping (state, nodeIndent, flowIndent) { + let allowCompact + let _keyLine + let _keyLineStart + let _keyPos + const _tag = state.tag + const _anchor = state.anchor + const _result = {} + const overridableKeys = Object.create(null) + let keyTag = null + let keyNode = null + let valueNode = null + let atExplicitKey = false + let detected = false // there is a leading tab before this token, so it can't be a block sequence/mapping; // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; + if (state.firstTabInLine !== -1) return false if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; + state.anchorMap[state.anchor] = _result } - ch = state.input.charCodeAt(state.position); + let ch = state.input.charCodeAt(state.position) while (ch !== 0) { if (!atExplicitKey && state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); + state.position = state.firstTabInLine + throwError(state, 'tab characters must not be used in indentation') } - following = state.input.charCodeAt(state.position + 1); - _line = state.line; // Save the current line. + const following = state.input.charCodeAt(state.position + 1) + const _line = state.line // Save the current line. // // Explicit notation case. There are two separate blocks: // first for the key (denoted by "?") and second for the value (denoted by ":") // if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { - if (ch === 0x3F/* ? */) { if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) + keyTag = keyNode = valueNode = null } - detected = true; - atExplicitKey = true; - allowCompact = true; - + detected = true + atExplicitKey = true + allowCompact = true } else if (atExplicitKey) { // i.e. 0x3A/* : */ === character after the explicit key. - atExplicitKey = false; - allowCompact = true; - + atExplicitKey = false + allowCompact = true } else { - throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line') } - state.position += 1; - ch = following; + state.position += 1 + ch = following // // Implicit notation case. Flow-style node as the key first, then ":", and the value. // } else { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; + _keyLine = state.line + _keyLineStart = state.lineStart + _keyPos = state.position if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { // Neither implicit nor explicit notation. // Reading is done. Go to the epilogue. - break; + break } if (state.line === _line) { - ch = state.input.charCodeAt(state.position); + ch = state.input.charCodeAt(state.position) while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } if (ch === 0x3A/* : */) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) if (!is_WS_OR_EOL(ch)) { - throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping') } if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) + keyTag = keyNode = valueNode = null } - detected = true; - atExplicitKey = false; - allowCompact = false; - keyTag = state.tag; - keyNode = state.result; - + detected = true + atExplicitKey = false + allowCompact = false + keyTag = state.tag + keyNode = state.result } else if (detected) { - throwError(state, 'can not read an implicit mapping pair; a colon is missed'); - + throwError(state, 'can not read an implicit mapping pair; a colon is missed') } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. + state.tag = _tag + state.anchor = _anchor + return true // Keep the result of `composeNode`. } - } else if (detected) { - throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); - + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key') } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. + state.tag = _tag + state.anchor = _anchor + return true // Keep the result of `composeNode`. } } @@ -1162,32 +1093,32 @@ function readBlockMapping(state, nodeIndent, flowIndent) { // if (state.line === _line || state.lineIndent > nodeIndent) { if (atExplicitKey) { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; + _keyLine = state.line + _keyLineStart = state.lineStart + _keyPos = state.position } if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { if (atExplicitKey) { - keyNode = state.result; + keyNode = state.result } else { - valueNode = state.result; + valueNode = state.result } } if (!atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos) + keyTag = keyNode = valueNode = null } - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); + skipSeparationSpace(state, true, -1) + ch = state.input.charCodeAt(state.position) } if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a mapping entry'); + throwError(state, 'bad indentation of a mapping entry') } else if (state.lineIndent < nodeIndent) { - break; + break } } @@ -1197,214 +1128,195 @@ function readBlockMapping(state, nodeIndent, flowIndent) { // Special case: last mapping's node contains only the key in explicit notation. if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) } // Expose the resulting mapping. if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'mapping'; - state.result = _result; + state.tag = _tag + state.anchor = _anchor + state.kind = 'mapping' + state.result = _result } - return detected; + return detected } -function readTagProperty(state) { - var _position, - isVerbatim = false, - isNamed = false, - tagHandle, - tagName, - ch; +function readTagProperty (state) { + let isVerbatim = false + let isNamed = false + let tagHandle + let tagName - ch = state.input.charCodeAt(state.position); + let ch = state.input.charCodeAt(state.position) - if (ch !== 0x21/* ! */) return false; + if (ch !== 0x21/* ! */) return false if (state.tag !== null) { - throwError(state, 'duplication of a tag property'); + throwError(state, 'duplication of a tag property') } - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) if (ch === 0x3C/* < */) { - isVerbatim = true; - ch = state.input.charCodeAt(++state.position); - + isVerbatim = true + ch = state.input.charCodeAt(++state.position) } else if (ch === 0x21/* ! */) { - isNamed = true; - tagHandle = '!!'; - ch = state.input.charCodeAt(++state.position); - + isNamed = true + tagHandle = '!!' + ch = state.input.charCodeAt(++state.position) } else { - tagHandle = '!'; + tagHandle = '!' } - _position = state.position; + let _position = state.position if (isVerbatim) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && ch !== 0x3E/* > */); + do { ch = state.input.charCodeAt(++state.position) } + while (ch !== 0 && ch !== 0x3E/* > */) if (state.position < state.length) { - tagName = state.input.slice(_position, state.position); - ch = state.input.charCodeAt(++state.position); + tagName = state.input.slice(_position, state.position) + ch = state.input.charCodeAt(++state.position) } else { - throwError(state, 'unexpected end of the stream within a verbatim tag'); + throwError(state, 'unexpected end of the stream within a verbatim tag') } } else { while (ch !== 0 && !is_WS_OR_EOL(ch)) { - if (ch === 0x21/* ! */) { if (!isNamed) { - tagHandle = state.input.slice(_position - 1, state.position + 1); + tagHandle = state.input.slice(_position - 1, state.position + 1) if (!PATTERN_TAG_HANDLE.test(tagHandle)) { - throwError(state, 'named tag handle cannot contain such characters'); + throwError(state, 'named tag handle cannot contain such characters') } - isNamed = true; - _position = state.position + 1; + isNamed = true + _position = state.position + 1 } else { - throwError(state, 'tag suffix cannot contain exclamation marks'); + throwError(state, 'tag suffix cannot contain exclamation marks') } } - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } - tagName = state.input.slice(_position, state.position); + tagName = state.input.slice(_position, state.position) if (PATTERN_FLOW_INDICATORS.test(tagName)) { - throwError(state, 'tag suffix cannot contain flow indicator characters'); + throwError(state, 'tag suffix cannot contain flow indicator characters') } } if (tagName && !PATTERN_TAG_URI.test(tagName)) { - throwError(state, 'tag name cannot contain such characters: ' + tagName); + throwError(state, 'tag name cannot contain such characters: ' + tagName) } try { - tagName = decodeURIComponent(tagName); + tagName = decodeURIComponent(tagName) } catch (err) { - throwError(state, 'tag name is malformed: ' + tagName); + throwError(state, 'tag name is malformed: ' + tagName) } if (isVerbatim) { - state.tag = tagName; - + state.tag = tagName } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { - state.tag = state.tagMap[tagHandle] + tagName; - + state.tag = state.tagMap[tagHandle] + tagName } else if (tagHandle === '!') { - state.tag = '!' + tagName; - + state.tag = '!' + tagName } else if (tagHandle === '!!') { - state.tag = 'tag:yaml.org,2002:' + tagName; - + state.tag = 'tag:yaml.org,2002:' + tagName } else { - throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + throwError(state, 'undeclared tag handle "' + tagHandle + '"') } - return true; + return true } -function readAnchorProperty(state) { - var _position, - ch; - - ch = state.input.charCodeAt(state.position); +function readAnchorProperty (state) { + let ch = state.input.charCodeAt(state.position) - if (ch !== 0x26/* & */) return false; + if (ch !== 0x26/* & */) return false if (state.anchor !== null) { - throwError(state, 'duplication of an anchor property'); + throwError(state, 'duplication of an anchor property') } - ch = state.input.charCodeAt(++state.position); - _position = state.position; + ch = state.input.charCodeAt(++state.position) + const _position = state.position while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } if (state.position === _position) { - throwError(state, 'name of an anchor node must contain at least one character'); + throwError(state, 'name of an anchor node must contain at least one character') } - state.anchor = state.input.slice(_position, state.position); - return true; + state.anchor = state.input.slice(_position, state.position) + return true } -function readAlias(state) { - var _position, alias, - ch; +function readAlias (state) { + let ch = state.input.charCodeAt(state.position) - ch = state.input.charCodeAt(state.position); + if (ch !== 0x2A/* * */) return false - if (ch !== 0x2A/* * */) return false; - - ch = state.input.charCodeAt(++state.position); - _position = state.position; + ch = state.input.charCodeAt(++state.position) + const _position = state.position while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } if (state.position === _position) { - throwError(state, 'name of an alias node must contain at least one character'); + throwError(state, 'name of an alias node must contain at least one character') } - alias = state.input.slice(_position, state.position); + const alias = state.input.slice(_position, state.position) if (!_hasOwnProperty.call(state.anchorMap, alias)) { - throwError(state, 'unidentified alias "' + alias + '"'); + throwError(state, 'unidentified alias "' + alias + '"') } - state.result = state.anchorMap[alias]; - skipSeparationSpace(state, true, -1); - return true; + state.result = state.anchorMap[alias] + skipSeparationSpace(state, true, -1) + return true } -function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { - var allowBlockStyles, - allowBlockScalars, - allowBlockCollections, - indentStatus = 1, // 1: this>parent, 0: this=parent, -1: thisparent, 0: this=parent, -1: this parentIndent) { - indentStatus = 1; + indentStatus = 1 } else if (state.lineIndent === parentIndent) { - indentStatus = 0; + indentStatus = 0 } else if (state.lineIndent < parentIndent) { - indentStatus = -1; + indentStatus = -1 } } } @@ -1412,78 +1324,74 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact if (indentStatus === 1) { while (readTagProperty(state) || readAnchorProperty(state)) { if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; - allowBlockCollections = allowBlockStyles; + atNewLine = true + allowBlockCollections = allowBlockStyles if (state.lineIndent > parentIndent) { - indentStatus = 1; + indentStatus = 1 } else if (state.lineIndent === parentIndent) { - indentStatus = 0; + indentStatus = 0 } else if (state.lineIndent < parentIndent) { - indentStatus = -1; + indentStatus = -1 } } else { - allowBlockCollections = false; + allowBlockCollections = false } } } if (allowBlockCollections) { - allowBlockCollections = atNewLine || allowCompact; + allowBlockCollections = atNewLine || allowCompact } if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { - flowIndent = parentIndent; + flowIndent = parentIndent } else { - flowIndent = parentIndent + 1; + flowIndent = parentIndent + 1 } - blockIndent = state.position - state.lineStart; + blockIndent = state.position - state.lineStart if (indentStatus === 1) { - if (allowBlockCollections && - (readBlockSequence(state, blockIndent) || - readBlockMapping(state, blockIndent, flowIndent)) || + if ((allowBlockCollections && + (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent))) || readFlowCollection(state, flowIndent)) { - hasContent = true; + hasContent = true } else { if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) { - hasContent = true; - + hasContent = true } else if (readAlias(state)) { - hasContent = true; + hasContent = true if (state.tag !== null || state.anchor !== null) { - throwError(state, 'alias node should not have any properties'); + throwError(state, 'alias node should not have any properties') } - } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { - hasContent = true; + hasContent = true if (state.tag === null) { - state.tag = '?'; + state.tag = '?' } } if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + state.anchorMap[state.anchor] = state.result } } } else if (indentStatus === 0) { // Special case: block sequences are allowed to have same indentation level as the parent. // http://www.yaml.org/spec/1.2/spec.html#id2799784 - hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent) } } if (state.tag === null) { if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + state.anchorMap[state.anchor] = state.result } - } else if (state.tag === '?') { // Implicit resolving is not allowed for non-scalar types, and '?' // non-specific tag is only automatically assigned to plain scalars. @@ -1492,242 +1400,229 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact // tag, for example like this: "! [0]" // if (state.result !== null && state.kind !== 'scalar') { - throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"') } - for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { - type = state.implicitTypes[typeIndex]; + for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex] if (type.resolve(state.result)) { // `state.result` updated in resolver if matched - state.result = type.construct(state.result); - state.tag = type.tag; + state.result = type.construct(state.result) + state.tag = type.tag if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + state.anchorMap[state.anchor] = state.result } - break; + break } } } else if (state.tag !== '!') { if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { - type = state.typeMap[state.kind || 'fallback'][state.tag]; + type = state.typeMap[state.kind || 'fallback'][state.tag] } else { // looking for multi type - type = null; - typeList = state.typeMap.multi[state.kind || 'fallback']; + type = null + const typeList = state.typeMap.multi[state.kind || 'fallback'] - for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { - type = typeList[typeIndex]; - break; + type = typeList[typeIndex] + break } } } if (!type) { - throwError(state, 'unknown tag !<' + state.tag + '>'); + throwError(state, 'unknown tag !<' + state.tag + '>') } if (state.result !== null && type.kind !== state.kind) { - throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"') } if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched - throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag') } else { - state.result = type.construct(state.result, state.tag); + state.result = type.construct(state.result, state.tag) if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + state.anchorMap[state.anchor] = state.result } } } if (state.listener !== null) { - state.listener('close', state); + state.listener('close', state) } - return state.tag !== null || state.anchor !== null || hasContent; + return state.tag !== null || state.anchor !== null || hasContent } -function readDocument(state) { - var documentStart = state.position, - _position, - directiveName, - directiveArgs, - hasDirectives = false, - ch; +function readDocument (state) { + const documentStart = state.position + let hasDirectives = false + let ch - state.version = null; - state.checkLineBreaks = state.legacy; - state.tagMap = Object.create(null); - state.anchorMap = Object.create(null); + state.version = null + state.checkLineBreaks = state.legacy + state.tagMap = Object.create(null) + state.anchorMap = Object.create(null) while ((ch = state.input.charCodeAt(state.position)) !== 0) { - skipSeparationSpace(state, true, -1); + skipSeparationSpace(state, true, -1) - ch = state.input.charCodeAt(state.position); + ch = state.input.charCodeAt(state.position) if (state.lineIndent > 0 || ch !== 0x25/* % */) { - break; + break } - hasDirectives = true; - ch = state.input.charCodeAt(++state.position); - _position = state.position; + hasDirectives = true + ch = state.input.charCodeAt(++state.position) + let _position = state.position while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } - directiveName = state.input.slice(_position, state.position); - directiveArgs = []; + const directiveName = state.input.slice(_position, state.position) + const directiveArgs = [] if (directiveName.length < 1) { - throwError(state, 'directive name must not be less than one character in length'); + throwError(state, 'directive name must not be less than one character in length') } while (ch !== 0) { while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && !is_EOL(ch)); - break; + do { ch = state.input.charCodeAt(++state.position) } + while (ch !== 0 && !is_EOL(ch)) + break } - if (is_EOL(ch)) break; + if (is_EOL(ch)) break - _position = state.position; + _position = state.position while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); + ch = state.input.charCodeAt(++state.position) } - directiveArgs.push(state.input.slice(_position, state.position)); + directiveArgs.push(state.input.slice(_position, state.position)) } - if (ch !== 0) readLineBreak(state); + if (ch !== 0) readLineBreak(state) if (_hasOwnProperty.call(directiveHandlers, directiveName)) { - directiveHandlers[directiveName](state, directiveName, directiveArgs); + directiveHandlers[directiveName](state, directiveName, directiveArgs) } else { - throwWarning(state, 'unknown document directive "' + directiveName + '"'); + throwWarning(state, 'unknown document directive "' + directiveName + '"') } } - skipSeparationSpace(state, true, -1); + skipSeparationSpace(state, true, -1) if (state.lineIndent === 0 && - state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position) === 0x2D/* - */ && state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - + state.position += 3 + skipSeparationSpace(state, true, -1) } else if (hasDirectives) { - throwError(state, 'directives end mark is expected'); + throwError(state, 'directives end mark is expected') } - composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); - skipSeparationSpace(state, true, -1); + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true) + skipSeparationSpace(state, true, -1) if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { - throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + throwWarning(state, 'non-ASCII line breaks are interpreted as content') } - state.documents.push(state.result); + state.documents.push(state.result) if (state.position === state.lineStart && testDocumentSeparator(state)) { - if (state.input.charCodeAt(state.position) === 0x2E/* . */) { - state.position += 3; - skipSeparationSpace(state, true, -1); + state.position += 3 + skipSeparationSpace(state, true, -1) } - return; + return } if (state.position < (state.length - 1)) { - throwError(state, 'end of the stream or a document separator is expected'); - } else { - return; + throwError(state, 'end of the stream or a document separator is expected') } } - -function loadDocuments(input, options) { - input = String(input); - options = options || {}; +function loadDocuments (input, options) { + input = String(input) + options = options || {} if (input.length !== 0) { - // Add tailing `\n` if not exists if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { - input += '\n'; + input += '\n' } // Strip BOM if (input.charCodeAt(0) === 0xFEFF) { - input = input.slice(1); + input = input.slice(1) } } - var state = new State(input, options); + const state = new State(input, options) - var nullpos = input.indexOf('\0'); + const nullpos = input.indexOf('\0') if (nullpos !== -1) { - state.position = nullpos; - throwError(state, 'null byte is not allowed in input'); + state.position = nullpos + throwError(state, 'null byte is not allowed in input') } // Use 0 as string terminator. That significantly simplifies bounds check. - state.input += '\0'; + state.input += '\0' while (state.input.charCodeAt(state.position) === 0x20/* Space */) { - state.lineIndent += 1; - state.position += 1; + state.lineIndent += 1 + state.position += 1 } while (state.position < (state.length - 1)) { - readDocument(state); + readDocument(state) } - return state.documents; + return state.documents } - -function loadAll(input, iterator, options) { +function loadAll (input, iterator, options) { if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { - options = iterator; - iterator = null; + options = iterator + iterator = null } - var documents = loadDocuments(input, options); + const documents = loadDocuments(input, options) if (typeof iterator !== 'function') { - return documents; + return documents } - for (var index = 0, length = documents.length; index < length; index += 1) { - iterator(documents[index]); + for (let index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]) } } - -function load(input, options) { - var documents = loadDocuments(input, options); +function load (input, options) { + const documents = loadDocuments(input, options) if (documents.length === 0) { - /*eslint-disable no-undefined*/ - return undefined; + return undefined } else if (documents.length === 1) { - return documents[0]; + return documents[0] } - throw new YAMLException('expected a single document in the stream, but found more'); + throw new YAMLException('expected a single document in the stream, but found more') } - -module.exports.loadAll = loadAll; -module.exports.load = load; +module.exports.loadAll = loadAll +module.exports.load = load diff --git a/lib/schema.js b/lib/schema.js index 65b41f40..52e8f41e 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -1,121 +1,109 @@ -'use strict'; +'use strict' -/*eslint-disable max-len*/ +const YAMLException = require('./exception') +const Type = require('./type') -var YAMLException = require('./exception'); -var Type = require('./type'); - - -function compileList(schema, name) { - var result = []; +function compileList (schema, name) { + const result = [] schema[name].forEach(function (currentType) { - var newIndex = result.length; + let newIndex = result.length result.forEach(function (previousType, previousIndex) { if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { - - newIndex = previousIndex; + newIndex = previousIndex } - }); + }) - result[newIndex] = currentType; - }); + result[newIndex] = currentType + }) - return result; + return result } - -function compileMap(/* lists... */) { - var result = { - scalar: {}, - sequence: {}, - mapping: {}, - fallback: {}, - multi: { - scalar: [], - sequence: [], - mapping: [], - fallback: [] - } - }, index, length; - - function collectType(type) { +function compileMap (/* lists... */) { + const result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + } + function collectType (type) { if (type.multi) { - result.multi[type.kind].push(type); - result.multi['fallback'].push(type); + result.multi[type.kind].push(type) + result.multi['fallback'].push(type) } else { - result[type.kind][type.tag] = result['fallback'][type.tag] = type; + result[type.kind][type.tag] = result['fallback'][type.tag] = type } } - for (index = 0, length = arguments.length; index < length; index += 1) { - arguments[index].forEach(collectType); + for (let index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType) } - return result; + return result } - -function Schema(definition) { - return this.extend(definition); +function Schema (definition) { + return this.extend(definition) } - -Schema.prototype.extend = function extend(definition) { - var implicit = []; - var explicit = []; +Schema.prototype.extend = function extend (definition) { + let implicit = [] + let explicit = [] if (definition instanceof Type) { // Schema.extend(type) - explicit.push(definition); - + explicit.push(definition) } else if (Array.isArray(definition)) { // Schema.extend([ type1, type2, ... ]) - explicit = explicit.concat(definition); - + explicit = explicit.concat(definition) } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) - if (definition.implicit) implicit = implicit.concat(definition.implicit); - if (definition.explicit) explicit = explicit.concat(definition.explicit); - + if (definition.implicit) implicit = implicit.concat(definition.implicit) + if (definition.explicit) explicit = explicit.concat(definition.explicit) } else { throw new YAMLException('Schema.extend argument should be a Type, [ Type ], ' + - 'or a schema definition ({ implicit: [...], explicit: [...] })'); + 'or a schema definition ({ implicit: [...], explicit: [...] })') } implicit.forEach(function (type) { if (!(type instanceof Type)) { - throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.') } if (type.loadKind && type.loadKind !== 'scalar') { - throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.') } if (type.multi) { - throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); + throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.') } - }); + }) explicit.forEach(function (type) { if (!(type instanceof Type)) { - throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.') } - }); - - var result = Object.create(Schema.prototype); + }) - result.implicit = (this.implicit || []).concat(implicit); - result.explicit = (this.explicit || []).concat(explicit); + const result = Object.create(Schema.prototype) - result.compiledImplicit = compileList(result, 'implicit'); - result.compiledExplicit = compileList(result, 'explicit'); - result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + result.implicit = (this.implicit || []).concat(implicit) + result.explicit = (this.explicit || []).concat(explicit) - return result; -}; + result.compiledImplicit = compileList(result, 'implicit') + result.compiledExplicit = compileList(result, 'explicit') + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit) + return result +} -module.exports = Schema; +module.exports = Schema diff --git a/lib/schema/core.js b/lib/schema/core.js index 608b26de..2660239d 100644 --- a/lib/schema/core.js +++ b/lib/schema/core.js @@ -4,8 +4,6 @@ // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. // So, Core schema has no distinctions from JSON schema is JS-YAML. +'use strict' -'use strict'; - - -module.exports = require('./json'); +module.exports = require('./json') diff --git a/lib/schema/default.js b/lib/schema/default.js index 3af0520d..fb232d6d 100644 --- a/lib/schema/default.js +++ b/lib/schema/default.js @@ -4,9 +4,7 @@ // This schema is based on standard YAML's Core schema and includes most of // extra types described at YAML tag repository. (http://yaml.org/type/) - -'use strict'; - +'use strict' module.exports = require('./core').extend({ implicit: [ @@ -19,4 +17,4 @@ module.exports = require('./core').extend({ require('../type/pairs'), require('../type/set') ] -}); +}) diff --git a/lib/schema/failsafe.js b/lib/schema/failsafe.js index b7a33eb7..ee63fe03 100644 --- a/lib/schema/failsafe.js +++ b/lib/schema/failsafe.js @@ -1,12 +1,9 @@ // Standard YAML's Failsafe schema. // http://www.yaml.org/spec/1.2/spec.html#id2802346 +'use strict' -'use strict'; - - -var Schema = require('../schema'); - +const Schema = require('../schema') module.exports = new Schema({ explicit: [ @@ -14,4 +11,4 @@ module.exports = new Schema({ require('../type/seq'), require('../type/map') ] -}); +}) diff --git a/lib/schema/json.js b/lib/schema/json.js index b73df78e..ac75fa2b 100644 --- a/lib/schema/json.js +++ b/lib/schema/json.js @@ -5,9 +5,7 @@ // So, this schema is not such strict as defined in the YAML specification. // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. - -'use strict'; - +'use strict' module.exports = require('./failsafe').extend({ implicit: [ @@ -16,4 +14,4 @@ module.exports = require('./failsafe').extend({ require('../type/int'), require('../type/float') ] -}); +}) diff --git a/lib/snippet.js b/lib/snippet.js index 00e2133c..71004a4d 100644 --- a/lib/snippet.js +++ b/lib/snippet.js @@ -1,101 +1,96 @@ -'use strict'; - - -var common = require('./common'); +'use strict' +const common = require('./common') // get snippet for a single line, respecting maxLength -function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { - var head = ''; - var tail = ''; - var maxHalfLength = Math.floor(maxLineLength / 2) - 1; +function getLine (buffer, lineStart, lineEnd, position, maxLineLength) { + let head = '' + let tail = '' + const maxHalfLength = Math.floor(maxLineLength / 2) - 1 if (position - lineStart > maxHalfLength) { - head = ' ... '; - lineStart = position - maxHalfLength + head.length; + head = ' ... ' + lineStart = position - maxHalfLength + head.length } if (lineEnd - position > maxHalfLength) { - tail = ' ...'; - lineEnd = position + maxHalfLength - tail.length; + tail = ' ...' + lineEnd = position + maxHalfLength - tail.length } return { str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, pos: position - lineStart + head.length // relative position - }; + } } - -function padStart(string, max) { - return common.repeat(' ', max - string.length) + string; +function padStart (string, max) { + return common.repeat(' ', max - string.length) + string } +function makeSnippet (mark, options) { + options = Object.create(options || null) -function makeSnippet(mark, options) { - options = Object.create(options || null); - - if (!mark.buffer) return null; + if (!mark.buffer) return null - if (!options.maxLength) options.maxLength = 79; - if (typeof options.indent !== 'number') options.indent = 1; - if (typeof options.linesBefore !== 'number') options.linesBefore = 3; - if (typeof options.linesAfter !== 'number') options.linesAfter = 2; + if (!options.maxLength) options.maxLength = 79 + if (typeof options.indent !== 'number') options.indent = 1 + if (typeof options.linesBefore !== 'number') options.linesBefore = 3 + if (typeof options.linesAfter !== 'number') options.linesAfter = 2 - var re = /\r?\n|\r|\0/g; - var lineStarts = [ 0 ]; - var lineEnds = []; - var match; - var foundLineNo = -1; + const re = /\r?\n|\r|\0/g + const lineStarts = [0] + const lineEnds = [] + let match + let foundLineNo = -1 while ((match = re.exec(mark.buffer))) { - lineEnds.push(match.index); - lineStarts.push(match.index + match[0].length); + lineEnds.push(match.index) + lineStarts.push(match.index + match[0].length) if (mark.position <= match.index && foundLineNo < 0) { - foundLineNo = lineStarts.length - 2; + foundLineNo = lineStarts.length - 2 } } - if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; + if (foundLineNo < 0) foundLineNo = lineStarts.length - 1 - var result = '', i, line; - var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; - var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + let result = '' + const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length + const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3) - for (i = 1; i <= options.linesBefore; i++) { - if (foundLineNo - i < 0) break; - line = getLine( + for (let i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) break + const line = getLine( mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength - ); + ) result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n' + result; + ' | ' + line.str + '\n' + result } - line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength) result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; - result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; + ' | ' + line.str + '\n' + result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n' - for (i = 1; i <= options.linesAfter; i++) { - if (foundLineNo + i >= lineEnds.length) break; - line = getLine( + for (let i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) break + const line = getLine( mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength - ); + ) result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; + ' | ' + line.str + '\n' } - return result.replace(/\n$/, ''); + return result.replace(/\n$/, '') } - -module.exports = makeSnippet; +module.exports = makeSnippet diff --git a/lib/type.js b/lib/type.js index 5e57877f..8ec3dbed 100644 --- a/lib/type.js +++ b/lib/type.js @@ -1,8 +1,8 @@ -'use strict'; +'use strict' -var YAMLException = require('./exception'); +const YAMLException = require('./exception') -var TYPE_CONSTRUCTOR_OPTIONS = [ +const TYPE_CONSTRUCTOR_OPTIONS = [ 'kind', 'multi', 'resolve', @@ -13,54 +13,54 @@ var TYPE_CONSTRUCTOR_OPTIONS = [ 'representName', 'defaultStyle', 'styleAliases' -]; +] -var YAML_NODE_KINDS = [ +const YAML_NODE_KINDS = [ 'scalar', 'sequence', 'mapping' -]; +] -function compileStyleAliases(map) { - var result = {}; +function compileStyleAliases (map) { + const result = {} if (map !== null) { Object.keys(map).forEach(function (style) { map[style].forEach(function (alias) { - result[String(alias)] = style; - }); - }); + result[String(alias)] = style + }) + }) } - return result; + return result } -function Type(tag, options) { - options = options || {}; +function Type (tag, options) { + options = options || {} Object.keys(options).forEach(function (name) { if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { - throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.') } - }); + }) // TODO: Add tag format check. - this.options = options; // keep original options in case user wants to extend this type later - this.tag = tag; - this.kind = options['kind'] || null; - this.resolve = options['resolve'] || function () { return true; }; - this.construct = options['construct'] || function (data) { return data; }; - this.instanceOf = options['instanceOf'] || null; - this.predicate = options['predicate'] || null; - this.represent = options['represent'] || null; - this.representName = options['representName'] || null; - this.defaultStyle = options['defaultStyle'] || null; - this.multi = options['multi'] || false; - this.styleAliases = compileStyleAliases(options['styleAliases'] || null); + this.options = options // keep original options in case user wants to extend this type later + this.tag = tag + this.kind = options['kind'] || null + this.resolve = options['resolve'] || function () { return true } + this.construct = options['construct'] || function (data) { return data } + this.instanceOf = options['instanceOf'] || null + this.predicate = options['predicate'] || null + this.represent = options['represent'] || null + this.representName = options['representName'] || null + this.defaultStyle = options['defaultStyle'] || null + this.multi = options['multi'] || false + this.styleAliases = compileStyleAliases(options['styleAliases'] || null) if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { - throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.') } } -module.exports = Type; +module.exports = Type diff --git a/lib/type/binary.js b/lib/type/binary.js index e1523513..dbe23004 100644 --- a/lib/type/binary.js +++ b/lib/type/binary.js @@ -1,119 +1,116 @@ -'use strict'; - -/*eslint-disable no-bitwise*/ - - -var Type = require('../type'); +'use strict' +const Type = require('../type') // [ 64, 65, 66 ] -> [ padding, CR, LF ] -var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; - +const BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r' -function resolveYamlBinary(data) { - if (data === null) return false; +function resolveYamlBinary (data) { + if (data === null) return false - var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; + let bitlen = 0 + const max = data.length + const map = BASE64_MAP // Convert one by one. - for (idx = 0; idx < max; idx++) { - code = map.indexOf(data.charAt(idx)); + for (let idx = 0; idx < max; idx++) { + const code = map.indexOf(data.charAt(idx)) // Skip CR/LF - if (code > 64) continue; + if (code > 64) continue // Fail on illegal characters - if (code < 0) return false; + if (code < 0) return false - bitlen += 6; + bitlen += 6 } // If there are any bits left, source was corrupted - return (bitlen % 8) === 0; + return (bitlen % 8) === 0 } -function constructYamlBinary(data) { - var idx, tailbits, - input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan - max = input.length, - map = BASE64_MAP, - bits = 0, - result = []; +function constructYamlBinary (data) { + const input = data.replace(/[\r\n=]/g, '') // remove CR/LF & padding to simplify scan + const max = input.length + const map = BASE64_MAP + let bits = 0 + const result = [] // Collect by 6*4 bits (3 bytes) - for (idx = 0; idx < max; idx++) { + for (let idx = 0; idx < max; idx++) { if ((idx % 4 === 0) && idx) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); + result.push((bits >> 16) & 0xFF) + result.push((bits >> 8) & 0xFF) + result.push(bits & 0xFF) } - bits = (bits << 6) | map.indexOf(input.charAt(idx)); + bits = (bits << 6) | map.indexOf(input.charAt(idx)) } // Dump tail - tailbits = (max % 4) * 6; + const tailbits = (max % 4) * 6 if (tailbits === 0) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); + result.push((bits >> 16) & 0xFF) + result.push((bits >> 8) & 0xFF) + result.push(bits & 0xFF) } else if (tailbits === 18) { - result.push((bits >> 10) & 0xFF); - result.push((bits >> 2) & 0xFF); + result.push((bits >> 10) & 0xFF) + result.push((bits >> 2) & 0xFF) } else if (tailbits === 12) { - result.push((bits >> 4) & 0xFF); + result.push((bits >> 4) & 0xFF) } - return new Uint8Array(result); + return new Uint8Array(result) } -function representYamlBinary(object /*, style*/) { - var result = '', bits = 0, idx, tail, - max = object.length, - map = BASE64_MAP; +function representYamlBinary (object /*, style */) { + let result = '' + let bits = 0 + const max = object.length + const map = BASE64_MAP // Convert every three bytes to 4 ASCII characters. - for (idx = 0; idx < max; idx++) { + for (let idx = 0; idx < max; idx++) { if ((idx % 3 === 0) && idx) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; + result += map[(bits >> 18) & 0x3F] + result += map[(bits >> 12) & 0x3F] + result += map[(bits >> 6) & 0x3F] + result += map[bits & 0x3F] } - bits = (bits << 8) + object[idx]; + bits = (bits << 8) + object[idx] } // Dump tail - tail = max % 3; + const tail = max % 3 if (tail === 0) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; + result += map[(bits >> 18) & 0x3F] + result += map[(bits >> 12) & 0x3F] + result += map[(bits >> 6) & 0x3F] + result += map[bits & 0x3F] } else if (tail === 2) { - result += map[(bits >> 10) & 0x3F]; - result += map[(bits >> 4) & 0x3F]; - result += map[(bits << 2) & 0x3F]; - result += map[64]; + result += map[(bits >> 10) & 0x3F] + result += map[(bits >> 4) & 0x3F] + result += map[(bits << 2) & 0x3F] + result += map[64] } else if (tail === 1) { - result += map[(bits >> 2) & 0x3F]; - result += map[(bits << 4) & 0x3F]; - result += map[64]; - result += map[64]; + result += map[(bits >> 2) & 0x3F] + result += map[(bits << 4) & 0x3F] + result += map[64] + result += map[64] } - return result; + return result } -function isBinary(obj) { - return Object.prototype.toString.call(obj) === '[object Uint8Array]'; +function isBinary (obj) { + return Object.prototype.toString.call(obj) === '[object Uint8Array]' } module.exports = new Type('tag:yaml.org,2002:binary', { @@ -122,4 +119,4 @@ module.exports = new Type('tag:yaml.org,2002:binary', { construct: constructYamlBinary, predicate: isBinary, represent: representYamlBinary -}); +}) diff --git a/lib/type/bool.js b/lib/type/bool.js index cb774593..ba3d44f8 100644 --- a/lib/type/bool.js +++ b/lib/type/bool.js @@ -1,24 +1,24 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') -function resolveYamlBoolean(data) { - if (data === null) return false; +function resolveYamlBoolean (data) { + if (data === null) return false - var max = data.length; + const max = data.length return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || - (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')) } -function constructYamlBoolean(data) { +function constructYamlBoolean (data) { return data === 'true' || data === 'True' || - data === 'TRUE'; + data === 'TRUE' } -function isBoolean(object) { - return Object.prototype.toString.call(object) === '[object Boolean]'; +function isBoolean (object) { + return Object.prototype.toString.call(object) === '[object Boolean]' } module.exports = new Type('tag:yaml.org,2002:bool', { @@ -27,9 +27,9 @@ module.exports = new Type('tag:yaml.org,2002:bool', { construct: constructYamlBoolean, predicate: isBoolean, represent: { - lowercase: function (object) { return object ? 'true' : 'false'; }, - uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, - camelcase: function (object) { return object ? 'True' : 'False'; } + lowercase: function (object) { return object ? 'true' : 'false' }, + uppercase: function (object) { return object ? 'TRUE' : 'FALSE' }, + camelcase: function (object) { return object ? 'True' : 'False' } }, defaultStyle: 'lowercase' -}); +}) diff --git a/lib/type/float.js b/lib/type/float.js index 74d77ec2..6aae1b42 100644 --- a/lib/type/float.js +++ b/lib/type/float.js @@ -1,9 +1,9 @@ -'use strict'; +'use strict' -var common = require('../common'); -var Type = require('../type'); +const common = require('../common') +const Type = require('../type') -var YAML_FLOAT_PATTERN = new RegExp( +const YAML_FLOAT_PATTERN = new RegExp( // 2.5e4, 2.5 and integers '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + // .2e4, .2 @@ -12,79 +12,73 @@ var YAML_FLOAT_PATTERN = new RegExp( // .inf '|[-+]?\\.(?:inf|Inf|INF)' + // .nan - '|\\.(?:nan|NaN|NAN))$'); + '|\\.(?:nan|NaN|NAN))$') -function resolveYamlFloat(data) { - if (data === null) return false; +function resolveYamlFloat (data) { + if (data === null) return false if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` // Probably should update regexp & check speed data[data.length - 1] === '_') { - return false; + return false } - return true; + return true } -function constructYamlFloat(data) { - var value, sign; - - value = data.replace(/_/g, '').toLowerCase(); - sign = value[0] === '-' ? -1 : 1; +function constructYamlFloat (data) { + let value = data.replace(/_/g, '').toLowerCase() + const sign = value[0] === '-' ? -1 : 1 if ('+-'.indexOf(value[0]) >= 0) { - value = value.slice(1); + value = value.slice(1) } if (value === '.inf') { - return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; - + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY } else if (value === '.nan') { - return NaN; + return NaN } - return sign * parseFloat(value, 10); + return sign * parseFloat(value, 10) } +const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/ -var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; - -function representYamlFloat(object, style) { - var res; - +function representYamlFloat (object, style) { if (isNaN(object)) { switch (style) { - case 'lowercase': return '.nan'; - case 'uppercase': return '.NAN'; - case 'camelcase': return '.NaN'; + case 'lowercase': return '.nan' + case 'uppercase': return '.NAN' + case 'camelcase': return '.NaN' } } else if (Number.POSITIVE_INFINITY === object) { switch (style) { - case 'lowercase': return '.inf'; - case 'uppercase': return '.INF'; - case 'camelcase': return '.Inf'; + case 'lowercase': return '.inf' + case 'uppercase': return '.INF' + case 'camelcase': return '.Inf' } } else if (Number.NEGATIVE_INFINITY === object) { switch (style) { - case 'lowercase': return '-.inf'; - case 'uppercase': return '-.INF'; - case 'camelcase': return '-.Inf'; + case 'lowercase': return '-.inf' + case 'uppercase': return '-.INF' + case 'camelcase': return '-.Inf' } } else if (common.isNegativeZero(object)) { - return '-0.0'; + return '-0.0' } - res = object.toString(10); + const res = object.toString(10) // JS stringifier can build scientific format without dots: 5e-100, // while YAML requres dot: 5.e-100. Fix it with simple hack - return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res } -function isFloat(object) { +function isFloat (object) { return (Object.prototype.toString.call(object) === '[object Number]') && - (object % 1 !== 0 || common.isNegativeZero(object)); + (object % 1 !== 0 || common.isNegativeZero(object)) } module.exports = new Type('tag:yaml.org,2002:float', { @@ -94,4 +88,4 @@ module.exports = new Type('tag:yaml.org,2002:float', { predicate: isFloat, represent: representYamlFloat, defaultStyle: 'lowercase' -}); +}) diff --git a/lib/type/int.js b/lib/type/int.js index 3fe3a443..c4670b0f 100644 --- a/lib/type/int.js +++ b/lib/type/int.js @@ -1,137 +1,135 @@ -'use strict'; +'use strict' -var common = require('../common'); -var Type = require('../type'); +const common = require('../common') +const Type = require('../type') -function isHexCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || - ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || - ((0x61/* a */ <= c) && (c <= 0x66/* f */)); +function isHexCode (c) { + return ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) || + ((c >= 0x41/* A */) && (c <= 0x46/* F */)) || + ((c >= 0x61/* a */) && (c <= 0x66/* f */)) } -function isOctCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); +function isOctCode (c) { + return ((c >= 0x30/* 0 */) && (c <= 0x37/* 7 */)) } -function isDecCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); +function isDecCode (c) { + return ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) } -function resolveYamlInteger(data) { - if (data === null) return false; +function resolveYamlInteger (data) { + if (data === null) return false - var max = data.length, - index = 0, - hasDigits = false, - ch; + const max = data.length + let index = 0 + let hasDigits = false - if (!max) return false; + if (!max) return false - ch = data[index]; + let ch = data[index] // sign if (ch === '-' || ch === '+') { - ch = data[++index]; + ch = data[++index] } if (ch === '0') { // 0 - if (index + 1 === max) return true; - ch = data[++index]; + if (index + 1 === max) return true + ch = data[++index] // base 2, base 8, base 16 if (ch === 'b') { // base 2 - index++; + index++ for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (ch !== '0' && ch !== '1') return false; - hasDigits = true; + ch = data[index] + if (ch === '_') continue + if (ch !== '0' && ch !== '1') return false + hasDigits = true } - return hasDigits && ch !== '_'; + return hasDigits && ch !== '_' } - if (ch === 'x') { // base 16 - index++; + index++ for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isHexCode(data.charCodeAt(index))) return false; - hasDigits = true; + ch = data[index] + if (ch === '_') continue + if (!isHexCode(data.charCodeAt(index))) return false + hasDigits = true } - return hasDigits && ch !== '_'; + return hasDigits && ch !== '_' } - if (ch === 'o') { // base 8 - index++; + index++ for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isOctCode(data.charCodeAt(index))) return false; - hasDigits = true; + ch = data[index] + if (ch === '_') continue + if (!isOctCode(data.charCodeAt(index))) return false + hasDigits = true } - return hasDigits && ch !== '_'; + return hasDigits && ch !== '_' } } // base 10 (except 0) // value should not start with `_`; - if (ch === '_') return false; + if (ch === '_') return false for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; + ch = data[index] + if (ch === '_') continue if (!isDecCode(data.charCodeAt(index))) { - return false; + return false } - hasDigits = true; + hasDigits = true } // Should have digits and should not end with `_` - if (!hasDigits || ch === '_') return false; + if (!hasDigits || ch === '_') return false - return true; + return true } -function constructYamlInteger(data) { - var value = data, sign = 1, ch; +function constructYamlInteger (data) { + let value = data + let sign = 1 if (value.indexOf('_') !== -1) { - value = value.replace(/_/g, ''); + value = value.replace(/_/g, '') } - ch = value[0]; + let ch = value[0] if (ch === '-' || ch === '+') { - if (ch === '-') sign = -1; - value = value.slice(1); - ch = value[0]; + if (ch === '-') sign = -1 + value = value.slice(1) + ch = value[0] } - if (value === '0') return 0; + if (value === '0') return 0 if (ch === '0') { - if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); - if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); - if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); + if (value[1] === 'b') return sign * parseInt(value.slice(2), 2) + if (value[1] === 'x') return sign * parseInt(value.slice(2), 16) + if (value[1] === 'o') return sign * parseInt(value.slice(2), 8) } - return sign * parseInt(value, 10); + return sign * parseInt(value, 10) } -function isInteger(object) { +function isInteger (object) { return (Object.prototype.toString.call(object)) === '[object Number]' && - (object % 1 === 0 && !common.isNegativeZero(object)); + (object % 1 === 0 && !common.isNegativeZero(object)) } module.exports = new Type('tag:yaml.org,2002:int', { @@ -140,17 +138,16 @@ module.exports = new Type('tag:yaml.org,2002:int', { construct: constructYamlInteger, predicate: isInteger, represent: { - binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, - octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, - decimal: function (obj) { return obj.toString(10); }, - /* eslint-disable max-len */ - hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } + binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1) }, + octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1) }, + decimal: function (obj) { return obj.toString(10) }, + hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1) } }, defaultStyle: 'decimal', styleAliases: { - binary: [ 2, 'bin' ], - octal: [ 8, 'oct' ], - decimal: [ 10, 'dec' ], - hexadecimal: [ 16, 'hex' ] + binary: [2, 'bin'], + octal: [8, 'oct'], + decimal: [10, 'dec'], + hexadecimal: [16, 'hex'] } -}); +}) diff --git a/lib/type/map.js b/lib/type/map.js index f327beeb..aa278741 100644 --- a/lib/type/map.js +++ b/lib/type/map.js @@ -1,8 +1,8 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') module.exports = new Type('tag:yaml.org,2002:map', { kind: 'mapping', - construct: function (data) { return data !== null ? data : {}; } -}); + construct: function (data) { return data !== null ? data : {} } +}) diff --git a/lib/type/merge.js b/lib/type/merge.js index ae08a864..5781ff53 100644 --- a/lib/type/merge.js +++ b/lib/type/merge.js @@ -1,12 +1,12 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') -function resolveYamlMerge(data) { - return data === '<<' || data === null; +function resolveYamlMerge (data) { + return data === '<<' || data === null } module.exports = new Type('tag:yaml.org,2002:merge', { kind: 'scalar', resolve: resolveYamlMerge -}); +}) diff --git a/lib/type/null.js b/lib/type/null.js index 315ca4e2..cbae3bdc 100644 --- a/lib/type/null.js +++ b/lib/type/null.js @@ -1,22 +1,22 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') -function resolveYamlNull(data) { - if (data === null) return true; +function resolveYamlNull (data) { + if (data === null) return true - var max = data.length; + const max = data.length return (max === 1 && data === '~') || - (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')) } -function constructYamlNull() { - return null; +function constructYamlNull () { + return null } -function isNull(object) { - return object === null; +function isNull (object) { + return object === null } module.exports = new Type('tag:yaml.org,2002:null', { @@ -25,11 +25,11 @@ module.exports = new Type('tag:yaml.org,2002:null', { construct: constructYamlNull, predicate: isNull, represent: { - canonical: function () { return '~'; }, - lowercase: function () { return 'null'; }, - uppercase: function () { return 'NULL'; }, - camelcase: function () { return 'Null'; }, - empty: function () { return ''; } + canonical: function () { return '~' }, + lowercase: function () { return 'null' }, + uppercase: function () { return 'NULL' }, + camelcase: function () { return 'Null' }, + empty: function () { return '' } }, defaultStyle: 'lowercase' -}); +}) diff --git a/lib/type/omap.js b/lib/type/omap.js index b2b5323b..b27786e7 100644 --- a/lib/type/omap.js +++ b/lib/type/omap.js @@ -1,44 +1,45 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') -var _hasOwnProperty = Object.prototype.hasOwnProperty; -var _toString = Object.prototype.toString; +const _hasOwnProperty = Object.prototype.hasOwnProperty +const _toString = Object.prototype.toString -function resolveYamlOmap(data) { - if (data === null) return true; +function resolveYamlOmap (data) { + if (data === null) return true - var objectKeys = [], index, length, pair, pairKey, pairHasKey, - object = data; + const objectKeys = [] + const object = data - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - pairHasKey = false; + for (let index = 0, length = object.length; index < length; index += 1) { + const pair = object[index] + let pairHasKey = false - if (_toString.call(pair) !== '[object Object]') return false; + if (_toString.call(pair) !== '[object Object]') return false + let pairKey for (pairKey in pair) { if (_hasOwnProperty.call(pair, pairKey)) { - if (!pairHasKey) pairHasKey = true; - else return false; + if (!pairHasKey) pairHasKey = true + else return false } } - if (!pairHasKey) return false; + if (!pairHasKey) return false - if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); - else return false; + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey) + else return false } - return true; + return true } -function constructYamlOmap(data) { - return data !== null ? data : []; +function constructYamlOmap (data) { + return data !== null ? data : [] } module.exports = new Type('tag:yaml.org,2002:omap', { kind: 'sequence', resolve: resolveYamlOmap, construct: constructYamlOmap -}); +}) diff --git a/lib/type/pairs.js b/lib/type/pairs.js index 74b52403..4b902220 100644 --- a/lib/type/pairs.js +++ b/lib/type/pairs.js @@ -1,53 +1,50 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') -var _toString = Object.prototype.toString; +const _toString = Object.prototype.toString -function resolveYamlPairs(data) { - if (data === null) return true; +function resolveYamlPairs (data) { + if (data === null) return true - var index, length, pair, keys, result, - object = data; + const object = data - result = new Array(object.length); + const result = new Array(object.length) - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; + for (let index = 0, length = object.length; index < length; index += 1) { + const pair = object[index] - if (_toString.call(pair) !== '[object Object]') return false; + if (_toString.call(pair) !== '[object Object]') return false - keys = Object.keys(pair); + const keys = Object.keys(pair) - if (keys.length !== 1) return false; + if (keys.length !== 1) return false - result[index] = [ keys[0], pair[keys[0]] ]; + result[index] = [keys[0], pair[keys[0]]] } - return true; + return true } -function constructYamlPairs(data) { - if (data === null) return []; +function constructYamlPairs (data) { + if (data === null) return [] - var index, length, pair, keys, result, - object = data; + const object = data + const result = new Array(object.length) - result = new Array(object.length); + for (let index = 0, length = object.length; index < length; index += 1) { + const pair = object[index] - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; + const keys = Object.keys(pair) - keys = Object.keys(pair); - - result[index] = [ keys[0], pair[keys[0]] ]; + result[index] = [keys[0], pair[keys[0]]] } - return result; + return result } module.exports = new Type('tag:yaml.org,2002:pairs', { kind: 'sequence', resolve: resolveYamlPairs, construct: constructYamlPairs -}); +}) diff --git a/lib/type/seq.js b/lib/type/seq.js index be8f77f2..e85ab662 100644 --- a/lib/type/seq.js +++ b/lib/type/seq.js @@ -1,8 +1,8 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') module.exports = new Type('tag:yaml.org,2002:seq', { kind: 'sequence', - construct: function (data) { return data !== null ? data : []; } -}); + construct: function (data) { return data !== null ? data : [] } +}) diff --git a/lib/type/set.js b/lib/type/set.js index f885a329..8e8a1190 100644 --- a/lib/type/set.js +++ b/lib/type/set.js @@ -1,29 +1,29 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') -var _hasOwnProperty = Object.prototype.hasOwnProperty; +const _hasOwnProperty = Object.prototype.hasOwnProperty -function resolveYamlSet(data) { - if (data === null) return true; +function resolveYamlSet (data) { + if (data === null) return true - var key, object = data; + const object = data - for (key in object) { + for (const key in object) { if (_hasOwnProperty.call(object, key)) { - if (object[key] !== null) return false; + if (object[key] !== null) return false } } - return true; + return true } -function constructYamlSet(data) { - return data !== null ? data : {}; +function constructYamlSet (data) { + return data !== null ? data : {} } module.exports = new Type('tag:yaml.org,2002:set', { kind: 'mapping', resolve: resolveYamlSet, construct: constructYamlSet -}); +}) diff --git a/lib/type/str.js b/lib/type/str.js index 27acc106..072ef27f 100644 --- a/lib/type/str.js +++ b/lib/type/str.js @@ -1,8 +1,8 @@ -'use strict'; +'use strict' -var Type = require('../type'); +const Type = require('../type') module.exports = new Type('tag:yaml.org,2002:str', { kind: 'scalar', - construct: function (data) { return data !== null ? data : ''; } -}); + construct: function (data) { return data !== null ? data : '' } +}) diff --git a/lib/type/timestamp.js b/lib/type/timestamp.js index 8fa9c586..771474ea 100644 --- a/lib/type/timestamp.js +++ b/lib/type/timestamp.js @@ -1,82 +1,82 @@ -'use strict'; - -var Type = require('../type'); - -var YAML_DATE_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9])' + // [2] month - '-([0-9][0-9])$'); // [3] day - -var YAML_TIMESTAMP_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9]?)' + // [2] month - '-([0-9][0-9]?)' + // [3] day - '(?:[Tt]|[ \\t]+)' + // ... - '([0-9][0-9]?)' + // [4] hour - ':([0-9][0-9])' + // [5] minute - ':([0-9][0-9])' + // [6] second - '(?:\\.([0-9]*))?' + // [7] fraction +'use strict' + +const Type = require('../type') + +const YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$') // [3] day + +const YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour - '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + '(?::([0-9][0-9]))?))?$') // [11] tz_minute -function resolveYamlTimestamp(data) { - if (data === null) return false; - if (YAML_DATE_REGEXP.exec(data) !== null) return true; - if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; - return false; +function resolveYamlTimestamp (data) { + if (data === null) return false + if (YAML_DATE_REGEXP.exec(data) !== null) return true + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true + return false } -function constructYamlTimestamp(data) { - var match, year, month, day, hour, minute, second, fraction = 0, - delta = null, tz_hour, tz_minute, date; +function constructYamlTimestamp (data) { + let fraction = 0 + let delta = null - match = YAML_DATE_REGEXP.exec(data); - if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + let match = YAML_DATE_REGEXP.exec(data) + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data) - if (match === null) throw new Error('Date resolve error'); + if (match === null) throw new Error('Date resolve error') // match: [1] year [2] month [3] day - year = +(match[1]); - month = +(match[2]) - 1; // JS month starts with 0 - day = +(match[3]); + const year = +(match[1]) + const month = +(match[2]) - 1 // JS month starts with 0 + const day = +(match[3]) if (!match[4]) { // no hour - return new Date(Date.UTC(year, month, day)); + return new Date(Date.UTC(year, month, day)) } // match: [4] hour [5] minute [6] second [7] fraction - hour = +(match[4]); - minute = +(match[5]); - second = +(match[6]); + const hour = +(match[4]) + const minute = +(match[5]) + const second = +(match[6]) if (match[7]) { - fraction = match[7].slice(0, 3); + fraction = match[7].slice(0, 3) while (fraction.length < 3) { // milli-seconds - fraction += '0'; + fraction += '0' } - fraction = +fraction; + fraction = +fraction } // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute if (match[9]) { - tz_hour = +(match[10]); - tz_minute = +(match[11] || 0); - delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds - if (match[9] === '-') delta = -delta; + const tz_hour = +(match[10]) + const tz_minute = +(match[11] || 0) + delta = (tz_hour * 60 + tz_minute) * 60000 // delta in mili-seconds + if (match[9] === '-') delta = -delta } - date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)) - if (delta) date.setTime(date.getTime() - delta); + if (delta) date.setTime(date.getTime() - delta) - return date; + return date } -function representYamlTimestamp(object /*, style*/) { - return object.toISOString(); +function representYamlTimestamp (object /*, style */) { + return object.toISOString() } module.exports = new Type('tag:yaml.org,2002:timestamp', { @@ -85,4 +85,4 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', { construct: constructYamlTimestamp, instanceOf: Date, represent: representYamlTimestamp -}); +}) diff --git a/package.json b/package.json index 878aecd4..5b289fb5 100644 --- a/package.json +++ b/package.json @@ -35,12 +35,15 @@ }, "scripts": { "lint": "eslint .", - "test": "npm run lint && mocha", - "coverage": "npm run lint && c8 -r html mocha", - "demo": "npm run lint && node support/build_demo.js", - "gh-demo": "npm run demo && gh-pages -d demo -f", - "browserify": "rollup -c support/rollup.config.js", - "prepublishOnly": "npm run gh-demo" + "test": "npm run lint && npm run test:core && npm run test:build", + "test:core": "node --test test/core/*.test.*", + "test:build": "npm run build && node --test test/build/*.test.*", + "coverage": "npm run build && c8 --include 'lib/**' -r text -r html -r lcov node --test test/core/*.test.*", + "build": "node support/build-dist.mjs", + "build:demo": "npm run lint && node support/build_demo.mjs", + "gh-demo": "npm run build:demo && gh-pages -d demo -f", + "prepack": "npm test && npm run build && npm run build:demo", + "postpublish": "npm run gh-demo" }, "unpkg": "dist/js-yaml.min.js", "jsdelivr": "dist/js-yaml.min.js", @@ -48,19 +51,15 @@ "argparse": "^2.0.1" }, "devDependencies": { - "@rollup/plugin-commonjs": "^17.0.0", - "@rollup/plugin-node-resolve": "^11.0.0", - "ansi": "^0.3.1", - "benchmark": "^2.1.4", - "codemirror": "^5.13.4", - "eslint": "^7.0.0", - "fast-check": "^2.8.0", - "gh-pages": "^3.1.0", - "mocha": "^8.2.1", "c8": "^11.0.0", - "rollup": "^2.34.1", - "rollup-plugin-node-polyfills": "^0.2.1", - "rollup-plugin-terser": "^7.0.2", - "shelljs": "^0.8.4" + "codemirror": "^5.65.21", + "eslint": "^9.39.4", + "fast-check": "^4.8.0", + "gh-pages": "^6.3.0", + "neostandard": "^0.13.0", + "tinybench": "^6.0.2", + "vite": "^8.0.14", + "vite-plugin-node-polyfills": "^0.28.0", + "vite-plugin-singlefile": "^2.3.3" } } diff --git a/support/build-dist.mjs b/support/build-dist.mjs new file mode 100644 index 00000000..73fa5435 --- /dev/null +++ b/support/build-dist.mjs @@ -0,0 +1,80 @@ +import { rm } from 'node:fs/promises' +import { createRequire } from 'node:module' +import { build } from 'vite' + +const require = createRequire(import.meta.url) +const pkg = require('../package.json') + +const banner = `/*! ${pkg.name} ${pkg.version} https://github.com/${pkg.repository} @license ${pkg.license} */` + +const common = { + configFile: false, + logLevel: 'info', + build: { + outDir: 'dist', + emptyOutDir: false, + sourcemap: true, + target: 'es2015' + } +} + +await rm('dist', { recursive: true, force: true }) + +await build({ + ...common, + build: { + ...common.build, + minify: false, + lib: { + entry: 'lib/index_vite_proxy.tmp.mjs', + name: 'jsyaml', + formats: ['umd'], + fileName: () => 'js-yaml.js' + }, + rollupOptions: { + external: [], + output: { + banner + } + } + } +}) + +await build({ + ...common, + build: { + ...common.build, + minify: true, + lib: { + entry: 'lib/index_vite_proxy.tmp.mjs', + name: 'jsyaml', + formats: ['umd'], + fileName: () => 'js-yaml.min.js' + }, + rollupOptions: { + external: [], + output: { + banner + } + } + } +}) + +await build({ + ...common, + build: { + ...common.build, + minify: false, + lib: { + entry: 'lib/index_vite_proxy.tmp.mjs', + formats: ['es'], + fileName: () => 'js-yaml.mjs' + }, + rollupOptions: { + external: [], + output: { + banner + } + } + } +}) diff --git a/support/build_demo.js b/support/build_demo.js deleted file mode 100644 index 9cd139cd..00000000 --- a/support/build_demo.js +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -/* eslint-env es6 */ - -const shell = require('shelljs'); - -shell.rm('-rf', 'demo'); -shell.mkdir('demo'); - -shell.exec('node_modules/.bin/rollup -c support/demo_template/rollup.config.js'); - -shell.cp('support/demo_template/index.html', 'demo/'); -shell.cp('support/demo_template/demo.css', 'demo/'); -shell.cp('node_modules/codemirror/lib/codemirror.css', 'demo/'); diff --git a/support/build_demo.mjs b/support/build_demo.mjs new file mode 100644 index 00000000..345c35fa --- /dev/null +++ b/support/build_demo.mjs @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +import { build } from 'vite' +import { viteSingleFile } from 'vite-plugin-singlefile' +import { nodePolyfills } from 'vite-plugin-node-polyfills' + +await build({ + root: 'support/demo_template', + configFile: false, + plugins: [ + nodePolyfills({ include: ['util'] }), + viteSingleFile({ removeViteModuleLoader: true }) + ], + build: { + outDir: '../../demo', + emptyOutDir: true + } +}) diff --git a/support/demo_template/base64.js b/support/demo_template/base64.js deleted file mode 100644 index c0528ceb..00000000 --- a/support/demo_template/base64.js +++ /dev/null @@ -1,180 +0,0 @@ -// Base64 encoder/decoder with UTF-8 support -// -// Copyright (c) 2011 Vitaly Puzrin -// Copyright (c) 2011 Aleksey V Zapparov -// -// Author: Aleksey V Zapparov AKA ixti (http://www.ixti.net/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -// Based on original artworks of base64 encoder/decoder by [Mozilla][1] -// [1]: http://lxr.mozilla.org/mozilla/source/extensions/xml-rpc/src/nsXmlRpcClient.js - - -'use strict'; - -/* eslint-env browser */ -/* eslint-disable no-bitwise */ - -function noop() {} - -var logger = { warn: noop, error: noop }, - padding = '=', - chrTable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + - '0123456789+/', - binTable = [ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 - ]; - -if (window.console) { - logger = window.console; - logger.warn = logger.warn || logger.error || logger.log || noop; - logger.error = logger.error || logger.warn || logger.log || noop; -} - -// internal helpers ////////////////////////////////////////////////////////// - -function utf8Encode(str) { - var bytes = [], offset = 0, length, char; - - str = encodeURI(str); - length = str.length; - - while (offset < length) { - char = str.charAt(offset); - offset += 1; - - if (char !== '%') { - bytes.push(char.charCodeAt(0)); - } else { - char = str.charAt(offset) + str.charAt(offset + 1); - bytes.push(parseInt(char, 16)); - offset += 2; - } - } - - return bytes; -} - -function utf8Decode(bytes) { - var chars = [], offset = 0, length = bytes.length, c1, c2, c3; - - while (offset < length) { - c1 = bytes[offset]; - c2 = bytes[offset + 1]; - c3 = bytes[offset + 2]; - - if (c1 < 128) { - chars.push(String.fromCharCode(c1)); - offset += 1; - } else if (191 < c1 && c1 < 224) { - chars.push(String.fromCharCode(((c1 & 31) << 6) | (c2 & 63))); - offset += 2; - } else { - chars.push(String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63))); - offset += 3; - } - } - - return chars.join(''); -} - -// public api //////////////////////////////////////////////////////////////// - -function encode(str) { - var result = '', - bytes = utf8Encode(str), - length = bytes.length, - i; - - // Convert every three bytes to 4 ascii characters. - for (i = 0; i < (length - 2); i += 3) { - result += chrTable[bytes[i] >> 2]; - result += chrTable[((bytes[i] & 0x03) << 4) + (bytes[i + 1] >> 4)]; - result += chrTable[((bytes[i + 1] & 0x0f) << 2) + (bytes[i + 2] >> 6)]; - result += chrTable[bytes[i + 2] & 0x3f]; - } - - // Convert the remaining 1 or 2 bytes, pad out to 4 characters. - if (length % 3) { - i = length - (length % 3); - result += chrTable[bytes[i] >> 2]; - if ((length % 3) === 2) { - result += chrTable[((bytes[i] & 0x03) << 4) + (bytes[i + 1] >> 4)]; - result += chrTable[(bytes[i + 1] & 0x0f) << 2]; - result += padding; - } else { - result += chrTable[(bytes[i] & 0x03) << 4]; - result += padding + padding; - } - } - - return result; -} - -function decode(data) { - var value, code, idx = 0, - bytes = [], - leftbits = 0, // number of bits decoded, but yet to be appended - leftdata = 0; // bits decoded, but yet to be appended - - // Convert one by one. - for (idx = 0; idx < data.length; idx += 1) { - code = data.charCodeAt(idx); - value = binTable[code & 0x7F]; - - if (value === -1) { - // Skip illegal characters and whitespace - logger.warn('Illegal characters (code=' + code + ') in position ' + idx); - } else { - // Collect data into leftdata, update bitcount - leftdata = (leftdata << 6) | value; - leftbits += 6; - - // If we have 8 or more bits, append 8 bits to the result - if (leftbits >= 8) { - leftbits -= 8; - // Append if not padding. - if (padding !== data.charAt(idx)) { - bytes.push((leftdata >> leftbits) & 0xFF); - } - leftdata &= (1 << leftbits) - 1; - } - } - } - - // If there are any bits left, the base64 string was corrupted - if (leftbits) { - logger.error('Corrupted base64 string'); - return null; - } - - return utf8Decode(bytes); -} - -exports.encode = encode; -exports.decode = decode; diff --git a/support/demo_template/demo.css b/support/demo_template/demo.css index 94ffaedb..ca678d5f 100644 --- a/support/demo_template/demo.css +++ b/support/demo_template/demo.css @@ -1,42 +1,6 @@ -html, body { - height: 100%; -} - -body { - margin: 0 30px; - padding-bottom: 125px; - overflow-x: hidden; -} - -.header { - padding: 1px 0 30px; - white-space: nowrap; - overflow: hidden; -} - -.subheader { - position: absolute; - top: -35px; - width: 100%; -} - -.content { - height: 100%; -} - -#permalink { - float: right; -} - -.src, .dst { - width: 49%; - position: relative; - float: left; - height: 100%; -} - -.dst { - float: right; +.demo-column { + flex: 1 1 0; + min-width: 0; } .src .CodeMirror { @@ -48,17 +12,14 @@ body { .dst .CodeMirror { background-color: #F8F8F8; - border: 1px solid #eee; + border: 1px solid #ddd; border-radius: 3px; } -/*.CodeMirror-scroll { - height: 500px; - line-height: 1.2; -}*/ - .CodeMirror { + flex: 1 1 auto; height: 100%; + min-height: 0; font-size: 13px; } @@ -66,33 +27,15 @@ body { color: #baa; } -.gh-ribbon { - -webkit-transform: rotate(45deg); - -ms-transform: rotate(45deg); - transform: rotate(45deg); - background-color: #686868; - box-shadow: 0 0 2px rgba(102, 102, 102, 0.4); - display: block; - padding: 1px 0; - position: fixed; - right: -60px; - top: 44px; - width: 230px; - z-index: 10000; +.github-link { + color: #333; } -.gh-ribbon a { - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; - font-size: 13px; - border: 1px solid #AAAAAA; - color: #FFFFFF; - display: block; - font-size: 13px; - font-weight: 700; - outline: medium none; - padding: 4px 50px 2px; - text-align: center; - text-decoration: none; +.github-link:hover { + color: #000; } -.csstransforms .gh-ribbon { - display: block; +.github-link svg { + display: block; + fill: currentColor; + height: 32px; + width: 32px; } diff --git a/support/demo_template/demo.js b/support/demo_template/demo.js deleted file mode 100644 index 2efb3c11..00000000 --- a/support/demo_template/demo.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict'; - -/* eslint-env browser */ - -var jsyaml = require('../../index.js'); -var codemirror = require('codemirror'); -var base64 = require('./base64'); -var inspect = require('util').inspect; - - -require('codemirror/mode/yaml/yaml.js'); -require('codemirror/mode/javascript/javascript.js'); - - -var source, result, permalink, default_text; - -var SexyYamlType = new jsyaml.Type('!sexy', { - kind: 'sequence', // See node kinds in YAML spec: http://www.yaml.org/spec/1.2/spec.html#kind// - construct: function (data) { - return data.map(function (string) { return 'sexy ' + string; }); - } -}); - -var SEXY_SCHEMA = jsyaml.DEFAULT_SCHEMA.extend([ SexyYamlType ]); - -function parse() { - var str, obj; - - str = source.getValue(); - permalink.href = '#yaml=' + base64.encode(str); - - try { - obj = jsyaml.load(str, { schema: SEXY_SCHEMA }); - - result.setOption('mode', 'javascript'); - result.setValue(inspect(obj, false, 10)); - } catch (err) { - result.setOption('mode', 'text/plain'); - result.setValue(err.message || String(err)); - } -} - -function updateSource() { - var yaml; - - if (location.hash && location.hash.toString().slice(0, 6) === '#yaml=') { - yaml = base64.decode(location.hash.slice(6)); - } - - source.setValue(yaml || default_text); - parse(); -} - -window.onload = function () { - permalink = document.getElementById('permalink'); - default_text = document.getElementById('source').value || ''; - - source = codemirror.fromTextArea(document.getElementById('source'), { - mode: 'yaml', - lineNumbers: true - }); - - var timer; - - source.on('change', function () { - clearTimeout(timer); - timer = setTimeout(parse, 500); - }); - - result = codemirror.fromTextArea(document.getElementById('result'), { - readOnly: true - }); - - // initial source - updateSource(); -}; diff --git a/support/demo_template/index.html b/support/demo_template/index.html index 0528ee1e..b450f6d7 100644 --- a/support/demo_template/index.html +++ b/support/demo_template/index.html @@ -2,228 +2,42 @@ YAML parser for JavaScript - JS-YAML - + + - - - - - - - + + - - -
-

JS-YAML demo. YAML JavaScript parser.

+ + +
+

js-yaml demo

+ + +
-
-
-

Edit source here:

- +
+
+
+ Edit source + +
+
-
-

Result (JS object dump):

+
+
+ Result (JS object dump) +
- - diff --git a/support/demo_template/index.mjs b/support/demo_template/index.mjs new file mode 100644 index 00000000..7ccb5a90 --- /dev/null +++ b/support/demo_template/index.mjs @@ -0,0 +1,91 @@ +import jsyaml from '../../lib/index_vite_proxy.tmp.mjs' +import codemirror from 'codemirror' +import { inspect } from 'util' +import default_text from './sample.mjs' + +import 'codemirror/lib/codemirror.css' +import 'codemirror/mode/yaml/yaml.js' +import 'codemirror/mode/javascript/javascript.js' +import './demo.css' + +let source +let result +let permalink +let clear + +function encodeBase64 (str) { + return btoa(String.fromCharCode(...new TextEncoder().encode(str))) +} + +function decodeBase64 (str) { + return new TextDecoder().decode(Uint8Array.from(atob(str), function (char) { + return char.charCodeAt(0) + })) +} + +const SexyYamlType = new jsyaml.Type('!sexy', { + kind: 'sequence', // See node kinds in YAML spec: http://www.yaml.org/spec/1.2/spec.html#kind// + construct: function (data) { + return data.map(function (string) { return 'sexy ' + string }) + } +}) + +const SEXY_SCHEMA = jsyaml.DEFAULT_SCHEMA.extend([SexyYamlType]) + +function parse () { + let obj + + const str = source.getValue() + permalink.href = '#yaml=' + encodeBase64(str) + + try { + obj = jsyaml.load(str, { schema: SEXY_SCHEMA }) + + result.setOption('mode', 'javascript') + result.setValue(inspect(obj, false, 10)) + } catch (err) { + result.setOption('mode', 'text/plain') + result.setValue(err.message || String(err)) + } +} + +function updateSource () { + let yaml + + if (location.hash && location.hash.toString().slice(0, 6) === '#yaml=') { + yaml = decodeBase64(location.hash.slice(6)) + } + + source.setValue(yaml || default_text) + parse() +} + +window.onload = function () { + permalink = document.getElementById('permalink') + clear = document.getElementById('clear') + + source = codemirror.fromTextArea(document.getElementById('source'), { + mode: 'yaml', + lineNumbers: true + }) + + let timer + + source.on('change', function () { + clearTimeout(timer) + timer = setTimeout(parse, 500) + }) + + result = codemirror.fromTextArea(document.getElementById('result'), { + readOnly: true + }) + + clear.addEventListener('click', function (event) { + event.preventDefault() + source.setValue('') + parse() + }) + + // initial source + updateSource() +} diff --git a/support/demo_template/rollup.config.js b/support/demo_template/rollup.config.js deleted file mode 100644 index 377e433b..00000000 --- a/support/demo_template/rollup.config.js +++ /dev/null @@ -1,15 +0,0 @@ -import nodeResolve from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; -import nodePolyfills from 'rollup-plugin-node-polyfills'; - -export default [ - { - input: 'support/demo_template/demo.js', - output: { file: 'demo/demo.js', format: 'iife', name: 'demo' }, - plugins: [ - nodePolyfills(), - nodeResolve(), - commonjs() - ] - } -]; diff --git a/support/demo_template/sample.mjs b/support/demo_template/sample.mjs new file mode 100644 index 00000000..95ca95e5 --- /dev/null +++ b/support/demo_template/sample.mjs @@ -0,0 +1,183 @@ +export default `--- +# Collection Types ############################################################# +################################################################################ + +# http://yaml.org/type/map.html -----------------------------------------------# + +map: + # Unordered set of key: value pairs. + Block style: !!map + Clark : Evans + Ingy : döt Net + Oren : Ben-Kiki + Flow style: !!map { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki } + +# http://yaml.org/type/omap.html ----------------------------------------------# + +omap: + # Explicitly typed ordered map (dictionary). + Bestiary: !!omap + - aardvark: African pig-like ant eater. Ugly. + - anteater: South-American ant eater. Two species. + - anaconda: South-American constrictor snake. Scaly. + # Etc. + # Flow style + Numbers: !!omap [ one: 1, two: 2, three : 3 ] + +# http://yaml.org/type/pairs.html ---------------------------------------------# + +pairs: + # Explicitly typed pairs. + Block tasks: !!pairs + - meeting: with team. + - meeting: with boss. + - break: lunch. + - meeting: with client. + Flow tasks: !!pairs [ meeting: with team, meeting: with boss ] + +# http://yaml.org/type/set.html -----------------------------------------------# + +set: + # Explicitly typed set. + baseball players: !!set + ? Mark McGwire + ? Sammy Sosa + ? Ken Griffey + # Flow style + baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees } + +# http://yaml.org/type/seq.html -----------------------------------------------# + +seq: + # Ordered sequence of nodes + Block style: !!seq + - Mercury # Rotates - no light/dark sides. + - Venus # Deadliest. Aptly named. + - Earth # Mostly dirt. + - Mars # Seems empty. + - Jupiter # The king. + - Saturn # Pretty. + - Uranus # Where the sun hardly shines. + - Neptune # Boring. No rings. + - Pluto # You call this a planet? + Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks + Jupiter, Saturn, Uranus, Neptune, # Gas + Pluto ] # Overrated + + +# Scalar Types ################################################################# +################################################################################ + +# http://yaml.org/type/bool.html ----------------------------------------------# + +bool: + - true + - True + - TRUE + - false + - False + - FALSE + +# http://yaml.org/type/float.html ---------------------------------------------# + +float: + canonical: 6.8523015e+5 + exponentioal: 685.230_15e+03 + fixed: 685_230.15 + negative infinity: -.inf + not a number: .NaN + +# http://yaml.org/type/int.html -----------------------------------------------# + +int: + canonical: 685230 + decimal: +685_230 + octal: 0o2472256 + hexadecimal: 0x_0A_74_AE + binary: 0b1010_0111_0100_1010_1110 + +# http://yaml.org/type/merge.html ---------------------------------------------# + +merge: + - &CENTER { x: 1, y: 2 } + - &LEFT { x: 0, y: 2 } + - &BIG { r: 10 } + - &SMALL { r: 1 } + + # All the following maps are equal: + + - # Explicit keys + x: 1 + y: 2 + r: 10 + label: nothing + + - # Merge one map + << : *CENTER + r: 10 + label: center + + - # Merge multiple maps + << : [ *CENTER, *BIG ] + label: center/big + + - # Override + << : [ *BIG, *LEFT, *SMALL ] + x: 1 + label: big/left/small + +# http://yaml.org/type/null.html ----------------------------------------------# + +null: + # This mapping has four keys, + # one has a value. + empty: + canonical: ~ + english: null + ~: null key + # This sequence has five + # entries, two have values. + sparse: + - ~ + - 2nd entry + - + - 4th entry + - Null + +# http://yaml.org/type/str.html -----------------------------------------------# + +string: abcd + +# http://yaml.org/type/timestamp.html -----------------------------------------# + +timestamp: + canonical: 2001-12-15T02:59:43.1Z + valid iso8601: 2001-12-14t21:59:43.10-05:00 + space separated: 2001-12-14 21:59:43.10 -5 + no time zone (Z): 2001-12-15 2:59:43.10 + date (00:00:00Z): 2002-12-14 + + +# Custom types ################################################################# +################################################################################ + + +# JS-YAML allows you to specify a custom YAML types for your structures. +# This is a simple example of custom constructor defined in \`index.mjs\` for +# custom \`!sexy\` type: +# +# var SexyYamlType = new jsyaml.Type('!sexy', { +# kind: 'sequence', +# construct: function (data) { +# return data.map(function (string) { return 'sexy ' + string; }); +# } +# }); +# +# var SEXY_SCHEMA = jsyaml.Schema.create([ SexyYamlType ]); +# +# result = jsyaml.load(yourData, { schema: SEXY_SCHEMA }); + +foobar: !sexy + - bunny + - chocolate +` diff --git a/support/rollup.config.js b/support/rollup.config.js deleted file mode 100644 index 63f92166..00000000 --- a/support/rollup.config.js +++ /dev/null @@ -1,34 +0,0 @@ -import nodeResolve from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; -import pkg from '../package.json'; -import { terser } from 'rollup-plugin-terser'; - -const banner = { - banner() { - return `/*! ${pkg.name} ${pkg.version} https://github.com/${pkg.repository} @license ${pkg.license} */`; - } -} - -const plugins = [ nodeResolve(), commonjs(), banner ]; - -const umd_out_base = { format: 'umd', name: 'jsyaml', exports: 'named' }; - -export default [ - // es5 - { - input: 'index.js', - output: [ - { ...umd_out_base, file: 'dist/js-yaml.js' }, - { ...umd_out_base, file: 'dist/js-yaml.min.js', plugins: [ terser() ] } - ], - plugins - }, - // esm - { - input: 'index.js', - output: [ - { format: 'esm', file: 'dist/js-yaml.mjs' }, - ], - plugins - } -]; diff --git a/test/.eslintrc.yml b/test/.eslintrc.yml deleted file mode 100644 index 5fa543ad..00000000 --- a/test/.eslintrc.yml +++ /dev/null @@ -1,10 +0,0 @@ -env: - node: true - mocha: true - es6: true - -parserOptions: - ecmaVersion: 2020 - -rules: - no-undefined: 0 diff --git a/test/00-units.js b/test/00-units.js deleted file mode 100644 index 7dfa4953..00000000 --- a/test/00-units.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - - -var path = require('path'); -var fs = require('fs'); - - -describe('Units', function () { - var directory = path.resolve(__dirname, 'units'); - - fs.readdirSync(directory).forEach(function (file) { - if (path.extname(file) === '.js') { - require(path.resolve(directory, file)); - } - }); -}); diff --git a/test/10-loader.js b/test/10-loader.js deleted file mode 100644 index 5482d0fb..00000000 --- a/test/10-loader.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); -var yaml = require('../'); - -var TEST_SCHEMA = require('./support/schema').TEST_SCHEMA; - - -describe('Loader', function () { - var samplesDir = path.resolve(__dirname, 'samples-common'); - - fs.readdirSync(samplesDir).forEach(function (jsFile) { - if (path.extname(jsFile) !== '.js') return; // continue - - var yamlFile = path.resolve(samplesDir, path.basename(jsFile, '.js') + '.yml'); - - it(path.basename(jsFile, '.js'), function () { - var expected = require(path.resolve(samplesDir, jsFile)); - var actual = []; - - yaml.loadAll(fs.readFileSync(yamlFile, { encoding: 'utf8' }), function (doc) { actual.push(doc); }, { - filename: yamlFile, - schema: TEST_SCHEMA - }); - - if (actual.length === 1) actual = actual[0]; - - if (typeof expected === 'function') { - expected.call(this, actual); - } else { - assert.deepStrictEqual(actual, expected); - } - }); - }); -}); diff --git a/test/11-load-errors.js b/test/11-load-errors.js deleted file mode 100644 index e983473d..00000000 --- a/test/11-load-errors.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); -var yaml = require('../'); - -var TEST_SCHEMA = require('./support/schema').TEST_SCHEMA; - - -describe('Load errors', function () { - var samplesDir = path.resolve(__dirname, 'samples-load-errors'); - - fs.readdirSync(samplesDir).forEach(function (sampleName) { - var yamlFile = path.resolve(samplesDir, sampleName); - - it(path.basename(sampleName, '.yml'), function () { - var yamlSource = fs.readFileSync(yamlFile, { encoding: 'utf8' }); - - assert.throws(function () { - yaml.loadAll( - yamlSource, - function () {}, - { - filename: yamlFile, - schema: TEST_SCHEMA, - onWarning: function (e) { throw e; } - } - ); - }, yaml.YAMLException, yamlFile); - }); - }); -}); diff --git a/test/20-dumper.js b/test/20-dumper.js deleted file mode 100644 index bca822d3..00000000 --- a/test/20-dumper.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); -var yaml = require('../'); - -var TEST_SCHEMA = require('./support/schema').TEST_SCHEMA; - - -describe('Dumper', function () { - var samplesDir = path.resolve(__dirname, 'samples-common'); - - fs.readdirSync(samplesDir).forEach(function (jsFile) { - if (path.extname(jsFile) !== '.js') return; // continue - - it(path.basename(jsFile, '.js'), function () { - var sample = require(path.resolve(samplesDir, jsFile)); - var data = typeof sample === 'function' ? sample.expected : sample, - serialized = yaml.dump(data, { schema: TEST_SCHEMA }), - deserialized = yaml.load(serialized, { schema: TEST_SCHEMA }); - - if (typeof sample === 'function') { - sample.call(this, deserialized); - } else { - assert.deepStrictEqual(deserialized, sample); - } - }); - }); -}); diff --git a/test/30-issues.js b/test/30-issues.js deleted file mode 100644 index 4a4095ab..00000000 --- a/test/30-issues.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - - -var path = require('path'); -var fs = require('fs'); - - -describe('Issues', function () { - var issues = path.resolve(__dirname, 'issues'); - - fs.readdirSync(issues).forEach(function (file) { - if (path.extname(file) === '.js') { - require(path.resolve(issues, file)); - } - }); -}); diff --git a/test/build/dist.test.js b/test/build/dist.test.js new file mode 100644 index 00000000..14a4076e --- /dev/null +++ b/test/build/dist.test.js @@ -0,0 +1,82 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const fs = require('fs') +const path = require('path') +const vm = require('vm') + +const distDir = path.resolve(__dirname, '../../dist') + +const expectedKeys = [ + 'CORE_SCHEMA', + 'DEFAULT_SCHEMA', + 'FAILSAFE_SCHEMA', + 'JSON_SCHEMA', + 'Schema', + 'Type', + 'YAMLException', + 'default', + 'dump', + 'load', + 'loadAll', + 'safeDump', + 'safeLoad', + 'safeLoadAll', + 'types' +] + +function checkExports (yaml, options) { + assert.deepStrictEqual(Object.keys(yaml).sort(), expectedKeys.slice().sort()) + assert.strictEqual(yaml.default.load, yaml.load) + assert.strictEqual(yaml.load('a: 1').a, 1) + assert.strictEqual(typeof yaml.dump, 'function') + assert.strictEqual(typeof yaml.types.binary, 'object') + + if (options && options.checkEsModule) { + assert.strictEqual(yaml.__esModule, true) + } +} + +function loadGlobal (filename) { + const context = {} + + vm.runInNewContext(fs.readFileSync(path.join(distDir, filename), 'utf8'), context) + + return context.jsyaml +} + +describe('dist build', function () { + it('keeps Vite proxy exports in sync with the CommonJS entry', async function () { + const yaml = require('../../index.js') + const proxy = await import('../../lib/index_vite_proxy.tmp.mjs') + + assert.deepStrictEqual(Object.keys(proxy).sort(), Object.keys(yaml).concat('default').sort()) + assert.strictEqual(proxy.default, yaml) + + Object.keys(yaml).forEach(function (key) { + assert.strictEqual(proxy[key], yaml[key]) + }) + }) + + it('exports the expected UMD API from js-yaml.js', function () { + checkExports(require('../../dist/js-yaml.js'), { checkEsModule: true }) + }) + + it('exports the expected UMD API from js-yaml.min.js', function () { + checkExports(require('../../dist/js-yaml.min.js'), { checkEsModule: true }) + }) + + it('exports the expected ESM API from js-yaml.mjs', async function () { + checkExports(await import('../../dist/js-yaml.mjs')) + }) + + it('exposes the expected browser global from js-yaml.js', function () { + checkExports(loadGlobal('js-yaml.js')) + }) + + it('exposes the expected browser global from js-yaml.min.js', function () { + checkExports(loadGlobal('js-yaml.min.js')) + }) +}) diff --git a/test/core/00-units.test.js b/test/core/00-units.test.js new file mode 100644 index 00000000..6dd30aad --- /dev/null +++ b/test/core/00-units.test.js @@ -0,0 +1,16 @@ +'use strict' + +const { describe } = require('node:test') + +const path = require('path') +const fs = require('fs') + +describe('Units', function () { + const directory = path.resolve(__dirname, 'units') + + fs.readdirSync(directory).forEach(function (file) { + if (path.extname(file) === '.js') { + require(path.resolve(directory, file)) + } + }) +}) diff --git a/test/core/10-loader.test.js b/test/core/10-loader.test.js new file mode 100644 index 00000000..3a11ea3d --- /dev/null +++ b/test/core/10-loader.test.js @@ -0,0 +1,38 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const path = require('path') +const fs = require('fs') +const yaml = require('js-yaml') + +const TEST_SCHEMA = require('./support/schema').TEST_SCHEMA + +describe('Loader', function () { + const samplesDir = path.resolve(__dirname, 'samples-common') + + fs.readdirSync(samplesDir).forEach(function (jsFile) { + if (path.extname(jsFile) !== '.js') return // continue + + const yamlFile = path.resolve(samplesDir, path.basename(jsFile, '.js') + '.yml') + + it(path.basename(jsFile, '.js'), function () { + const expected = require(path.resolve(samplesDir, jsFile)) + let actual = [] + + yaml.loadAll(fs.readFileSync(yamlFile, { encoding: 'utf8' }), function (doc) { actual.push(doc) }, { + filename: yamlFile, + schema: TEST_SCHEMA + }) + + if (actual.length === 1) actual = actual[0] + + if (typeof expected === 'function') { + expected.call(this, actual) + } else { + assert.deepStrictEqual(actual, expected) + } + }) + }) +}) diff --git a/test/core/11-load-errors.test.js b/test/core/11-load-errors.test.js new file mode 100644 index 00000000..8d7ebd70 --- /dev/null +++ b/test/core/11-load-errors.test.js @@ -0,0 +1,34 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const path = require('path') +const fs = require('fs') +const yaml = require('js-yaml') + +const TEST_SCHEMA = require('./support/schema').TEST_SCHEMA + +describe('Load errors', function () { + const samplesDir = path.resolve(__dirname, 'samples-load-errors') + + fs.readdirSync(samplesDir).forEach(function (sampleName) { + const yamlFile = path.resolve(samplesDir, sampleName) + + it(path.basename(sampleName, '.yml'), function () { + const yamlSource = fs.readFileSync(yamlFile, { encoding: 'utf8' }) + + assert.throws(function () { + yaml.loadAll( + yamlSource, + function () {}, + { + filename: yamlFile, + schema: TEST_SCHEMA, + onWarning: function (e) { throw e } + } + ) + }, yaml.YAMLException, yamlFile) + }) + }) +}) diff --git a/test/core/20-dumper.test.js b/test/core/20-dumper.test.js new file mode 100644 index 00000000..75b7dd4d --- /dev/null +++ b/test/core/20-dumper.test.js @@ -0,0 +1,31 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const path = require('path') +const fs = require('fs') +const yaml = require('js-yaml') + +const TEST_SCHEMA = require('./support/schema').TEST_SCHEMA + +describe('Dumper', function () { + const samplesDir = path.resolve(__dirname, 'samples-common') + + fs.readdirSync(samplesDir).forEach(function (jsFile) { + if (path.extname(jsFile) !== '.js') return // continue + + it(path.basename(jsFile, '.js'), function () { + const sample = require(path.resolve(samplesDir, jsFile)) + const data = typeof sample === 'function' ? sample.expected : sample + const serialized = yaml.dump(data, { schema: TEST_SCHEMA }) + const deserialized = yaml.load(serialized, { schema: TEST_SCHEMA }) + + if (typeof sample === 'function') { + sample.call(this, deserialized) + } else { + assert.deepStrictEqual(deserialized, sample) + } + }) + }) +}) diff --git a/test/25-dumper-fuzzy.js b/test/core/25-dumper-fuzzy.test.js similarity index 56% rename from test/25-dumper-fuzzy.js rename to test/core/25-dumper-fuzzy.test.js index 8bbf5e77..1739b358 100644 --- a/test/25-dumper-fuzzy.js +++ b/test/core/25-dumper-fuzzy.test.js @@ -1,37 +1,39 @@ -'use strict'; +'use strict' -var assert = require('assert'); -var fc = require('fast-check'); -var yaml = require('../'); +const { describe, it } = require('node:test') + +const assert = require('assert') +const fc = require('fast-check') +const yaml = require('js-yaml') // Generate valid YAML instances for yaml.safeDump -var key = fc.string16bits(); -var values = [ +const key = fc.string({ unit: fc.nat({ max: 0xffff }).map(n => String.fromCharCode(n)) }) +const values = [ key, fc.boolean(), fc.integer(), fc.double(), fc.constantFrom(null, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) -]; -var yamlArbitrary = fc.object({ key: key, values: values }); +] +const yamlArbitrary = fc.object({ key: key, values: values }) // Generate valid options for yaml.safeDump configuration -var dumpOptionsArbitrary = fc.record({ +const dumpOptionsArbitrary = fc.record({ skipInvalid: fc.boolean(), sortKeys: fc.boolean(), noRefs: fc.boolean(), noCompatMode: fc.boolean(), condenseFlow: fc.boolean(), - indent: fc.integer(1, 80), - flowLevel: fc.integer(-1, 10), + indent: fc.integer({ min: 1, max: 80 }), + flowLevel: fc.integer({ min: -1, max: 10 }), styles: fc.record({ '!!null': fc.constantFrom('lowercase', 'canonical', 'uppercase', 'camelcase'), '!!int': fc.constantFrom('decimal', 'binary', 'octal', 'hexadecimal'), '!!bool': fc.constantFrom('lowercase', 'uppercase', 'camelcase'), '!!float': fc.constantFrom('lowercase', 'uppercase', 'camelcase') - }, { with_deleted_keys: true }) -}, { with_deleted_keys: true }) + }, { requiredKeys: [] }) +}, { requiredKeys: [] }) .map(function (instance) { - if (instance.condenseFlow === true && instance.flowLevel !== undefined) { instance.flowLevel = -1; } - return instance; - }); + if (instance.condenseFlow === true && instance.flowLevel !== undefined) { instance.flowLevel = -1 } + return instance + }) describe('Properties', function () { it('Load from dumped should be the original object', function () { @@ -39,9 +41,9 @@ describe('Properties', function () { yamlArbitrary, dumpOptionsArbitrary, function (obj, dumpOptions) { - var yamlContent = yaml.dump(obj, dumpOptions); - assert.ok(typeof yamlContent === 'string'); - assert.deepStrictEqual(yaml.load(yamlContent), obj); - })); - }); -}); + const yamlContent = yaml.dump(obj, dumpOptions) + assert.ok(typeof yamlContent === 'string') + assert.deepStrictEqual(yaml.load(yamlContent), obj) + })) + }) +}) diff --git a/test/core/30-issues.test.js b/test/core/30-issues.test.js new file mode 100644 index 00000000..4ff041d7 --- /dev/null +++ b/test/core/30-issues.test.js @@ -0,0 +1,16 @@ +'use strict' + +const { describe } = require('node:test') + +const path = require('path') +const fs = require('fs') + +describe('Issues', function () { + const issues = path.resolve(__dirname, 'issues') + + fs.readdirSync(issues).forEach(function (file) { + if (path.extname(file) === '.js') { + require(path.resolve(issues, file)) + } + }) +}) diff --git a/test/core/issues/0008.js b/test/core/issues/0008.js new file mode 100644 index 00000000..ac4fb3ad --- /dev/null +++ b/test/core/issues/0008.js @@ -0,0 +1,14 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Parse failed when no document start present', function () { + assert.doesNotThrow(function () { + yaml.load(` +foo: !!str bar +`) + }, TypeError) +}) diff --git a/test/core/issues/0017.js b/test/core/issues/0017.js new file mode 100644 index 00000000..6f0c102f --- /dev/null +++ b/test/core/issues/0017.js @@ -0,0 +1,14 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Non-specific "!" tags should resolve to !!str', function () { + const data = yaml.load(` +! 12 +`) + + assert.strictEqual(typeof data, 'string') +}) diff --git a/test/issues/0019.js b/test/core/issues/0019.js similarity index 57% rename from test/issues/0019.js rename to test/core/issues/0019.js index 1314a228..6a087ba6 100644 --- a/test/issues/0019.js +++ b/test/core/issues/0019.js @@ -1,17 +1,17 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('Timestamp parsing is one month off', function () { - var data = yaml.load(` + const data = yaml.load(` --- xmas: 2011-12-24 ... -`); +`) // JS month starts with 0 (0 => Jan, 1 => Feb, ...) - assert.strictEqual(data.xmas.getTime(), Date.UTC(2011, 11, 24)); -}); + assert.strictEqual(data.xmas.getTime(), Date.UTC(2011, 11, 24)) +}) diff --git a/test/core/issues/0026.js b/test/core/issues/0026.js new file mode 100644 index 00000000..01236d31 --- /dev/null +++ b/test/core/issues/0026.js @@ -0,0 +1,17 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should convert new line into white space', function () { + const data = yaml.load(` +test: > + a + b + c +`) + + assert.strictEqual(data.test, 'a b c\n') +}) diff --git a/test/core/issues/0027.js b/test/core/issues/0027.js new file mode 100644 index 00000000..f4b29092 --- /dev/null +++ b/test/core/issues/0027.js @@ -0,0 +1,55 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +describe('Should load numbers in YAML 1.2 format', function () { + it('should not parse base60', function () { + // previously parsed as int + assert.strictEqual(yaml.load('1:23'), '1:23') + // previously parsed as float + assert.strictEqual(yaml.load('1:23.45'), '1:23.45') + }) + + it('should allow leading zero in int and float', function () { + assert.strictEqual(yaml.load('01234'), 1234) + assert.strictEqual(yaml.load('00999'), 999) + assert.strictEqual(yaml.load('-00999'), -999) + assert.strictEqual(yaml.load('001234.56'), 1234.56) + assert.strictEqual(yaml.load('001234e4'), 12340000) + assert.strictEqual(yaml.load('-001234.56'), -1234.56) + assert.strictEqual(yaml.load('-001234e4'), -12340000) + }) + + it('should parse 0o prefix as octal', function () { + assert.strictEqual(yaml.load('0o1234'), 668) + // not valid octal + assert.strictEqual(yaml.load('0o1289'), '0o1289') + }) +}) + +describe('Should dump numbers in YAML 1.2 format', function () { + it('should dump in different styles', function () { + assert.strictEqual(yaml.dump(123, { styles: { '!!int': 'binary' } }), '0b1111011\n') + assert.strictEqual(yaml.dump(123, { styles: { '!!int': 'octal' } }), '0o173\n') + assert.strictEqual(yaml.dump(123, { styles: { '!!int': 'hex' } }), '0x7B\n') + }) + + it('should quote all potential numbers', function () { + const tests = '1:23 1:23.45 01234 0999 -01234 01234e4 01234.56 -01234.56 0x123 0o123' + + tests.split(' ').forEach(function (sample) { + assert.strictEqual(yaml.dump(sample, { noCompatMode: false }), "'" + sample + "'\n") + }) + }) + + it('should not quote base60 in noCompatMode', function () { + const tests = '1:23 1:23.45' + + tests.split(' ').forEach(function (sample) { + assert.strictEqual(yaml.dump(sample, { noCompatMode: true }), sample + '\n') + }) + }) +}) diff --git a/test/core/issues/0033.js b/test/core/issues/0033.js new file mode 100644 index 00000000..0744e26a --- /dev/null +++ b/test/core/issues/0033.js @@ -0,0 +1,16 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('refactor compact variant of MarkedYAMLError.toString', function () { + const source = ` +foo: {bar} baz +` + + assert.throws(function () { + yaml.load(source) + }, "require('issue-33.yml') should throw, but it does not") +}) diff --git a/test/core/issues/0046.js b/test/core/issues/0046.js new file mode 100644 index 00000000..c8541e5e --- /dev/null +++ b/test/core/issues/0046.js @@ -0,0 +1,30 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Timestamps are incorrectly parsed in local time', function () { + const src = ` +date1: 2010-10-20T20:45:00Z +date2: 2010-10-20T20:45:00+01:00 +` + const data = yaml.load(src) + + const date1 = data.date1 // date1: 2010-10-20T20:45:00Z + assert.strictEqual(date1.getUTCFullYear(), 2010, 'year') + assert.strictEqual(date1.getUTCMonth(), 9, 'month') + assert.strictEqual(date1.getUTCDate(), 20, 'date') + assert.strictEqual(date1.getUTCHours(), 20) + assert.strictEqual(date1.getUTCMinutes(), 45) + assert.strictEqual(date1.getUTCSeconds(), 0) + + const date2 = data.date2 // date2: 2010-10-20T20:45:00+0100 + assert.strictEqual(date2.getUTCFullYear(), 2010, 'year') + assert.strictEqual(date2.getUTCMonth(), 9, 'month') + assert.strictEqual(date2.getUTCDate(), 20, 'date') + assert.strictEqual(date2.getUTCHours(), 19) + assert.strictEqual(date2.getUTCMinutes(), 45) + assert.strictEqual(date2.getUTCSeconds(), 0) +}) diff --git a/test/issues/0054.js b/test/core/issues/0054.js similarity index 96% rename from test/issues/0054.js rename to test/core/issues/0054.js index ac7c09af..5c94abed 100644 --- a/test/issues/0054.js +++ b/test/core/issues/0054.js @@ -1,12 +1,12 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it("Incorrect utf-8 handling on require('file.yaml')", function () { - var data = yaml.load(` + const data = yaml.load(` - ууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууу - ууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууу - ууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууу @@ -48,22 +48,21 @@ it("Incorrect utf-8 handling on require('file.yaml')", function () { - ууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууу - ууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууу - ууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууууу -`); - var expected = '', - index; +`) + let expected = '' // // document is an array of 40 elements // each element is a string of 100 `у` (Russian letter) chars // - for (index = 0; index <= 100; index += 1) { - expected += 'у'; + for (let index = 0; index <= 100; index += 1) { + expected += 'у' } // // make sure none of the strings were corrupted. // - for (index = 0; index < 40; index += 1) { - assert.strictEqual(data[index], expected, ('Line ' + index + ' is corrupted')); + for (let index = 0; index < 40; index += 1) { + assert.strictEqual(data[index], expected, ('Line ' + index + ' is corrupted')) } -}); +}) diff --git a/test/core/issues/0063.js b/test/core/issues/0063.js new file mode 100644 index 00000000..69cdc6eb --- /dev/null +++ b/test/core/issues/0063.js @@ -0,0 +1,23 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Invalid errors/warnings of invalid indentation on flow scalars', function () { + const sources = [ + 'text:\n hello\n world', // plain style + "text:\n 'hello\n world'", // single-quoted style + 'text:\n "hello\n world"' // double-quoted style + ] + const expected = { text: 'hello world' } + + assert.doesNotThrow(function () { yaml.load(sources[0]) }, 'Throws on plain style') + assert.doesNotThrow(function () { yaml.load(sources[1]) }, 'Throws on single-quoted style') + assert.doesNotThrow(function () { yaml.load(sources[2]) }, 'Throws on double-quoted style') + + assert.deepStrictEqual(yaml.load(sources[0]), expected) + assert.deepStrictEqual(yaml.load(sources[1]), expected) + assert.deepStrictEqual(yaml.load(sources[2]), expected) +}) diff --git a/test/core/issues/0064.js b/test/core/issues/0064.js new file mode 100644 index 00000000..729ed56a --- /dev/null +++ b/test/core/issues/0064.js @@ -0,0 +1,13 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') +const readFileSync = require('fs').readFileSync + +it('Wrong error message when yaml file contains tabs', function () { + assert.doesNotThrow( + function () { yaml.load(readFileSync(require('path').join(__dirname, '/0064.yml'), 'utf8')) }, + yaml.YAMLException) +}) diff --git a/test/issues/0064.yml b/test/core/issues/0064.yml similarity index 100% rename from test/issues/0064.yml rename to test/core/issues/0064.yml diff --git a/test/core/issues/0068.js b/test/core/issues/0068.js new file mode 100644 index 00000000..9b7b714a --- /dev/null +++ b/test/core/issues/0068.js @@ -0,0 +1,11 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Prevent adding unnecessary space character to end of a line within block collections', function () { + assert.strictEqual(yaml.dump({ data: ['foo', 'bar', 'baz'] }), 'data:\n - foo\n - bar\n - baz\n') + assert.strictEqual(yaml.dump({ foo: { bar: ['baz'] } }), 'foo:\n bar:\n - baz\n') +}) diff --git a/test/issues/0080.js b/test/core/issues/0080.js similarity index 64% rename from test/issues/0080.js rename to test/core/issues/0080.js index a0bf3361..cf320d42 100644 --- a/test/issues/0080.js +++ b/test/core/issues/0080.js @@ -1,73 +1,71 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('should throw when tabs are used as indentation', function () { assert.throws(() => yaml.load(` \tfoo: 1 bar: 2 -`), /end of the stream or a document separator is expected/); +`), /end of the stream or a document separator is expected/) assert.throws(() => yaml.load(` foo: 1 \tbar: 2 -`), /tab characters must not be used/); +`), /tab characters must not be used/) assert.throws(() => yaml.load(` \t- foo - bar -`), /end of the stream or a document separator is expected/); +`), /end of the stream or a document separator is expected/) assert.throws(() => yaml.load(` - foo \t- bar -`), /tab characters must not be used/); -}); - +`), /tab characters must not be used/) +}) it('should allow tabs inside separation spaces', function () { assert.deepStrictEqual(yaml.load(` foo\t \t:\t \t1\t \t \t \t \t bar \t : \t 2 \t -`), { foo: 1, bar: 2 }); +`), { foo: 1, bar: 2 }) assert.deepStrictEqual(yaml.load(` -\t \tfoo\t \t \t \t \t - \t bar \t -`), [ 'foo', 'bar' ]); +`), ['foo', 'bar']) assert.deepStrictEqual(yaml.load(` \t{\tfoo\t:\t1\t,\tbar\t:\t2\t}\t -`), { foo: 1, bar: 2 }); +`), { foo: 1, bar: 2 }) assert.deepStrictEqual(yaml.load(` \t[\tfoo\t,\tbar\t]\t -`), [ 'foo', 'bar' ]); +`), ['foo', 'bar']) assert.deepStrictEqual(yaml.load(` foo: # string indent = 1 \t \t1 \t 2 \t \t3 -`), { foo: '1 2 3' }); -}); - +`), { foo: '1 2 3' }) +}) it('should throw when tabs are used as indentation in strings', function () { assert.throws(() => yaml.load(` foo: bar: | \tbaz -`), /tab characters must not be used/); +`), /tab characters must not be used/) assert.deepStrictEqual(yaml.load(` foo: bar: | \tbaz -`), { foo: { bar: '\tbaz\n' } }); -}); +`), { foo: { bar: '\tbaz\n' } }) +}) diff --git a/test/issues/0085.js b/test/core/issues/0085.js similarity index 66% rename from test/issues/0085.js rename to test/core/issues/0085.js index 0172b04c..1cb0a7c2 100644 --- a/test/issues/0085.js +++ b/test/core/issues/0085.js @@ -1,24 +1,22 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); +const assert = require('assert') +const yaml = require('js-yaml') - -var DEPRECATED_BOOLEANS_SYNTAX = [ +const DEPRECATED_BOOLEANS_SYNTAX = [ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' -]; - +] it('Dumper should take into account booleans syntax from YAML 1.0/1.1', function () { DEPRECATED_BOOLEANS_SYNTAX.forEach(function (string) { - var dump = yaml.dump(string).trim(); + const dump = yaml.dump(string).trim() assert( ((dump === "'" + string + "'") || (dump === '"' + string + '"')), ('"' + string + '" string is dumped without quoting; actual dump: ' + dump) - ); - }); -}); - + ) + }) +}) diff --git a/test/core/issues/0092.js b/test/core/issues/0092.js new file mode 100644 index 00000000..662c5ebc --- /dev/null +++ b/test/core/issues/0092.js @@ -0,0 +1,12 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Invalid parse error on whitespace between quoted scalar keys and ":" symbol in mappings', function () { + assert.doesNotThrow(function () { + yaml.load('{ "field1" : "v1", "field2": "v2" }') + }) +}) diff --git a/test/core/issues/0093.js b/test/core/issues/0093.js new file mode 100644 index 00000000..564a1429 --- /dev/null +++ b/test/core/issues/0093.js @@ -0,0 +1,40 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Unwanted line breaks in folded scalars', function () { + const data = yaml.load(` +first: > + a + b + c + d + e + f + +second: > + a + b + c + + d + e + f + +third: > + a + b + + c + d + e + f +`) + + assert.strictEqual(data.first, 'a b\n c\n d\ne f\n') + assert.strictEqual(data.second, 'a b\n c\n\n d\ne f\n') + assert.strictEqual(data.third, 'a b\n\n c\n d\ne f\n') +}) diff --git a/test/core/issues/0095.js b/test/core/issues/0095.js new file mode 100644 index 00000000..61823650 --- /dev/null +++ b/test/core/issues/0095.js @@ -0,0 +1,24 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Empty block scalars loaded wrong', function () { + assert.deepStrictEqual(yaml.load('a: |\nb: .'), { a: '', b: '.' }) + assert.deepStrictEqual(yaml.load('a: |+\nb: .'), { a: '', b: '.' }) + assert.deepStrictEqual(yaml.load('a: |-\nb: .'), { a: '', b: '.' }) + + assert.deepStrictEqual(yaml.load('a: >\nb: .'), { a: '', b: '.' }) + assert.deepStrictEqual(yaml.load('a: >+\nb: .'), { a: '', b: '.' }) + assert.deepStrictEqual(yaml.load('a: >-\nb: .'), { a: '', b: '.' }) + + assert.deepStrictEqual(yaml.load('a: |\n\nb: .'), { a: '', b: '.' }) + assert.deepStrictEqual(yaml.load('a: |+\n\nb: .'), { a: '\n', b: '.' }) + assert.deepStrictEqual(yaml.load('a: |-\n\nb: .'), { a: '', b: '.' }) + + assert.deepStrictEqual(yaml.load('a: >\n\nb: .'), { a: '', b: '.' }) + assert.deepStrictEqual(yaml.load('a: >+\n\nb: .'), { a: '\n', b: '.' }) + assert.deepStrictEqual(yaml.load('a: >-\n\nb: .'), { a: '', b: '.' }) +}) diff --git a/test/core/issues/0108.js b/test/core/issues/0108.js new file mode 100644 index 00000000..a8a399c5 --- /dev/null +++ b/test/core/issues/0108.js @@ -0,0 +1,12 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Literal scalars have an unwanted leading line break', function () { + assert.strictEqual(yaml.load('|\n foobar\n'), 'foobar\n') + assert.strictEqual(yaml.load('|\n hello\n world\n'), 'hello\nworld\n') + assert.strictEqual(yaml.load('|\n war never changes\n'), 'war never changes\n') +}) diff --git a/test/core/issues/0110.js b/test/core/issues/0110.js new file mode 100644 index 00000000..b6eb838e --- /dev/null +++ b/test/core/issues/0110.js @@ -0,0 +1,28 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Circular and cross references', function () { + const source = { + a: { a: 1 }, + b: [1, 2], + c: {}, + d: [] + } + source.crossObject = source.a + source.crossArray = source.b + source.c.circularObject = source + source.d.push(source.d) + source.d.push(source) + + const obtained = yaml.load(yaml.dump(source)) + + assert.strictEqual(obtained.crossObject, obtained.a) + assert.strictEqual(obtained.crossArray, obtained.b) + assert.strictEqual(obtained.c.circularObject, obtained) + assert.strictEqual(obtained.d[0], obtained.d) + assert.strictEqual(obtained.d[1], obtained) +}) diff --git a/test/core/issues/0112.js b/test/core/issues/0112.js new file mode 100644 index 00000000..28c8b6e4 --- /dev/null +++ b/test/core/issues/0112.js @@ -0,0 +1,14 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Plain scalar "constructor" parsed as `null`', function () { + assert.strictEqual(yaml.load('constructor'), 'constructor') + assert.deepStrictEqual(yaml.load('constructor: value'), { constructor: 'value' }) + assert.deepStrictEqual(yaml.load('key: constructor'), { key: 'constructor' }) + assert.deepStrictEqual(yaml.load('{ constructor: value }'), { constructor: 'value' }) + assert.deepStrictEqual(yaml.load('{ key: constructor }'), { key: 'constructor' }) +}) diff --git a/test/core/issues/0117.js b/test/core/issues/0117.js new file mode 100644 index 00000000..32b763e8 --- /dev/null +++ b/test/core/issues/0117.js @@ -0,0 +1,10 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Negative zero loses the sign after dump', function () { + assert.strictEqual(yaml.dump(-0), '-0.0\n') +}) diff --git a/test/core/issues/0144.js b/test/core/issues/0144.js new file mode 100644 index 00000000..5d9b741d --- /dev/null +++ b/test/core/issues/0144.js @@ -0,0 +1,10 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Infinite loop when attempting to parse multi-line scalar document that is not indented', function () { + assert.strictEqual(yaml.load('--- |\nfoo\n'), 'foo\n') +}) diff --git a/test/issues/0154.js b/test/core/issues/0154.js similarity index 68% rename from test/issues/0154.js rename to test/core/issues/0154.js index 05115e9f..1d34079a 100644 --- a/test/issues/0154.js +++ b/test/core/issues/0154.js @@ -1,13 +1,13 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('Indentation warning on empty lines within quoted scalars and flow collections', function () { - assert.doesNotThrow(function () { yaml.load("- 'hello\n\n world'"); }); - assert.doesNotThrow(function () { yaml.load('- "hello\n\n world"'); }); - assert.doesNotThrow(function () { yaml.load('- [hello,\n\n world]'); }); - assert.doesNotThrow(function () { yaml.load('- {hello: world,\n\n foo: bar}'); }); -}); + assert.doesNotThrow(function () { yaml.load("- 'hello\n\n world'") }) + assert.doesNotThrow(function () { yaml.load('- "hello\n\n world"') }) + assert.doesNotThrow(function () { yaml.load('- [hello,\n\n world]') }) + assert.doesNotThrow(function () { yaml.load('- {hello: world,\n\n foo: bar}') }) +}) diff --git a/test/core/issues/0155.js b/test/core/issues/0155.js new file mode 100644 index 00000000..91ac6553 --- /dev/null +++ b/test/core/issues/0155.js @@ -0,0 +1,10 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Named null', function () { + assert.deepStrictEqual(yaml.load('---\ntest: !!null \nfoo: bar'), { test: null, foo: 'bar' }) +}) diff --git a/test/core/issues/0156.js b/test/core/issues/0156.js new file mode 100644 index 00000000..d10c8e17 --- /dev/null +++ b/test/core/issues/0156.js @@ -0,0 +1,19 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +function SuccessSignal () {} + +const TestClassYaml = new yaml.Type('!test', { + kind: 'scalar', + resolve: function () { throw new SuccessSignal() } +}) + +const TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([TestClassYaml]) + +it('Resolving of empty nodes are skipped in some cases', function () { + assert.throws(function () { yaml.load('- foo: !test\n- bar: baz', { schema: TEST_SCHEMA }) }, SuccessSignal) +}) diff --git a/test/core/issues/0160.js b/test/core/issues/0160.js new file mode 100644 index 00000000..33da714e --- /dev/null +++ b/test/core/issues/0160.js @@ -0,0 +1,10 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Correct encoding of UTF-16 surrogate pairs', function () { + assert.strictEqual(yaml.load('"\\U0001F431"'), '🐱') +}) diff --git a/test/issues/0164.js b/test/core/issues/0164.js similarity index 58% rename from test/issues/0164.js rename to test/core/issues/0164.js index 8240318d..5307595f 100644 --- a/test/issues/0164.js +++ b/test/core/issues/0164.js @@ -1,30 +1,29 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('should define __proto__ as a value (not invoke setter)', function () { - let object = yaml.load('{ __proto__: {polluted: bar} }'); - - assert.strictEqual(({}).hasOwnProperty.call(yaml.load('{}'), '__proto__'), false); - assert.strictEqual(({}).hasOwnProperty.call(object, '__proto__'), true); - assert(!object.polluted); -}); + const object = yaml.load('{ __proto__: {polluted: bar} }') + assert.strictEqual(({}).hasOwnProperty.call(yaml.load('{}'), '__proto__'), false) + assert.strictEqual(({}).hasOwnProperty.call(object, '__proto__'), true) + assert(!object.polluted) +}) it('should merge __proto__ as a value with << operator', function () { - let object = yaml.load(` + const object = yaml.load(` payload: &ref polluted: bar foo: <<: __proto__: *ref - `); + `) - assert.strictEqual(({}).hasOwnProperty.call(yaml.load('{}'), '__proto__'), false); - assert.strictEqual(({}).hasOwnProperty.call(object.foo, '__proto__'), true); - assert(!object.foo.polluted); -}); + assert.strictEqual(({}).hasOwnProperty.call(yaml.load('{}'), '__proto__'), false) + assert.strictEqual(({}).hasOwnProperty.call(object.foo, '__proto__'), true) + assert(!object.foo.polluted) +}) diff --git a/test/core/issues/0194.js b/test/core/issues/0194.js new file mode 100644 index 00000000..4e89929e --- /dev/null +++ b/test/core/issues/0194.js @@ -0,0 +1,23 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Don\'t throw on warning', function () { + const src = ` +foo: { + bar: true +} +` + const warnings = [] + + const data = yaml.load(src) + + assert.deepStrictEqual(data, { foo: { bar: true } }) + + yaml.load(src, { onWarning: function (e) { warnings.push(e) } }) + + assert.strictEqual(warnings.length, 1) +}) diff --git a/test/core/issues/0203.js b/test/core/issues/0203.js new file mode 100644 index 00000000..61fec6ab --- /dev/null +++ b/test/core/issues/0203.js @@ -0,0 +1,18 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Don\'t throw on warning', function () { + const src = ` +test: |- + + + Hello + world +` + + assert.deepStrictEqual(yaml.load(src), { test: '\n\nHello\nworld' }) +}) diff --git a/test/core/issues/0205.js b/test/core/issues/0205.js new file mode 100644 index 00000000..01967012 --- /dev/null +++ b/test/core/issues/0205.js @@ -0,0 +1,27 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Duplicated objects within array', function () { + const obj = { test: 'canary' } + const arrayWithRefs = [obj, obj] + + const obtained = yaml.load(yaml.dump(arrayWithRefs)) + + assert.strictEqual(obtained[0].test, 'canary') + assert.strictEqual(obtained[0], obtained[1]) +}) + +it('Duplicated arrays within array', function () { + const array = [0, 1] + const arrayWithRefs = [array, array] + + const obtained = yaml.load(yaml.dump(arrayWithRefs)) + + assert.strictEqual(obtained[0][0], 0) + assert.strictEqual(obtained[0][1], 1) + assert.strictEqual(obtained[0], obtained[1]) +}) diff --git a/test/core/issues/0220.js b/test/core/issues/0220.js new file mode 100644 index 00000000..0d203214 --- /dev/null +++ b/test/core/issues/0220.js @@ -0,0 +1,14 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Float type dumper should not miss dot', function () { + assert.strictEqual(5e-100.toString(10), '5e-100') + assert.strictEqual(0.5e-100.toString(10), '5e-101') + + assert.strictEqual(yaml.dump(0.5e-100), '5.e-101\n') + assert.strictEqual(yaml.load(yaml.dump(5e-100)), 5e-100) +}) diff --git a/test/core/issues/0221.js b/test/core/issues/0221.js new file mode 100644 index 00000000..c4316d37 --- /dev/null +++ b/test/core/issues/0221.js @@ -0,0 +1,11 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it.skip('Block scalar chomping does not work on zero indent', function () { + assert.throws(function () { yaml.load('|-\nfoo\nbar') }, yaml.YAMLException) + assert.deepStrictEqual(yaml.dump('foo\nbar'), '|-\n foo\nbar') +}) diff --git a/test/issues/0235.js b/test/core/issues/0235.js similarity index 68% rename from test/issues/0235.js rename to test/core/issues/0235.js index 6fc94de9..034541fb 100644 --- a/test/issues/0235.js +++ b/test/core/issues/0235.js @@ -1,13 +1,15 @@ -'use strict'; +'use strict' -var assert = require('assert'); -var yaml = require('../../'); +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') it('Flow style does not dump with block literals.', function () { - assert.strictEqual(yaml.dump({ a: '\n' }, { flowLevel: 0 }), '{a: "\\n"}\n'); -}); + assert.strictEqual(yaml.dump({ a: '\n' }, { flowLevel: 0 }), '{a: "\\n"}\n') +}) it('Ok to dump block-style literals when not yet flowing.', function () { // cf. example 8.6 from the YAML 1.2 spec - assert.strictEqual(yaml.dump({ a: '\n' }, { flowLevel: 2 }), 'a: |+\n\n'); -}); + assert.strictEqual(yaml.dump({ a: '\n' }, { flowLevel: 2 }), 'a: |+\n\n') +}) diff --git a/test/issues/0243-basic.yml b/test/core/issues/0243-basic.yml similarity index 100% rename from test/issues/0243-basic.yml rename to test/core/issues/0243-basic.yml diff --git a/test/issues/0243-nested.yml b/test/core/issues/0243-nested.yml similarity index 100% rename from test/issues/0243-nested.yml rename to test/core/issues/0243-nested.yml diff --git a/test/core/issues/0243.js b/test/core/issues/0243.js new file mode 100644 index 00000000..9597e351 --- /dev/null +++ b/test/core/issues/0243.js @@ -0,0 +1,53 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') +const readFileSync = require('fs').readFileSync + +describe('Duplicated mapping key errors throw at beginning of key', function () { + it('on top level', function () { + const src = readFileSync(require('path').join(__dirname, '/0243-basic.yml'), 'utf8') + const lines = src.split('\n') + + try { + yaml.load(src) + } catch (e) { + assert.strictEqual(lines[e.mark.line], 'duplicate: # 2') + assert.strictEqual(e.mark.line, 9) + assert.strictEqual(e.mark.column, 0) + } + }) + + it('inside of mapping values', function () { + const src = readFileSync(require('path').join(__dirname, '/0243-nested.yml'), 'utf8') + const lines = src.split('\n') + + try { + yaml.load(src) + } catch (e) { + assert.strictEqual(lines[e.mark.line], ' duplicate: # 2') + assert.strictEqual(e.mark.line, 9) + assert.strictEqual(e.mark.column, 2) + } + }) + + it('inside flow collection', function () { + try { + yaml.load('{ foo: 123, foo: 456 }') + } catch (e) { + assert.strictEqual(e.mark.line, 0) + assert.strictEqual(e.mark.column, 12) + } + }) + + it('inside a set', function () { + try { + yaml.load(' ? foo\n ? foo\n ? bar') + } catch (e) { + assert.strictEqual(e.mark.line, 1) + assert.strictEqual(e.mark.column, 4) + } + }) +}) diff --git a/test/core/issues/0248-listener.js b/test/core/issues/0248-listener.js new file mode 100644 index 00000000..3ba28f6c --- /dev/null +++ b/test/core/issues/0248-listener.js @@ -0,0 +1,64 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Listener informed on a very simple scalar.', function () { + const history = [] + function l (eventType, state) { + history.push([eventType, state.position]) + } + + yaml.load('a_simple_scalar', { listener: l }) + + // 2 open events then 2 close events + assert.strictEqual(history.length, 4) + assert.strictEqual(history[0][0], 'open') + assert.strictEqual(history[1][0], 'open') + assert.strictEqual(history[2][0], 'close') + assert.strictEqual(history[3][0], 'close') + assert.strictEqual(history[0][1], 0) + assert.strictEqual(history[3][1], 16) +}) + +it('Listener informed on a map with a list.', function () { + const history = [] + function l (eventType, state) { + history.push([eventType, state.position, state.result]) + } + + yaml.load('{ a: 1, b: [ 0, xyz ] }', { listener: l }) + + let i = -1 + assert.strictEqual(history[++i][0], 'open') // doc + assert.strictEqual(history[++i][0], 'open') // map + + assert.strictEqual(history[++i][0], 'open') // key + assert.strictEqual(history[++i][0], 'close') + assert.strictEqual(history[i][2], 'a') + + assert.strictEqual(history[++i][0], 'open') // a value + assert.strictEqual(history[++i][0], 'close') + assert.strictEqual(history[i][2], 1) + + assert.strictEqual(history[++i][0], 'open') // key + assert.strictEqual(history[++i][0], 'close') + assert.strictEqual(history[i][2], 'b') + + assert.strictEqual(history[++i][0], 'open') // b value (list) + assert.strictEqual(history[++i][0], 'open') // item in list + assert.strictEqual(history[++i][0], 'close') + assert.strictEqual(history[i][2], 0) + assert.strictEqual(history[++i][0], 'open') // item in list + assert.strictEqual(history[++i][0], 'close') + + assert.strictEqual(history[++i][0], 'close') // b value (list) end + assert.deepStrictEqual(history[i][2], [0, 'xyz']) + + assert.strictEqual(history[++i][0], 'close') // map end + assert.strictEqual(history[++i][0], 'close') // doc end + + assert.strictEqual(history.length, ++i) +}) diff --git a/test/core/issues/0258.js b/test/core/issues/0258.js new file mode 100644 index 00000000..287cd13d --- /dev/null +++ b/test/core/issues/0258.js @@ -0,0 +1,26 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should shorthand tags with !! whenever possible', function () { + const regexp = new yaml.Type('tag:yaml.org,2002:js/regexp', { + kind: 'scalar', + resolve: () => true, + construct: str => new RegExp(str), + instanceOf: RegExp, + represent: object => object.source + }) + + const schema = yaml.DEFAULT_SCHEMA.extend(regexp) + + const source = 're: !!js/regexp .*\n' + + const object = yaml.load(source, { schema }) + assert(object.re instanceof RegExp) + + const str = yaml.dump(object, { schema }) + assert.strictEqual(str, source) +}) diff --git a/test/issues/0266.js b/test/core/issues/0266.js similarity index 62% rename from test/issues/0266.js rename to test/core/issues/0266.js index df565003..2a007bd4 100644 --- a/test/issues/0266.js +++ b/test/core/issues/0266.js @@ -1,23 +1,22 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); +const assert = require('assert') +const yaml = require('js-yaml') - -var DEPRECATED_BOOLEANS_SYNTAX = [ +const DEPRECATED_BOOLEANS_SYNTAX = [ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' -]; - +] it('Dumper should not take into account booleans syntax from YAML 1.0/1.1 in noCompatMode', function () { DEPRECATED_BOOLEANS_SYNTAX.forEach(function (string) { - var dump = yaml.dump(string, { noCompatMode: true }).trim(); + const dump = yaml.dump(string, { noCompatMode: true }).trim() assert( (dump === string), ('"' + string + '" string is not dumped as-is; actual dump: ' + dump) - ); - }); -}); + ) + }) +}) diff --git a/test/issues/0301.js b/test/core/issues/0301.js similarity index 68% rename from test/issues/0301.js rename to test/core/issues/0301.js index 25226d52..bed08dde 100644 --- a/test/issues/0301.js +++ b/test/core/issues/0301.js @@ -1,28 +1,28 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('should assign anchor to an empty node', function () { assert.deepStrictEqual( yaml.load('foo: &a\nbar: *a\n'), { foo: null, bar: null } - ); + ) assert.deepStrictEqual( yaml.load('{ foo: &a, bar: *a }'), { foo: null, bar: null } - ); + ) assert.deepStrictEqual( yaml.load('- &a\n- *a\n'), - [ null, null ] - ); + [null, null] + ) assert.deepStrictEqual( yaml.load('[ &a, *a ]'), - [ null, null ] - ); -}); + [null, null] + ) +}) diff --git a/test/core/issues/0303.js b/test/core/issues/0303.js new file mode 100644 index 00000000..ef0ffaab --- /dev/null +++ b/test/core/issues/0303.js @@ -0,0 +1,13 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Loader should not strip quotes before newlines', function () { + const with_space = yaml.load("'''foo'' '") + const with_newline = yaml.load("'''foo''\n'") + assert.strictEqual(with_space, "'foo' ") + assert.strictEqual(with_newline, "'foo' ") +}) diff --git a/test/core/issues/0321.js b/test/core/issues/0321.js new file mode 100644 index 00000000..faaaced7 --- /dev/null +++ b/test/core/issues/0321.js @@ -0,0 +1,19 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Should throw exception on extra comma in flow mappings', function () { + assert.throws(function () { + yaml.load('[foo, bar,, baz]') + }, /expected the node content, but found ','/) + + assert.throws(function () { + yaml.load('{foo, bar,, baz}') + }, /expected the node content, but found ','/) + + // empty key is allowed here + assert.deepStrictEqual(yaml.load('{foo,: bar}'), { foo: null, null: 'bar' }) +}) diff --git a/test/issues/0332.js b/test/core/issues/0332.js similarity index 68% rename from test/issues/0332.js rename to test/core/issues/0332.js index 14c32573..f5a8abae 100644 --- a/test/issues/0332.js +++ b/test/core/issues/0332.js @@ -1,40 +1,39 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('Should format errors', function () { try { - yaml.load('"foo\u0001bar"'); + yaml.load('"foo\u0001bar"') } catch (err) { - assert.strictEqual(err.toString(true), 'YAMLException: expected valid JSON character (1:9)'); + assert.strictEqual(err.toString(true), 'YAMLException: expected valid JSON character (1:9)') assert.strictEqual(err.toString(false), `YAMLException: expected valid JSON character (1:9) 1 | "foo\u0001bar" --------------^`); +-------------^`) } try { - yaml.load('*'); + yaml.load('*') } catch (err) { assert.strictEqual(err.toString(), `YAMLException: name of an alias node must contain at least one character (1:2) 1 | * -------^`); +------^`) } try { - yaml.load('foo:\n bar: 1\na'); + yaml.load('foo:\n bar: 1\na') } catch (err) { - // eslint-disable-next-line max-len assert.strictEqual(err.toString(), `YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key (4:1) 1 | foo: 2 | bar: 1 3 | a 4 | ------^`); +-----^`) } -}); +}) diff --git a/test/issues/0333.js b/test/core/issues/0333.js similarity index 57% rename from test/issues/0333.js rename to test/core/issues/0333.js index 1371dcfb..122578a5 100644 --- a/test/issues/0333.js +++ b/test/core/issues/0333.js @@ -1,20 +1,20 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('should allow cast integers as !!float', function () { - var data = yaml.load(` + const data = yaml.load(` negative: !!float -1 zero: !!float 0 positive: !!float 2.3e4 -`); +`) assert.deepStrictEqual(data, { negative: -1, zero: 0, positive: 23000 - }); -}); + }) +}) diff --git a/test/issues/0335.js b/test/core/issues/0335.js similarity index 70% rename from test/issues/0335.js rename to test/core/issues/0335.js index b7fbd49f..e0082f2a 100644 --- a/test/issues/0335.js +++ b/test/core/issues/0335.js @@ -1,19 +1,19 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('Don\'t throw on warning', function () { - var src = ` + const src = ` not_num_1: -_123 not_num_2: _123 not_num_3: 123_ not_num_4: 0b00_ not_num_5: 0x00_ not_num_6: 011_ -`; +` assert.deepStrictEqual(yaml.load(src), { not_num_1: '-_123', @@ -22,5 +22,5 @@ not_num_6: 011_ not_num_4: '0b00_', not_num_5: '0x00_', not_num_6: '011_' - }); -}); + }) +}) diff --git a/test/issues/0342.js b/test/core/issues/0342.js similarity index 81% rename from test/issues/0342.js rename to test/core/issues/0342.js index 0d00dce7..3cf2c69c 100644 --- a/test/issues/0342.js +++ b/test/core/issues/0342.js @@ -1,61 +1,61 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); -var simpleArray = [ 'a', 'b' ]; -var arrayOfSimpleObj = [ { a: 1 }, { b: 2 } ]; -var arrayOfObj = [ { a: 1, b: 'abc' }, { c: 'def', d: 2 } ]; - +const assert = require('assert') +const yaml = require('js-yaml') +const simpleArray = ['a', 'b'] +const arrayOfSimpleObj = [{ a: 1 }, { b: 2 }] +const arrayOfObj = [{ a: 1, b: 'abc' }, { c: 'def', d: 2 }] it('space should be added for array, regardless of indent', function () { assert.deepStrictEqual( yaml.dump(simpleArray, { indent: 1 }), '- a\n- b\n' - ); + ) assert.deepStrictEqual( yaml.dump(simpleArray, { indent: 2 }), '- a\n- b\n' - ); + ) assert.deepStrictEqual( yaml.dump(simpleArray, { indent: 3 }), '- a\n- b\n' - ); + ) assert.deepStrictEqual( yaml.dump(simpleArray, { indent: 4 }), '- a\n- b\n' - ); -}); + ) +}) it('array of objects should not wrap at indentation of 2', function () { assert.deepStrictEqual( yaml.dump(arrayOfSimpleObj, { indent: 2 }), '- a: 1\n- b: 2\n' - ); + ) assert.deepStrictEqual( yaml.dump(arrayOfObj, { indent: 2 }), '- a: 1\n b: abc\n- c: def\n d: 2\n' - ); -}); + ) +}) it('EOL space should not be added on array of objects at indentation of 3', function () { assert.deepStrictEqual( yaml.dump(arrayOfSimpleObj, { indent: 3 }), '-\n a: 1\n-\n b: 2\n' - ); + ) assert.deepStrictEqual( yaml.dump(arrayOfObj, { indent: 3 }), '-\n a: 1\n b: abc\n-\n c: def\n d: 2\n' - ); -}); + ) +}) it('EOL space should not be added on array of objects at indentation of 4', function () { assert.deepStrictEqual( yaml.dump(arrayOfSimpleObj, { indent: 4 }), '-\n a: 1\n-\n b: 2\n' - ); + ) assert.deepStrictEqual( yaml.dump(arrayOfObj, { indent: 4 }), '-\n a: 1\n b: abc\n-\n c: def\n d: 2\n' - ); -}); + ) +}) diff --git a/test/core/issues/0346.js b/test/core/issues/0346.js new file mode 100644 index 00000000..5a0958f5 --- /dev/null +++ b/test/core/issues/0346.js @@ -0,0 +1,26 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should not emit spaces in arrays in flow mode between entries using condenseFlow: true', function () { + const array = ['a', 'b'] + const dumpedArray = yaml.dump(array, { flowLevel: 0, indent: 0, condenseFlow: true }) + assert.strictEqual( + dumpedArray, + '[a,b]\n' + ) + assert.deepStrictEqual(yaml.load(dumpedArray), array) +}) + +it('should not emit spaces between key: value and quote keys using condenseFlow: true', function () { + const object = { a: { b: 'c', d: 'e' } } + const objectDump = yaml.dump(object, { flowLevel: 0, indent: 0, condenseFlow: true }) + assert.strictEqual( + objectDump, + '{"a":{"b":c, "d":e}}\n' + ) + assert.deepStrictEqual(yaml.load(objectDump), object) +}) diff --git a/test/core/issues/0350.js b/test/core/issues/0350.js new file mode 100644 index 00000000..92457e2c --- /dev/null +++ b/test/core/issues/0350.js @@ -0,0 +1,17 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should return parse docs from loadAll', function () { + const data = yaml.loadAll(` +--- +a: 1 +--- +b: 2 +`) + + assert.deepStrictEqual(data, [{ a: 1 }, { b: 2 }]) +}) diff --git a/test/issues/0351.js b/test/core/issues/0351.js similarity index 50% rename from test/issues/0351.js rename to test/core/issues/0351.js index 4c5383f6..5ad7bad0 100644 --- a/test/issues/0351.js +++ b/test/core/issues/0351.js @@ -1,9 +1,9 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../..'); - +const assert = require('assert') +const yaml = require('js-yaml') it('should include the error message in the error stack', function () { try { @@ -12,10 +12,10 @@ it('should include the error message in the error stack', function () { foo: bar baz: qux -`); +`) } catch (err) { - assert(err.stack.startsWith('YAMLException: end of the stream or a document separator is expected')); - return; + assert(err.stack.startsWith('YAMLException: end of the stream or a document separator is expected')) + return } - assert.fail(null, null, 'Expected an error to be thrown'); -}); + assert.fail(null, null, 'Expected an error to be thrown') +}) diff --git a/test/issues/0385.js b/test/core/issues/0385.js similarity index 66% rename from test/issues/0385.js rename to test/core/issues/0385.js index b7d39bf8..1ae22ddf 100644 --- a/test/issues/0385.js +++ b/test/core/issues/0385.js @@ -1,28 +1,28 @@ -'use strict'; +'use strict' +const { describe, it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') describe('Multi tag', function () { it('should process multi tags', function () { - let tags = [ 'scalar', 'mapping', 'sequence' ].map(kind => + const tags = ['scalar', 'mapping', 'sequence'].map(kind => new yaml.Type('!', { kind, multi: true, resolve: function () { - return true; + return true }, construct: function (value, tag) { - return { kind, tag, value }; + return { kind, tag, value } } }) - ); + ) - let schema = yaml.DEFAULT_SCHEMA.extend(tags); + const schema = yaml.DEFAULT_SCHEMA.extend(tags) - let expected = [ + const expected = [ { kind: 'scalar', tag: '!t1', @@ -31,14 +31,14 @@ describe('Multi tag', function () { { kind: 'sequence', tag: '!t2', - value: [ 1, 2, 3 ] + value: [1, 2, 3] }, { kind: 'mapping', tag: '!t3', value: { a: 1, b: 2 } } - ]; + ] assert.deepStrictEqual(yaml.load(` - !t1 123 @@ -46,45 +46,44 @@ describe('Multi tag', function () { - !t3 { a: 1, b: 2 } `, { schema: schema - }), expected); - }); - + }), expected) + }) it('should process tags depending on prefix', function () { - let tags = [ '!foo', '!bar', '!' ].map(prefix => + const tags = ['!foo', '!bar', '!'].map(prefix => new yaml.Type(prefix, { kind: 'scalar', multi: true, resolve: function () { - return true; + return true }, construct: function (value, tag) { - return { prefix, tag, value }; + return { prefix, tag, value } } }) - ); + ) tags.push( new yaml.Type('!bar', { kind: 'scalar', resolve: function () { - return true; + return true }, construct: function (value) { - return { single: true, value }; + return { single: true, value } } }) - ); + ) - let schema = yaml.DEFAULT_SCHEMA.extend(tags); + const schema = yaml.DEFAULT_SCHEMA.extend(tags) - let expected = [ + const expected = [ { prefix: '!foo', tag: '!foo', value: '1' }, { prefix: '!foo', tag: '!foo2', value: '2' }, { single: true, value: '3' }, { prefix: '!bar', tag: '!bar2', value: '4' }, { prefix: '!', tag: '!baz', value: '5' } - ]; + ] assert.deepStrictEqual(yaml.load(` - !foo 1 @@ -94,31 +93,30 @@ describe('Multi tag', function () { - !baz 5 `, { schema: schema - }), expected); - }); - + }), expected) + }) it('should dump multi types with custom tag', function () { - let tags = [ + const tags = [ new yaml.Type('!', { kind: 'scalar', multi: true, predicate: function (obj) { - return !!obj.tag; + return !!obj.tag }, representName: function (obj) { - return obj.tag; + return obj.tag }, represent: function (obj) { - return obj.value; + return obj.value } }) - ]; + ] - let schema = yaml.DEFAULT_SCHEMA.extend(tags); + const schema = yaml.DEFAULT_SCHEMA.extend(tags) assert.strictEqual(yaml.dump({ test: { tag: 'foo', value: 'bar' } }, { schema: schema - }), 'test: ! bar\n'); - }); -}); + }), 'test: ! bar\n') + }) +}) diff --git a/test/core/issues/0399.js b/test/core/issues/0399.js new file mode 100644 index 00000000..95566d43 --- /dev/null +++ b/test/core/issues/0399.js @@ -0,0 +1,20 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should properly dump negative ints in different styles', function () { + let dump + const src = { integer: -100 } + + dump = yaml.dump(src, { styles: { '!!int': 'binary' } }) + assert.deepStrictEqual(yaml.load(dump), src) + + dump = yaml.dump(src, { styles: { '!!int': 'octal' } }) + assert.deepStrictEqual(yaml.load(dump), src) + + dump = yaml.dump(src, { styles: { '!!int': 'hex' } }) + assert.deepStrictEqual(yaml.load(dump), src) +}) diff --git a/test/core/issues/0403.js b/test/core/issues/0403.js new file mode 100644 index 00000000..4d608b3c --- /dev/null +++ b/test/core/issues/0403.js @@ -0,0 +1,20 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should properly dump leading newlines and spaces', function () { + let src = { str: '\n a\nb' } + let dump = yaml.dump(src) + assert.deepStrictEqual(yaml.load(dump), src) + + src = { str: '\n\n a\nb' } + dump = yaml.dump(src) + assert.deepStrictEqual(yaml.load(dump), src) + + src = { str: '\n a\nb' } + dump = yaml.dump(src, { indent: 10 }) + assert.deepStrictEqual(yaml.load(dump), src) +}) diff --git a/test/core/issues/0418.js b/test/core/issues/0418.js new file mode 100644 index 00000000..dddfadb7 --- /dev/null +++ b/test/core/issues/0418.js @@ -0,0 +1,11 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should error on invalid indentation in mappings', function () { + assert.throws(() => yaml.load('foo: "1" bar: "2"'), /bad indentation of a mapping entry/) + assert.throws(() => yaml.load('- "foo" - "bar"'), /bad indentation of a sequence entry/) +}) diff --git a/test/core/issues/0432.js b/test/core/issues/0432.js new file mode 100644 index 00000000..42d1b276 --- /dev/null +++ b/test/core/issues/0432.js @@ -0,0 +1,24 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should indent arrays an extra level by default', function () { + const output = yaml.dump({ array: ['a', 'b'] }) + const expected = 'array:\n - a\n - b\n' + assert.strictEqual(output, expected) +}) + +it('should not indent arrays an extra level when disabled', function () { + const output = yaml.dump({ array: ['a', 'b'] }, { noArrayIndent: true }) + const expected = 'array:\n- a\n- b\n' + assert.strictEqual(output, expected) +}) + +it('should always indent nested arrays', function () { + const output = yaml.dump({ array: ['a', ['b', 'c'], 'd'] }, { noArrayIndent: true }) + const expected = 'array:\n- a\n- - b\n - c\n- d\n' + assert.strictEqual(output, expected) +}) diff --git a/test/issues/0468.js b/test/core/issues/0468.js similarity index 51% rename from test/issues/0468.js rename to test/core/issues/0468.js index 1f033b7a..7a397c93 100644 --- a/test/issues/0468.js +++ b/test/core/issues/0468.js @@ -1,12 +1,12 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../..'); +const assert = require('assert') +const yaml = require('js-yaml') it('should not indent arrays an extra level when disabled', function () { - /* eslint-disable max-len */ - var output = yaml.dump( + const output = yaml.dump( [ { a: 'a_val', @@ -23,7 +23,7 @@ it('should not indent arrays an extra level when disabled', function () { } ], { noArrayIndent: true } - ); - var expected = '- a: a_val\n b: b_val\n- a: a2_val\n items:\n - a: a_a_val\n b: a_b_val\n'; - assert.strictEqual(output, expected); -}); + ) + const expected = '- a: a_val\n b: b_val\n- a: a2_val\n items:\n - a: a_a_val\n b: a_b_val\n' + assert.strictEqual(output, expected) +}) diff --git a/test/issues/0470.js b/test/core/issues/0470.js similarity index 50% rename from test/issues/0470.js rename to test/core/issues/0470.js index 80045c8c..97531768 100644 --- a/test/issues/0470.js +++ b/test/core/issues/0470.js @@ -1,25 +1,25 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('Don\'t quote strings with : without need', function () { - var data = { + const data = { // no quotes needed 'http://example.com': 'http://example.com', // quotes required 'foo: bar': 'foo: bar', 'foo:': 'foo:' - }; + } - var expected = ` + const expected = ` http://example.com: http://example.com 'foo: bar': 'foo: bar' 'foo:': 'foo:' -`.replace(/^\n/, ''); +`.replace(/^\n/, '') - assert.strictEqual(yaml.dump(data), expected); - assert.deepStrictEqual(yaml.load(expected), data); -}); + assert.strictEqual(yaml.dump(data), expected) + assert.deepStrictEqual(yaml.load(expected), data) +}) diff --git a/test/issues/0475-case1.yml b/test/core/issues/0475-case1.yml similarity index 100% rename from test/issues/0475-case1.yml rename to test/core/issues/0475-case1.yml diff --git a/test/issues/0475-case2.yml b/test/core/issues/0475-case2.yml similarity index 100% rename from test/issues/0475-case2.yml rename to test/core/issues/0475-case2.yml diff --git a/test/issues/0475.js b/test/core/issues/0475.js similarity index 53% rename from test/issues/0475.js rename to test/core/issues/0475.js index ed144d04..5794ce61 100644 --- a/test/issues/0475.js +++ b/test/core/issues/0475.js @@ -1,27 +1,27 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); -var readFileSync = require('fs').readFileSync; - +const assert = require('assert') +const yaml = require('js-yaml') +const readFileSync = require('fs').readFileSync it('Should not allow nested arrays in map keys (explicit syntax)', function () { try { - yaml.load(readFileSync(require('path').join(__dirname, '/0475-case1.yml'), 'utf8')); + yaml.load(readFileSync(require('path').join(__dirname, '/0475-case1.yml'), 'utf8')) } catch (err) { - assert(err.stack.startsWith('YAMLException: nested arrays are not supported inside keys')); - return; + assert(err.stack.startsWith('YAMLException: nested arrays are not supported inside keys')) + return } - assert.fail(null, null, 'Expected an error to be thrown'); -}); + assert.fail(null, null, 'Expected an error to be thrown') +}) it('Should not allow nested arrays in map keys (implicit syntax)', function () { try { - yaml.load(readFileSync(require('path').join(__dirname, '/0475-case2.yml'), 'utf8')); + yaml.load(readFileSync(require('path').join(__dirname, '/0475-case2.yml'), 'utf8')) } catch (err) { - assert(err.stack.startsWith('YAMLException: nested arrays are not supported inside keys')); - return; + assert(err.stack.startsWith('YAMLException: nested arrays are not supported inside keys')) + return } - assert.fail(null, null, 'Expected an error to be thrown'); -}); + assert.fail(null, null, 'Expected an error to be thrown') +}) diff --git a/test/core/issues/0519.js b/test/core/issues/0519.js new file mode 100644 index 00000000..c16c89fb --- /dev/null +++ b/test/core/issues/0519.js @@ -0,0 +1,13 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Dumper should add quotes around equals sign', function () { + // pyyaml fails with unquoted `=` + // https://yaml-online-parser.appspot.com/?yaml=%3D%0A&type=json + assert.strictEqual(yaml.load(yaml.dump('=')), '=') + assert.strictEqual(yaml.dump('='), "'='\n") +}) diff --git a/test/issues/0521.js b/test/core/issues/0521.js similarity index 79% rename from test/issues/0521.js rename to test/core/issues/0521.js index 88647a20..b3af669b 100644 --- a/test/issues/0521.js +++ b/test/core/issues/0521.js @@ -1,43 +1,42 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('Don\'t quote strings with # without need', function () { - var required = ` + const required = ` http://example.com/page#anchor: no:quotes#required parameter#fallback: 'quotes #required' 'quotes: required': Visit [link](http://example.com/foo#bar) 'foo #bar': key is quoted -`.replace(/^\n/, ''); +`.replace(/^\n/, '') - var sample = { + const sample = { 'http://example.com/page#anchor': 'no:quotes#required', 'parameter#fallback': 'quotes #required', 'quotes: required': 'Visit [link](http://example.com/foo#bar)', 'foo #bar': 'key is quoted' - }; + } assert.strictEqual( yaml.dump(sample), required - ); -}); - + ) +}) it('Quote []{} in block-level scalars, but not in flow', function () { - var required = ` + const required = ` key1: a[]b key2: a{}b nested: key1: a[]b key2: a{}b nested: {key1: 'a[]b', key2: 'a{}b', nested: {key1: 'a[]b', key2: 'a{}b'}} -`.replace(/^\n/, ''); +`.replace(/^\n/, '') - var sample = { + const sample = { key1: 'a[]b', key2: 'a{}b', nested: { @@ -52,10 +51,10 @@ nested: } } } - }; + } assert.strictEqual( yaml.dump(sample, { flowLevel: 2 }), required - ); -}); + ) +}) diff --git a/test/core/issues/0525-1.js b/test/core/issues/0525-1.js new file mode 100644 index 00000000..c6ddac53 --- /dev/null +++ b/test/core/issues/0525-1.js @@ -0,0 +1,16 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Should throw if there is a null-byte in input', function () { + try { + yaml.load('foo\0bar') + } catch (err) { + assert(err.stack.startsWith('YAMLException: null byte is not allowed in input')) + return + } + assert.fail(null, null, 'Expected an error to be thrown') +}) diff --git a/test/core/issues/0525-2.js b/test/core/issues/0525-2.js new file mode 100644 index 00000000..8950fd7b --- /dev/null +++ b/test/core/issues/0525-2.js @@ -0,0 +1,16 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Should check kind type when resolving ! tag', function () { + try { + yaml.load('! [0]') + } catch (err) { + assert(err.stack.startsWith('YAMLException: unacceptable node kind for ! tag')) + return + } + assert.fail(null, null, 'Expected an error to be thrown') +}) diff --git a/test/issues/0529.js b/test/core/issues/0529.js similarity index 92% rename from test/issues/0529.js rename to test/core/issues/0529.js index 52e171cc..bc913fd4 100644 --- a/test/issues/0529.js +++ b/test/core/issues/0529.js @@ -1,9 +1,9 @@ -'use strict'; +'use strict' -/* eslint-disable max-len */ +const { describe, it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); +const assert = require('assert') +const yaml = require('js-yaml') const sample = { // normal key-value pair @@ -55,8 +55,7 @@ const sample = { // bool compat yes: 'yes' -}; - +} describe('should format strings with specified quoting type', function () { it('quotingType=\', forceQuotes=false', function () { @@ -90,11 +89,10 @@ nonprintable2: "foo\\vbar test test test test test test test test test test test nonprintable3: "foo\\vbar foo\\nbar\\nbaz" empty: '' 'yes': 'yes' -`.replace(/^\n/, ''); - - assert.strictEqual(yaml.dump(sample, { quotingType: "'", forceQuotes: false }), expected); - }); +`.replace(/^\n/, '') + assert.strictEqual(yaml.dump(sample, { quotingType: "'", forceQuotes: false }), expected) + }) it('quotingType=\", forceQuotes=false', function () { const expected = ` @@ -127,11 +125,10 @@ nonprintable2: "foo\\vbar test test test test test test test test test test test nonprintable3: "foo\\vbar foo\\nbar\\nbaz" empty: "" "yes": "yes" -`.replace(/^\n/, ''); - - assert.strictEqual(yaml.dump(sample, { quotingType: '"', forceQuotes: false }), expected); - }); +`.replace(/^\n/, '') + assert.strictEqual(yaml.dump(sample, { quotingType: '"', forceQuotes: false }), expected) + }) it('quotingType=\', forceQuotes=true', function () { const expected = ` @@ -157,11 +154,10 @@ nonprintable2: "foo\\vbar test test test test test test test test test test test nonprintable3: "foo\\vbar foo\\nbar\\nbaz" empty: '' 'yes': 'yes' -`.replace(/^\n/, ''); - - assert.strictEqual(yaml.dump(sample, { quotingType: "'", forceQuotes: true }), expected); - }); +`.replace(/^\n/, '') + assert.strictEqual(yaml.dump(sample, { quotingType: "'", forceQuotes: true }), expected) + }) it('quotingType=\", forceQuotes=true', function () { const expected = ` @@ -187,8 +183,8 @@ nonprintable2: "foo\\vbar test test test test test test test test test test test nonprintable3: "foo\\vbar foo\\nbar\\nbaz" empty: "" "yes": "yes" -`.replace(/^\n/, ''); +`.replace(/^\n/, '') - assert.strictEqual(yaml.dump(sample, { quotingType: '"', forceQuotes: true }), expected); - }); -}); + assert.strictEqual(yaml.dump(sample, { quotingType: '"', forceQuotes: true }), expected) + }) +}) diff --git a/test/core/issues/0570.js b/test/core/issues/0570.js new file mode 100644 index 00000000..17c1bf07 --- /dev/null +++ b/test/core/issues/0570.js @@ -0,0 +1,25 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('should dump null in different styles', function () { + let dump + const src = { foo: null, bar: 1 } + + const tests = { + lowercase: 'null', + uppercase: 'NULL', + camelcase: 'Null', + canonical: '~', + empty: '' + } + + for (const [name, value] of Object.entries(tests)) { + dump = yaml.dump(src, { styles: { '!!null': name } }) + assert.strictEqual(dump, 'foo: ' + value + '\nbar: 1\n') + assert.deepStrictEqual(yaml.load(dump), src) + } +}) diff --git a/test/issues/0571.js b/test/core/issues/0571.js similarity index 56% rename from test/issues/0571.js rename to test/core/issues/0571.js index 928d7eea..bbd06e58 100644 --- a/test/issues/0571.js +++ b/test/core/issues/0571.js @@ -1,73 +1,69 @@ -'use strict'; +'use strict' +const { describe, it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') describe('Undefined', function () { - let undef = new yaml.Type('!undefined', { + const undef = new yaml.Type('!undefined', { kind: 'scalar', resolve: () => true, construct: () => {}, predicate: object => typeof object === 'undefined', represent: () => '' - }); - - let undef_schema = yaml.DEFAULT_SCHEMA.extend(undef); + }) + const undef_schema = yaml.DEFAULT_SCHEMA.extend(undef) it('Should replace undefined with null in collections', function () { - let str; + let str - str = yaml.dump([ undefined, 1, undefined, null, 2 ], { flowLevel: 0 }); - assert(str.match(/^\[/)); + str = yaml.dump([undefined, 1, undefined, null, 2], { flowLevel: 0 }) + assert(str.match(/^\[/)) assert.deepStrictEqual( yaml.load(str), - [ null, 1, null, null, 2 ] - ); + [null, 1, null, null, 2] + ) - str = yaml.dump([ undefined, 1, undefined, null, 2 ], { flowLevel: -1 }); - assert(str.match(/^- /)); + str = yaml.dump([undefined, 1, undefined, null, 2], { flowLevel: -1 }) + assert(str.match(/^- /)) assert.deepStrictEqual( yaml.load(str), - [ null, 1, null, null, 2 ] - ); - }); - + [null, 1, null, null, 2] + ) + }) it('Should remove keys with undefined in mappings', function () { - let str; + let str - str = yaml.dump({ t: undefined, foo: 1, bar: undefined, baz: null }, { flowLevel: 0 }); - assert(str.match(/^\{/)); + str = yaml.dump({ t: undefined, foo: 1, bar: undefined, baz: null }, { flowLevel: 0 }) + assert(str.match(/^\{/)) assert.deepStrictEqual( yaml.load(str), { foo: 1, baz: null } - ); + ) - str = yaml.dump({ t: undefined, foo: 1, bar: undefined, baz: null }, { flowLevel: -1 }); - assert(str.match(/^foo:/)); + str = yaml.dump({ t: undefined, foo: 1, bar: undefined, baz: null }, { flowLevel: -1 }) + assert(str.match(/^foo:/)) assert.deepStrictEqual( yaml.load(str), { foo: 1, baz: null } - ); - }); - + ) + }) it("Should serialize top-level undefined to ''", function () { - assert.strictEqual(yaml.dump(undefined), ''); - }); - + assert.strictEqual(yaml.dump(undefined), '') + }) it('Should serialize undefined if schema is available', function () { assert.deepStrictEqual( yaml.load( - yaml.dump([ 1, undefined, null, 2 ], { schema: undef_schema }), + yaml.dump([1, undefined, null, 2], { schema: undef_schema }), { schema: undef_schema } ), - [ 1, undefined, null, 2 ] - ); + [1, undefined, null, 2] + ) assert.deepStrictEqual( yaml.load( @@ -75,40 +71,37 @@ describe('Undefined', function () { { schema: undef_schema } ), { foo: 1, bar: undefined, baz: null } - ); - }); - + ) + }) it('Should respect null formatting', function () { assert.strictEqual( - yaml.dump([ undefined ], { styles: { '!!null': 'uppercase' } }), + yaml.dump([undefined], { styles: { '!!null': 'uppercase' } }), '- NULL\n' - ); - }); - + ) + }) it('Should return an error if neither null nor undefined schemas are available', function () { assert.throws(() => { - yaml.dump([ 'foo', undefined, 'bar' ], { schema: yaml.FAILSAFE_SCHEMA }); - }, /unacceptable kind of an object to dump/); - }); - + yaml.dump(['foo', undefined, 'bar'], { schema: yaml.FAILSAFE_SCHEMA }) + }, /unacceptable kind of an object to dump/) + }) it('Should skip leading values correctly', function () { assert.strictEqual( - yaml.dump([ () => {}, 'a' ], { flowLevel: 0, skipInvalid: true }), - '[a]\n'); + yaml.dump([() => {}, 'a'], { flowLevel: 0, skipInvalid: true }), + '[a]\n') assert.strictEqual( - yaml.dump([ () => {}, 'a' ], { flowLevel: -1, skipInvalid: true }), - '- a\n'); + yaml.dump([() => {}, 'a'], { flowLevel: -1, skipInvalid: true }), + '- a\n') assert.strictEqual( yaml.dump({ a: () => {}, b: 'a' }, { flowLevel: 0, skipInvalid: true }), - '{b: a}\n'); + '{b: a}\n') assert.strictEqual( yaml.dump({ a: () => {}, b: 'a' }, { flowLevel: -1, skipInvalid: true }), - 'b: a\n'); - }); -}); + 'b: a\n') + }) +}) diff --git a/test/issues/0576.js b/test/core/issues/0576.js similarity index 50% rename from test/issues/0576.js rename to test/core/issues/0576.js index b56ecd8a..3137f4fb 100644 --- a/test/issues/0576.js +++ b/test/core/issues/0576.js @@ -1,53 +1,49 @@ -'use strict'; +'use strict' +const { describe, it } = require('node:test') -const assert = require('assert'); -const yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') describe('Custom tags', function () { - let tag_names = [ 'tag', '!tag', '!!tag', '!', 'tag*-!< >{\n}', '!tagαβγ' ]; - let encoded = [ '!', '!tag', '!%21tag', '!%3C%21tag%3E', - '!', '!tag%CE%B1%CE%B2%CE%B3' ]; + const tag_names = ['tag', '!tag', '!!tag', '!', 'tag*-!< >{\n}', '!tagαβγ'] + const encoded = ['!', '!tag', '!%21tag', '!%3C%21tag%3E', + '!', '!tag%CE%B1%CE%B2%CE%B3'] - let tags = tag_names.map(tag => + const tags = tag_names.map(tag => new yaml.Type(tag, { kind: 'scalar', resolve: () => true, - construct: object => [ tag, object ], + construct: object => [tag, object], predicate: object => object.tag === tag, represent: () => 'value' }) - ); - - let schema = yaml.DEFAULT_SCHEMA.extend(tags); + ) + const schema = yaml.DEFAULT_SCHEMA.extend(tags) it('Should dump tags with proper encoding', function () { tag_names.forEach(function (tag, idx) { - assert.strictEqual(yaml.dump({ tag }, { schema }), encoded[idx] + ' value\n'); - }); - }); - + assert.strictEqual(yaml.dump({ tag }, { schema }), encoded[idx] + ' value\n') + }) + }) it('Should decode tags when loading', function () { encoded.forEach(function (tag, idx) { - assert.deepStrictEqual(yaml.load(tag + ' value', { schema }), [ tag_names[idx], 'value' ]); - }); - }); - + assert.deepStrictEqual(yaml.load(tag + ' value', { schema }), [tag_names[idx], 'value']) + }) + }) it('Should url-decode built-in tags', function () { - assert.strictEqual(yaml.load('!!%69nt 123'), 123); - assert.strictEqual(yaml.load('!!%73tr 123'), '123'); - }); - + assert.strictEqual(yaml.load('!!%69nt 123'), 123) + assert.strictEqual(yaml.load('!!%73tr 123'), '123') + }) it('Should url-decode %TAG prefix', function () { assert.deepStrictEqual(yaml.load(` %TAG !xx! %74a --- !xx!g 123 -`, { schema }), [ 'tag', '123' ]); - }); -}); +`, { schema }), ['tag', '123']) + }) +}) diff --git a/test/core/issues/0586.js b/test/core/issues/0586.js new file mode 100644 index 00000000..12fb3ca4 --- /dev/null +++ b/test/core/issues/0586.js @@ -0,0 +1,45 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Should allow custom formatting through implicit custom tags', function () { + function CustomDump (data, opts) { + if (!(this instanceof CustomDump)) return new CustomDump(data, opts) + this.data = data + this.opts = opts + } + + CustomDump.prototype.represent = function () { + let result = yaml.dump(this.data, Object.assign({ replacer, schema }, this.opts)) + result = result.trim() + if (result.includes('\n')) result = '\n' + result + return result + } + + const CustomDumpType = new yaml.Type('!format', { + kind: 'scalar', + resolve: () => false, + instanceOf: CustomDump, + represent: d => d.represent() + }) + + const schema = yaml.DEFAULT_SCHEMA.extend({ implicit: [CustomDumpType] }) + + function replacer (key, value) { + if (key === '') return value // top-level, don't change this + if (key === 'flow_choices') return CustomDump(value, { flowLevel: 0 }) + if (key === 'block_choices') return CustomDump(value, { flowLevel: Infinity }) + return value // default + } + + const result = CustomDump({ flow_choices : [1, 2], block_choices: [4, 5] }).represent().trim() + + assert.strictEqual(result, ` +flow_choices: [1, 2] +block_choices: +- 4 +- 5`.replace(/^\n/, '')) +}) diff --git a/test/core/issues/0587.js b/test/core/issues/0587.js new file mode 100644 index 00000000..5ffa9134 --- /dev/null +++ b/test/core/issues/0587.js @@ -0,0 +1,10 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Should not encode astral characters', function () { + assert.strictEqual(yaml.dump('😃😊'), '😃😊\n') +}) diff --git a/test/core/issues/0614.js b/test/core/issues/0614.js new file mode 100644 index 00000000..10915c52 --- /dev/null +++ b/test/core/issues/0614.js @@ -0,0 +1,48 @@ +'use strict' + +const { it } = require('node:test') + +/* global BigInt */ + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Should allow int override', function () { + const options = Object.assign({}, yaml.types.int.options) + + options.construct = data => { + let value = data + let sign = 1n + let ch + + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, '') + } + + ch = value[0] + + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1n + value = value.slice(1) + ch = value[0] + } + + return sign * BigInt(value) + } + + const BigIntType = new yaml.Type('tag:yaml.org,2002:int', options) + + const SCHEMA = yaml.DEFAULT_SCHEMA.extend({ implicit: [BigIntType] }) + + const data = ` +int: -123_456_789 +bigint: -12_345_678_901_234_567_890 +float: -12_345_678_901_234_567_890.1234 +` + + assert.deepStrictEqual(yaml.load(data, { schema: SCHEMA }), { + int: -123456789n, + bigint: -12345678901234567890n, + float: -12345678901234567000 // precision loss expected + }) +}) diff --git a/test/samples-common/construct-binary.js b/test/core/samples-common/construct-binary.js similarity index 90% rename from test/samples-common/construct-binary.js rename to test/core/samples-common/construct-binary.js index e862b5ef..b79b6db4 100644 --- a/test/samples-common/construct-binary.js +++ b/test/core/samples-common/construct-binary.js @@ -1,9 +1,7 @@ -'use strict'; +'use strict' -/*eslint-disable max-len*/ - -function toTyped(data, encoding) { - return new Uint8Array(Buffer.from(data, encoding)); +function toTyped (data, encoding) { + return new Uint8Array(Buffer.from(data, encoding)) } module.exports = { @@ -12,4 +10,4 @@ module.exports = { generic: toTyped("GIF89a\x0c\x00\x0c\x00\x84\x00\x00\xff\xff\xf7\xf5\xf5\xee\xe9\xe9\xe5fff\x00\x00\x00\xe7\xe7\xe7^^^\xf3\xf3\xed\x8e\x8e\x8e\xe0\xe0\xe0\x9f\x9f\x9f\x93\x93\x93\xa7\xa7\xa7\x9e\x9e\x9eiiiccc\xa3\xa3\xa3\x84\x84\x84\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9!\xfe\x0eMade with GIMP\x00,\x00\x00\x00\x00\x0c\x00\x0c\x00\x00\x05, \x8e\x810\x9e\xe3@\x14\xe8i\x10\xc4\xd1\x8a\x08\x1c\xcf\x80M$z\xef\xff0\x85p\xb8\xb01f\r\x1b\xce\x01\xc3\x01\x1e\x10' \x82\n\x01\x00;", 'binary'), description: 'The binary value above is a tiny arrow encoded as a gif image.' -}; +} diff --git a/test/samples-common/construct-binary.yml b/test/core/samples-common/construct-binary.yml similarity index 100% rename from test/samples-common/construct-binary.yml rename to test/core/samples-common/construct-binary.yml diff --git a/test/core/samples-common/construct-bool.js b/test/core/samples-common/construct-bool.js new file mode 100644 index 00000000..fbbf1726 --- /dev/null +++ b/test/core/samples-common/construct-bool.js @@ -0,0 +1,8 @@ +'use strict' + +module.exports = { + valid_true: [true, true, true], + valid_false: [false, false, false], + deprecated_true: ['y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON'], + deprecated_false: ['n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'] +} diff --git a/test/samples-common/construct-bool.yml b/test/core/samples-common/construct-bool.yml similarity index 100% rename from test/samples-common/construct-bool.yml rename to test/core/samples-common/construct-bool.yml diff --git a/test/core/samples-common/construct-custom.js b/test/core/samples-common/construct-custom.js new file mode 100644 index 00000000..438392a9 --- /dev/null +++ b/test/core/samples-common/construct-custom.js @@ -0,0 +1,44 @@ +'use strict' + +const assert = require('assert') +const schema = require('../support/schema') + +const expected = [ + new schema.Tag1({ x: 1 }), + new schema.Tag1({ x: 1, y: 2, z: 3 }), + new schema.Tag2({ x: 10 }), + new schema.Tag3({ x: 1 }), + new schema.Tag3({ x: 1, y: 2, z: 3 }), + new schema.Tag3({ x: 1, y: 2, z: 3 }), + new schema.Foo({ myParameter: 'foo', myAnotherParameter: [1, 2, 3] }) +] + +function testHandler (actual) { + assert.strictEqual(Object.prototype.toString.call(actual), '[object Array]') + assert.strictEqual(actual.length, 7) + + assert.deepStrictEqual(actual[0], expected[0]) + assert.strictEqual(Object.getPrototypeOf(actual[0]), Object.getPrototypeOf(expected[0])) + + assert.deepStrictEqual(actual[1], expected[1]) + assert.strictEqual(Object.getPrototypeOf(actual[1]), Object.getPrototypeOf(expected[1])) + + assert.deepStrictEqual(actual[2], expected[2]) + assert.strictEqual(Object.getPrototypeOf(actual[2]), Object.getPrototypeOf(expected[2])) + + assert.deepStrictEqual(actual[3], expected[3]) + assert.strictEqual(Object.getPrototypeOf(actual[3]), Object.getPrototypeOf(expected[3])) + + assert.deepStrictEqual(actual[4], expected[4]) + assert.strictEqual(Object.getPrototypeOf(actual[4]), Object.getPrototypeOf(expected[4])) + + assert.deepStrictEqual(actual[5], expected[5]) + assert.strictEqual(Object.getPrototypeOf(actual[5]), Object.getPrototypeOf(expected[5])) + + assert.deepStrictEqual(actual[6], expected[6]) + assert.strictEqual(Object.getPrototypeOf(actual[6]), Object.getPrototypeOf(expected[6])) +} + +testHandler.expected = expected + +module.exports = testHandler diff --git a/test/samples-common/construct-custom.yml b/test/core/samples-common/construct-custom.yml similarity index 100% rename from test/samples-common/construct-custom.yml rename to test/core/samples-common/construct-custom.yml diff --git a/test/core/samples-common/construct-float.js b/test/core/samples-common/construct-float.js new file mode 100644 index 00000000..78caf28f --- /dev/null +++ b/test/core/samples-common/construct-float.js @@ -0,0 +1,27 @@ +'use strict' + +const assert = require('assert') + +const expected = { + canonical: 685230.15, + exponential: 685230.15, + fixed: 685230.15, + 'negative infinity': Number.NEGATIVE_INFINITY, + 'not a number': NaN +} + +function testHandler (actual) { + assert.strictEqual(Object.prototype.toString.call(actual), '[object Object]') + assert.strictEqual(Object.keys(actual).sort().join(','), Object.keys(expected).sort().join(',')) + + assert.strictEqual(actual['canonical'], expected['canonical']) + assert.strictEqual(actual['exponential'], expected['exponential']) + assert.strictEqual(actual['fixed'], expected['fixed']) + assert.strictEqual(actual['negative infinity'], expected['negative infinity']) + + assert(Number.isNaN(actual['not a number'])) +} + +testHandler.expected = expected + +module.exports = testHandler diff --git a/test/samples-common/construct-float.yml b/test/core/samples-common/construct-float.yml similarity index 100% rename from test/samples-common/construct-float.yml rename to test/core/samples-common/construct-float.yml diff --git a/test/samples-common/construct-int.js b/test/core/samples-common/construct-int.js similarity index 87% rename from test/samples-common/construct-int.js rename to test/core/samples-common/construct-int.js index beee5309..57478820 100644 --- a/test/samples-common/construct-int.js +++ b/test/core/samples-common/construct-int.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { canonical: 685230, @@ -6,4 +6,4 @@ module.exports = { octal: 685230, hexadecimal: 685230, binary: 685230 -}; +} diff --git a/test/samples-common/construct-int.yml b/test/core/samples-common/construct-int.yml similarity index 100% rename from test/samples-common/construct-int.yml rename to test/core/samples-common/construct-int.yml diff --git a/test/samples-common/construct-map.js b/test/core/samples-common/construct-map.js similarity index 92% rename from test/samples-common/construct-map.js rename to test/core/samples-common/construct-map.js index 195680d9..b91ec0a6 100644 --- a/test/samples-common/construct-map.js +++ b/test/core/samples-common/construct-map.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { 'Block style': { @@ -12,4 +12,4 @@ module.exports = { Oren: 'Ben-Kiki' }, 'foo,bar': 'baz' -}; +} diff --git a/test/samples-common/construct-map.yml b/test/core/samples-common/construct-map.yml similarity index 100% rename from test/samples-common/construct-map.yml rename to test/core/samples-common/construct-map.yml diff --git a/test/samples-common/construct-merge.js b/test/core/samples-common/construct-merge.js similarity index 93% rename from test/samples-common/construct-merge.js rename to test/core/samples-common/construct-merge.js index b05b916c..225f524a 100644 --- a/test/samples-common/construct-merge.js +++ b/test/core/samples-common/construct-merge.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = [ { x: 1, y: 2 }, @@ -9,4 +9,4 @@ module.exports = [ { x: 1, y: 2, r: 10, label: 'center/big' }, { x: 1, y: 2, r: 10, label: 'center/big' }, { x: 1, y: 2, r: 10, label: 'center/big' } -]; +] diff --git a/test/samples-common/construct-merge.yml b/test/core/samples-common/construct-merge.yml similarity index 100% rename from test/samples-common/construct-merge.yml rename to test/core/samples-common/construct-merge.yml diff --git a/test/samples-common/construct-null.js b/test/core/samples-common/construct-null.js similarity index 92% rename from test/samples-common/construct-null.js rename to test/core/samples-common/construct-null.js index c94c1a2e..950a4212 100644 --- a/test/samples-common/construct-null.js +++ b/test/core/samples-common/construct-null.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = [ null, @@ -17,4 +17,4 @@ module.exports = [ null ] } -]; +] diff --git a/test/samples-common/construct-null.yml b/test/core/samples-common/construct-null.yml similarity index 100% rename from test/samples-common/construct-null.yml rename to test/core/samples-common/construct-null.yml diff --git a/test/samples-common/construct-omap.js b/test/core/samples-common/construct-omap.js similarity index 54% rename from test/samples-common/construct-omap.js rename to test/core/samples-common/construct-omap.js index 3c98d7f6..8c41dcf5 100644 --- a/test/samples-common/construct-omap.js +++ b/test/core/samples-common/construct-omap.js @@ -1,9 +1,9 @@ -'use strict'; +'use strict' module.exports = { Bestiary: [ - { aardvark : 'African pig-like ant eater. Ugly.' }, - { anteater : 'South-American ant eater. Two species.' }, + { aardvark : 'African pig-like ant eater. Ugly.' }, + { anteater : 'South-American ant eater. Two species.' }, { anaconda : 'South-American constrictor snake. Scaly.' } ], Numbers: [ @@ -11,4 +11,4 @@ module.exports = { { two : 2 }, { three : 3 } ] -}; +} diff --git a/test/samples-common/construct-omap.yml b/test/core/samples-common/construct-omap.yml similarity index 100% rename from test/samples-common/construct-omap.yml rename to test/core/samples-common/construct-omap.yml diff --git a/test/core/samples-common/construct-pairs.js b/test/core/samples-common/construct-pairs.js new file mode 100644 index 00000000..97210bfe --- /dev/null +++ b/test/core/samples-common/construct-pairs.js @@ -0,0 +1,14 @@ +'use strict' + +module.exports = { + 'Block tasks': [ + ['meeting', 'with team.'], + ['meeting', 'with boss.'], + ['break', 'lunch.'], + ['meeting', 'with client.'] + ], + 'Flow tasks': [ + ['meeting', 'with team'], + ['meeting', 'with boss'] + ] +} diff --git a/test/samples-common/construct-pairs.yml b/test/core/samples-common/construct-pairs.yml similarity index 100% rename from test/samples-common/construct-pairs.yml rename to test/core/samples-common/construct-pairs.yml diff --git a/test/samples-common/construct-seq.js b/test/core/samples-common/construct-seq.js similarity index 94% rename from test/samples-common/construct-seq.js rename to test/core/samples-common/construct-seq.js index 6962d595..9349184b 100644 --- a/test/samples-common/construct-seq.js +++ b/test/core/samples-common/construct-seq.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { 'Block style': [ @@ -23,4 +23,4 @@ module.exports = { 'Neptune', 'Pluto' ] -}; +} diff --git a/test/samples-common/construct-seq.yml b/test/core/samples-common/construct-seq.yml similarity index 100% rename from test/samples-common/construct-seq.yml rename to test/core/samples-common/construct-seq.yml diff --git a/test/samples-common/construct-set.js b/test/core/samples-common/construct-set.js similarity index 93% rename from test/samples-common/construct-set.js rename to test/core/samples-common/construct-set.js index 1e39ba8a..2eead2cd 100644 --- a/test/samples-common/construct-set.js +++ b/test/core/samples-common/construct-set.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { 'baseball players': { @@ -11,4 +11,4 @@ module.exports = { 'Detroit Tigers': null, 'New York Yankees': null } -}; +} diff --git a/test/samples-common/construct-set.yml b/test/core/samples-common/construct-set.yml similarity index 100% rename from test/samples-common/construct-set.yml rename to test/core/samples-common/construct-set.yml diff --git a/test/core/samples-common/construct-str-ascii.js b/test/core/samples-common/construct-str-ascii.js new file mode 100644 index 00000000..56e5670d --- /dev/null +++ b/test/core/samples-common/construct-str-ascii.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = 'ascii string' diff --git a/test/samples-common/construct-str-ascii.yml b/test/core/samples-common/construct-str-ascii.yml similarity index 100% rename from test/samples-common/construct-str-ascii.yml rename to test/core/samples-common/construct-str-ascii.yml diff --git a/test/samples-common/construct-str-utf8.js b/test/core/samples-common/construct-str-utf8.js similarity index 74% rename from test/samples-common/construct-str-utf8.js rename to test/core/samples-common/construct-str-utf8.js index 4b4c895e..03e75f34 100644 --- a/test/samples-common/construct-str-utf8.js +++ b/test/core/samples-common/construct-str-utf8.js @@ -1,5 +1,3 @@ -'use strict'; +'use strict' -/*eslint-disable max-len*/ - -module.exports = '\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'; +module.exports = '\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' diff --git a/test/samples-common/construct-str-utf8.yml b/test/core/samples-common/construct-str-utf8.yml similarity index 100% rename from test/samples-common/construct-str-utf8.yml rename to test/core/samples-common/construct-str-utf8.yml diff --git a/test/samples-common/construct-str.js b/test/core/samples-common/construct-str.js similarity index 68% rename from test/samples-common/construct-str.js rename to test/core/samples-common/construct-str.js index 3307e0ec..4f9119e6 100644 --- a/test/samples-common/construct-str.js +++ b/test/core/samples-common/construct-str.js @@ -1,5 +1,5 @@ -'use strict'; +'use strict' module.exports = { string: 'abcd' -}; +} diff --git a/test/samples-common/construct-str.yml b/test/core/samples-common/construct-str.yml similarity index 100% rename from test/samples-common/construct-str.yml rename to test/core/samples-common/construct-str.yml diff --git a/test/samples-common/construct-string-types.js b/test/core/samples-common/construct-string-types.js similarity index 74% rename from test/samples-common/construct-string-types.js rename to test/core/samples-common/construct-string-types.js index 5c38d111..b2687daa 100644 --- a/test/samples-common/construct-string-types.js +++ b/test/core/samples-common/construct-string-types.js @@ -1,6 +1,6 @@ -'use strict'; +'use strict' -var essay = 'a\n' + +const essay = 'a\n' + 'b\n' + '1sdf 2ar 3sdf 4sdf 5sdf 6sdf 7sdf 8sdf 9sdf 10asdf 11asdf ' + '12asdf 13asdf 14asdf 15df 16df long 17df 1890 1900 2000 ' + @@ -14,7 +14,7 @@ var essay = 'a\n' + 'aaaa bbbb cccc dddd eeeee fff ggggggg hhhi iiii jjjj ' + 'long asdfasdfasdfasdfslong ' + ' xlong ' + - 'asdfasdfasdfasdfasdfasdfasdfasd asdf xasdf the end'; + 'asdfasdfasdfasdfasdfasdfasdfasd asdf xasdf the end' module.exports = { simpleString: 'hello world', @@ -48,7 +48,7 @@ module.exports = { questy: '?asdf', // Example 8.1. - blockScalarHeader: [ 'literal\n', ' folded\n', 'keep\n\n', ' strip' ], + blockScalarHeader: ['literal\n', ' folded\n', 'keep\n\n', ' strip'], // Example 8.2. // The ' \t' is a more-indented line as per [177] s-nb-spaced-text. blockIndentationIndicator: [ @@ -66,49 +66,48 @@ module.exports = { longMultiTrailingCR: new Array(80).join('lo hel') + '\nworld\n\n\n\n\n', longMulti: new Array(80).join('lo hel') + '\nworld\n' -}; +} // now indent the long multi really far -var obj = module.exports, - i; +let obj = module.exports -for (i = 0; i < 5; i++) { - obj.indent = {}; - obj = obj.indent; +for (let i = 0; i < 5; i++) { + obj.indent = {} + obj = obj.indent } -obj.ind = module.exports.longMulti; +obj.ind = module.exports.longMulti -for (i = 0; i < 5; i++) { - obj.indent = {}; - obj = obj.indent; +for (let i = 0; i < 5; i++) { + obj.indent = {} + obj = obj.indent } -obj.ind = module.exports.longMulti; +obj.ind = module.exports.longMulti -for (i = 0; i < 5; i++) { - obj.indent = {}; - obj = obj.indent; +for (let i = 0; i < 5; i++) { + obj.indent = {} + obj = obj.indent } -obj.ind = module.exports.longMulti; +obj.ind = module.exports.longMulti -for (i = 0; i < 5; i++) { - obj.indent = {}; - obj = obj.indent; +for (let i = 0; i < 5; i++) { + obj.indent = {} + obj = obj.indent } -obj.ind = module.exports.longMulti; +obj.ind = module.exports.longMulti -for (i = 0; i < 5; i++) { - obj.indent = {}; - obj = obj.indent; +for (let i = 0; i < 5; i++) { + obj.indent = {} + obj = obj.indent } -obj.ind = module.exports.longMulti; +obj.ind = module.exports.longMulti -for (i = 0; i < 5; i++) { - obj.indent = {}; - obj = obj.indent; +for (let i = 0; i < 5; i++) { + obj.indent = {} + obj = obj.indent } -obj.ind = module.exports.longMulti; +obj.ind = module.exports.longMulti diff --git a/test/samples-common/construct-string-types.yml b/test/core/samples-common/construct-string-types.yml similarity index 100% rename from test/samples-common/construct-string-types.yml rename to test/core/samples-common/construct-string-types.yml diff --git a/test/samples-common/construct-timestamp.js b/test/core/samples-common/construct-timestamp.js similarity index 95% rename from test/samples-common/construct-timestamp.js rename to test/core/samples-common/construct-timestamp.js index 462c6919..d82b88c1 100644 --- a/test/samples-common/construct-timestamp.js +++ b/test/core/samples-common/construct-timestamp.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { canonical: new Date(Date.UTC(2001, 11, 15, 2, 59, 43, 100)), @@ -7,4 +7,4 @@ module.exports = { 'no time zone (Z)': new Date(Date.UTC(2001, 11, 15, 2, 59, 43, 100)), 'date (00:00:00Z)': new Date(Date.UTC(2002, 11, 14)), 'not a date': '2002-1-1' -}; +} diff --git a/test/samples-common/construct-timestamp.yml b/test/core/samples-common/construct-timestamp.yml similarity index 100% rename from test/samples-common/construct-timestamp.yml rename to test/core/samples-common/construct-timestamp.yml diff --git a/test/samples-common/construct-value.js b/test/core/samples-common/construct-value.js similarity index 92% rename from test/samples-common/construct-value.js rename to test/core/samples-common/construct-value.js index d534dc69..7ed8de8d 100644 --- a/test/samples-common/construct-value.js +++ b/test/core/samples-common/construct-value.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = [ { @@ -13,4 +13,4 @@ module.exports = [ { '=': 'library2.dll', version: 2.3 } ] } -]; +] diff --git a/test/samples-common/construct-value.yml b/test/core/samples-common/construct-value.yml similarity index 100% rename from test/samples-common/construct-value.yml rename to test/core/samples-common/construct-value.yml diff --git a/test/samples-common/dump-empty-collections.js b/test/core/samples-common/dump-empty-collections.js similarity index 76% rename from test/samples-common/dump-empty-collections.js rename to test/core/samples-common/dump-empty-collections.js index 01ca101d..0591ac63 100644 --- a/test/samples-common/dump-empty-collections.js +++ b/test/core/samples-common/dump-empty-collections.js @@ -1,7 +1,6 @@ -'use strict'; - +'use strict' module.exports = { emptyArray: [], emptyObject: {} -}; +} diff --git a/test/samples-common/dump-empty-collections.yml b/test/core/samples-common/dump-empty-collections.yml similarity index 100% rename from test/samples-common/dump-empty-collections.yml rename to test/core/samples-common/dump-empty-collections.yml diff --git a/test/samples-common/duplicate-mapping-key.js b/test/core/samples-common/duplicate-mapping-key.js similarity index 81% rename from test/samples-common/duplicate-mapping-key.js rename to test/core/samples-common/duplicate-mapping-key.js index 43e9e94b..99694356 100644 --- a/test/samples-common/duplicate-mapping-key.js +++ b/test/core/samples-common/duplicate-mapping-key.js @@ -1,8 +1,8 @@ -'use strict'; +'use strict' module.exports = { foo: { baz: 'bat', foo: 'duplicate key' } -}; +} diff --git a/test/samples-common/duplicate-mapping-key.yml b/test/core/samples-common/duplicate-mapping-key.yml similarity index 100% rename from test/samples-common/duplicate-mapping-key.yml rename to test/core/samples-common/duplicate-mapping-key.yml diff --git a/test/samples-common/duplicate-merge-key.js b/test/core/samples-common/duplicate-merge-key.js similarity index 79% rename from test/samples-common/duplicate-merge-key.js rename to test/core/samples-common/duplicate-merge-key.js index df445815..0c67771f 100644 --- a/test/samples-common/duplicate-merge-key.js +++ b/test/core/samples-common/duplicate-merge-key.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { x: 1, @@ -6,4 +6,4 @@ module.exports = { foo: 'bar', z: 3, t: 4 -}; +} diff --git a/test/samples-common/duplicate-merge-key.yml b/test/core/samples-common/duplicate-merge-key.yml similarity index 100% rename from test/samples-common/duplicate-merge-key.yml rename to test/core/samples-common/duplicate-merge-key.yml diff --git a/test/core/samples-common/emitting-unacceptable-unicode-character-bug.js b/test/core/samples-common/emitting-unacceptable-unicode-character-bug.js new file mode 100644 index 00000000..8afdfe81 --- /dev/null +++ b/test/core/samples-common/emitting-unacceptable-unicode-character-bug.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = '\udd00' diff --git a/test/samples-common/emitting-unacceptable-unicode-character-bug.yml b/test/core/samples-common/emitting-unacceptable-unicode-character-bug.yml similarity index 100% rename from test/samples-common/emitting-unacceptable-unicode-character-bug.yml rename to test/core/samples-common/emitting-unacceptable-unicode-character-bug.yml diff --git a/test/samples-common/invalid-single-quote-bug.js b/test/core/samples-common/invalid-single-quote-bug.js similarity index 74% rename from test/samples-common/invalid-single-quote-bug.js rename to test/core/samples-common/invalid-single-quote-bug.js index 9d949fca..c50c2cf8 100644 --- a/test/samples-common/invalid-single-quote-bug.js +++ b/test/core/samples-common/invalid-single-quote-bug.js @@ -1,6 +1,6 @@ -'use strict'; +'use strict' module.exports = [ "foo 'bar'", "foo\n'bar'" -]; +] diff --git a/test/samples-common/invalid-single-quote-bug.yml b/test/core/samples-common/invalid-single-quote-bug.yml similarity index 100% rename from test/samples-common/invalid-single-quote-bug.yml rename to test/core/samples-common/invalid-single-quote-bug.yml diff --git a/test/core/samples-common/more-floats.js b/test/core/samples-common/more-floats.js new file mode 100644 index 00000000..c85750ce --- /dev/null +++ b/test/core/samples-common/more-floats.js @@ -0,0 +1,29 @@ +'use strict' + +const assert = require('assert') + +const expected = [ + 0.0, + 1.0, + -1.0, + Number.POSITIVE_INFINITY, + Number.NEGATIVE_INFINITY, + NaN, + NaN +] + +function testHandler (actual) { + assert.strictEqual(Object.prototype.toString.call(actual), '[object Array]') + assert.strictEqual(actual.length, 7) + assert.strictEqual(actual[0], expected[0]) + assert.strictEqual(actual[1], expected[1]) + assert.strictEqual(actual[2], expected[2]) + assert.strictEqual(actual[3], expected[3]) + assert.strictEqual(actual[4], expected[4]) + assert(Number.isNaN(actual[5])) + assert(Number.isNaN(actual[6])) +} + +testHandler.expected = expected + +module.exports = testHandler diff --git a/test/samples-common/more-floats.yml b/test/core/samples-common/more-floats.yml similarity index 100% rename from test/samples-common/more-floats.yml rename to test/core/samples-common/more-floats.yml diff --git a/test/core/samples-common/negative-float-bug.js b/test/core/samples-common/negative-float-bug.js new file mode 100644 index 00000000..fb385178 --- /dev/null +++ b/test/core/samples-common/negative-float-bug.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = -1.0 diff --git a/test/samples-common/negative-float-bug.yml b/test/core/samples-common/negative-float-bug.yml similarity index 100% rename from test/samples-common/negative-float-bug.yml rename to test/core/samples-common/negative-float-bug.yml diff --git a/test/core/samples-common/single-dot-is-not-float-bug.js b/test/core/samples-common/single-dot-is-not-float-bug.js new file mode 100644 index 00000000..64c2b9b6 --- /dev/null +++ b/test/core/samples-common/single-dot-is-not-float-bug.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = '.' diff --git a/test/samples-common/single-dot-is-not-float-bug.yml b/test/core/samples-common/single-dot-is-not-float-bug.yml similarity index 100% rename from test/samples-common/single-dot-is-not-float-bug.yml rename to test/core/samples-common/single-dot-is-not-float-bug.yml diff --git a/test/samples-common/timestamp-bugs.js b/test/core/samples-common/timestamp-bugs.js similarity index 95% rename from test/samples-common/timestamp-bugs.js rename to test/core/samples-common/timestamp-bugs.js index 58d8949f..97ec53cc 100644 --- a/test/samples-common/timestamp-bugs.js +++ b/test/core/samples-common/timestamp-bugs.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = [ new Date(Date.UTC(2001, 11, 15, 3, 29, 43, 100)), @@ -7,4 +7,4 @@ module.exports = [ new Date(Date.UTC(2001, 11, 14, (21 - 1), 59, 43, 0)), new Date(Date.UTC(2001, 11, 14, (21 + 1), (59 + 30), 43, 0)), new Date(Date.UTC(2005, 6, 8, 17, 35, 4, 517)) -]; +] diff --git a/test/samples-common/timestamp-bugs.yml b/test/core/samples-common/timestamp-bugs.yml similarity index 100% rename from test/samples-common/timestamp-bugs.yml rename to test/core/samples-common/timestamp-bugs.yml diff --git a/test/core/samples-common/utf8-implicit.js b/test/core/samples-common/utf8-implicit.js new file mode 100644 index 00000000..5581c1b1 --- /dev/null +++ b/test/core/samples-common/utf8-implicit.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = 'implicit UTF-8' diff --git a/test/samples-common/utf8-implicit.yml b/test/core/samples-common/utf8-implicit.yml similarity index 100% rename from test/samples-common/utf8-implicit.yml rename to test/core/samples-common/utf8-implicit.yml diff --git a/test/samples-load-errors/a-nasty-libyaml-bug.yml b/test/core/samples-load-errors/a-nasty-libyaml-bug.yml similarity index 100% rename from test/samples-load-errors/a-nasty-libyaml-bug.yml rename to test/core/samples-load-errors/a-nasty-libyaml-bug.yml diff --git a/test/samples-load-errors/document-separator-in-quoted-scalar.yml b/test/core/samples-load-errors/document-separator-in-quoted-scalar.yml similarity index 100% rename from test/samples-load-errors/document-separator-in-quoted-scalar.yml rename to test/core/samples-load-errors/document-separator-in-quoted-scalar.yml diff --git a/test/core/samples-load-errors/duplicate-key.js b/test/core/samples-load-errors/duplicate-key.js new file mode 100644 index 00000000..414a55f0 --- /dev/null +++ b/test/core/samples-load-errors/duplicate-key.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = { foo: 'baz' } diff --git a/test/samples-load-errors/duplicate-key.yml b/test/core/samples-load-errors/duplicate-key.yml similarity index 100% rename from test/samples-load-errors/duplicate-key.yml rename to test/core/samples-load-errors/duplicate-key.yml diff --git a/test/samples-load-errors/duplicate-tag-directive.yml b/test/core/samples-load-errors/duplicate-tag-directive.yml similarity index 100% rename from test/samples-load-errors/duplicate-tag-directive.yml rename to test/core/samples-load-errors/duplicate-tag-directive.yml diff --git a/test/core/samples-load-errors/duplicate-value-key.js b/test/core/samples-load-errors/duplicate-value-key.js new file mode 100644 index 00000000..b44854cb --- /dev/null +++ b/test/core/samples-load-errors/duplicate-value-key.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = { foo: 'bar', '=': 2 } diff --git a/test/samples-load-errors/duplicate-value-key.yml b/test/core/samples-load-errors/duplicate-value-key.yml similarity index 100% rename from test/samples-load-errors/duplicate-value-key.yml rename to test/core/samples-load-errors/duplicate-value-key.yml diff --git a/test/samples-load-errors/duplicate-yaml-directive.yml b/test/core/samples-load-errors/duplicate-yaml-directive.yml similarity index 100% rename from test/samples-load-errors/duplicate-yaml-directive.yml rename to test/core/samples-load-errors/duplicate-yaml-directive.yml diff --git a/test/samples-load-errors/expected-mapping.yml b/test/core/samples-load-errors/expected-mapping.yml similarity index 100% rename from test/samples-load-errors/expected-mapping.yml rename to test/core/samples-load-errors/expected-mapping.yml diff --git a/test/samples-load-errors/expected-scalar.yml b/test/core/samples-load-errors/expected-scalar.yml similarity index 100% rename from test/samples-load-errors/expected-scalar.yml rename to test/core/samples-load-errors/expected-scalar.yml diff --git a/test/samples-load-errors/expected-sequence.yml b/test/core/samples-load-errors/expected-sequence.yml similarity index 100% rename from test/samples-load-errors/expected-sequence.yml rename to test/core/samples-load-errors/expected-sequence.yml diff --git a/test/samples-load-errors/fetch-complex-value-bug.yml b/test/core/samples-load-errors/fetch-complex-value-bug.yml similarity index 100% rename from test/samples-load-errors/fetch-complex-value-bug.yml rename to test/core/samples-load-errors/fetch-complex-value-bug.yml diff --git a/test/samples-load-errors/forbidden-entry.yml b/test/core/samples-load-errors/forbidden-entry.yml similarity index 100% rename from test/samples-load-errors/forbidden-entry.yml rename to test/core/samples-load-errors/forbidden-entry.yml diff --git a/test/samples-load-errors/forbidden-key.yml b/test/core/samples-load-errors/forbidden-key.yml similarity index 100% rename from test/samples-load-errors/forbidden-key.yml rename to test/core/samples-load-errors/forbidden-key.yml diff --git a/test/samples-load-errors/forbidden-value.yml b/test/core/samples-load-errors/forbidden-value.yml similarity index 100% rename from test/samples-load-errors/forbidden-value.yml rename to test/core/samples-load-errors/forbidden-value.yml diff --git a/test/samples-load-errors/invalid-anchor-2.yml b/test/core/samples-load-errors/invalid-anchor-2.yml similarity index 100% rename from test/samples-load-errors/invalid-anchor-2.yml rename to test/core/samples-load-errors/invalid-anchor-2.yml diff --git a/test/samples-load-errors/invalid-base64-data-2.yml b/test/core/samples-load-errors/invalid-base64-data-2.yml similarity index 100% rename from test/samples-load-errors/invalid-base64-data-2.yml rename to test/core/samples-load-errors/invalid-base64-data-2.yml diff --git a/test/samples-load-errors/invalid-base64-data.yml b/test/core/samples-load-errors/invalid-base64-data.yml similarity index 100% rename from test/samples-load-errors/invalid-base64-data.yml rename to test/core/samples-load-errors/invalid-base64-data.yml diff --git a/test/samples-load-errors/invalid-block-scalar-indicator.yml b/test/core/samples-load-errors/invalid-block-scalar-indicator.yml similarity index 100% rename from test/samples-load-errors/invalid-block-scalar-indicator.yml rename to test/core/samples-load-errors/invalid-block-scalar-indicator.yml diff --git a/test/samples-load-errors/invalid-character.yml b/test/core/samples-load-errors/invalid-character.yml similarity index 100% rename from test/samples-load-errors/invalid-character.yml rename to test/core/samples-load-errors/invalid-character.yml diff --git a/test/samples-load-errors/invalid-directive-line.yml b/test/core/samples-load-errors/invalid-directive-line.yml similarity index 100% rename from test/samples-load-errors/invalid-directive-line.yml rename to test/core/samples-load-errors/invalid-directive-line.yml diff --git a/test/samples-load-errors/invalid-directive-name-1.yml b/test/core/samples-load-errors/invalid-directive-name-1.yml similarity index 100% rename from test/samples-load-errors/invalid-directive-name-1.yml rename to test/core/samples-load-errors/invalid-directive-name-1.yml diff --git a/test/samples-load-errors/invalid-directive-name-2.yml b/test/core/samples-load-errors/invalid-directive-name-2.yml similarity index 100% rename from test/samples-load-errors/invalid-directive-name-2.yml rename to test/core/samples-load-errors/invalid-directive-name-2.yml diff --git a/test/samples-load-errors/invalid-escape-character.yml b/test/core/samples-load-errors/invalid-escape-character.yml similarity index 100% rename from test/samples-load-errors/invalid-escape-character.yml rename to test/core/samples-load-errors/invalid-escape-character.yml diff --git a/test/samples-load-errors/invalid-escape-numbers.yml b/test/core/samples-load-errors/invalid-escape-numbers.yml similarity index 100% rename from test/samples-load-errors/invalid-escape-numbers.yml rename to test/core/samples-load-errors/invalid-escape-numbers.yml diff --git a/test/samples-load-errors/invalid-indentation-indicator-1.yml b/test/core/samples-load-errors/invalid-indentation-indicator-1.yml similarity index 100% rename from test/samples-load-errors/invalid-indentation-indicator-1.yml rename to test/core/samples-load-errors/invalid-indentation-indicator-1.yml diff --git a/test/samples-load-errors/invalid-indentation-indicator-2.yml b/test/core/samples-load-errors/invalid-indentation-indicator-2.yml similarity index 100% rename from test/samples-load-errors/invalid-indentation-indicator-2.yml rename to test/core/samples-load-errors/invalid-indentation-indicator-2.yml diff --git a/test/samples-load-errors/invalid-item-without-trailing-break.yml b/test/core/samples-load-errors/invalid-item-without-trailing-break.yml similarity index 100% rename from test/samples-load-errors/invalid-item-without-trailing-break.yml rename to test/core/samples-load-errors/invalid-item-without-trailing-break.yml diff --git a/test/samples-load-errors/invalid-merge-1.yml b/test/core/samples-load-errors/invalid-merge-1.yml similarity index 100% rename from test/samples-load-errors/invalid-merge-1.yml rename to test/core/samples-load-errors/invalid-merge-1.yml diff --git a/test/samples-load-errors/invalid-merge-2.yml b/test/core/samples-load-errors/invalid-merge-2.yml similarity index 100% rename from test/samples-load-errors/invalid-merge-2.yml rename to test/core/samples-load-errors/invalid-merge-2.yml diff --git a/test/samples-load-errors/invalid-omap-1.yml b/test/core/samples-load-errors/invalid-omap-1.yml similarity index 100% rename from test/samples-load-errors/invalid-omap-1.yml rename to test/core/samples-load-errors/invalid-omap-1.yml diff --git a/test/samples-load-errors/invalid-omap-2.yml b/test/core/samples-load-errors/invalid-omap-2.yml similarity index 100% rename from test/samples-load-errors/invalid-omap-2.yml rename to test/core/samples-load-errors/invalid-omap-2.yml diff --git a/test/samples-load-errors/invalid-omap-3.yml b/test/core/samples-load-errors/invalid-omap-3.yml similarity index 100% rename from test/samples-load-errors/invalid-omap-3.yml rename to test/core/samples-load-errors/invalid-omap-3.yml diff --git a/test/samples-load-errors/invalid-pairs-1.yml b/test/core/samples-load-errors/invalid-pairs-1.yml similarity index 100% rename from test/samples-load-errors/invalid-pairs-1.yml rename to test/core/samples-load-errors/invalid-pairs-1.yml diff --git a/test/samples-load-errors/invalid-pairs-2.yml b/test/core/samples-load-errors/invalid-pairs-2.yml similarity index 100% rename from test/samples-load-errors/invalid-pairs-2.yml rename to test/core/samples-load-errors/invalid-pairs-2.yml diff --git a/test/samples-load-errors/invalid-pairs-3.yml b/test/core/samples-load-errors/invalid-pairs-3.yml similarity index 100% rename from test/samples-load-errors/invalid-pairs-3.yml rename to test/core/samples-load-errors/invalid-pairs-3.yml diff --git a/test/samples-load-errors/invalid-simple-key.yml b/test/core/samples-load-errors/invalid-simple-key.yml similarity index 100% rename from test/samples-load-errors/invalid-simple-key.yml rename to test/core/samples-load-errors/invalid-simple-key.yml diff --git a/test/samples-load-errors/invalid-starting-character.yml b/test/core/samples-load-errors/invalid-starting-character.yml similarity index 100% rename from test/samples-load-errors/invalid-starting-character.yml rename to test/core/samples-load-errors/invalid-starting-character.yml diff --git a/test/samples-load-errors/invalid-tag-2.yml b/test/core/samples-load-errors/invalid-tag-2.yml similarity index 100% rename from test/samples-load-errors/invalid-tag-2.yml rename to test/core/samples-load-errors/invalid-tag-2.yml diff --git a/test/samples-load-errors/invalid-tag-directive-handle.yml b/test/core/samples-load-errors/invalid-tag-directive-handle.yml similarity index 100% rename from test/samples-load-errors/invalid-tag-directive-handle.yml rename to test/core/samples-load-errors/invalid-tag-directive-handle.yml diff --git a/test/samples-load-errors/invalid-tag-handle-1.yml b/test/core/samples-load-errors/invalid-tag-handle-1.yml similarity index 100% rename from test/samples-load-errors/invalid-tag-handle-1.yml rename to test/core/samples-load-errors/invalid-tag-handle-1.yml diff --git a/test/samples-load-errors/invalid-tag-handle-2.yml b/test/core/samples-load-errors/invalid-tag-handle-2.yml similarity index 100% rename from test/samples-load-errors/invalid-tag-handle-2.yml rename to test/core/samples-load-errors/invalid-tag-handle-2.yml diff --git a/test/samples-load-errors/invalid-uri-escapes-1.yml b/test/core/samples-load-errors/invalid-uri-escapes-1.yml similarity index 100% rename from test/samples-load-errors/invalid-uri-escapes-1.yml rename to test/core/samples-load-errors/invalid-uri-escapes-1.yml diff --git a/test/samples-load-errors/invalid-uri.yml b/test/core/samples-load-errors/invalid-uri.yml similarity index 100% rename from test/samples-load-errors/invalid-uri.yml rename to test/core/samples-load-errors/invalid-uri.yml diff --git a/test/samples-load-errors/invalid-yaml-directive-version-1.yml b/test/core/samples-load-errors/invalid-yaml-directive-version-1.yml similarity index 100% rename from test/samples-load-errors/invalid-yaml-directive-version-1.yml rename to test/core/samples-load-errors/invalid-yaml-directive-version-1.yml diff --git a/test/samples-load-errors/invalid-yaml-directive-version-2.yml b/test/core/samples-load-errors/invalid-yaml-directive-version-2.yml similarity index 100% rename from test/samples-load-errors/invalid-yaml-directive-version-2.yml rename to test/core/samples-load-errors/invalid-yaml-directive-version-2.yml diff --git a/test/samples-load-errors/invalid-yaml-directive-version-3.yml b/test/core/samples-load-errors/invalid-yaml-directive-version-3.yml similarity index 100% rename from test/samples-load-errors/invalid-yaml-directive-version-3.yml rename to test/core/samples-load-errors/invalid-yaml-directive-version-3.yml diff --git a/test/samples-load-errors/invalid-yaml-directive-version-4.yml b/test/core/samples-load-errors/invalid-yaml-directive-version-4.yml similarity index 100% rename from test/samples-load-errors/invalid-yaml-directive-version-4.yml rename to test/core/samples-load-errors/invalid-yaml-directive-version-4.yml diff --git a/test/samples-load-errors/invalid-yaml-directive-version-5.yml b/test/core/samples-load-errors/invalid-yaml-directive-version-5.yml similarity index 100% rename from test/samples-load-errors/invalid-yaml-directive-version-5.yml rename to test/core/samples-load-errors/invalid-yaml-directive-version-5.yml diff --git a/test/samples-load-errors/invalid-yaml-directive-version-6.yml b/test/core/samples-load-errors/invalid-yaml-directive-version-6.yml similarity index 100% rename from test/samples-load-errors/invalid-yaml-directive-version-6.yml rename to test/core/samples-load-errors/invalid-yaml-directive-version-6.yml diff --git a/test/samples-load-errors/invalid-yaml-version.yml b/test/core/samples-load-errors/invalid-yaml-version.yml similarity index 100% rename from test/samples-load-errors/invalid-yaml-version.yml rename to test/core/samples-load-errors/invalid-yaml-version.yml diff --git a/test/samples-load-errors/no-block-collection-end.yml b/test/core/samples-load-errors/no-block-collection-end.yml similarity index 100% rename from test/samples-load-errors/no-block-collection-end.yml rename to test/core/samples-load-errors/no-block-collection-end.yml diff --git a/test/samples-load-errors/no-block-mapping-end-2.yml b/test/core/samples-load-errors/no-block-mapping-end-2.yml similarity index 100% rename from test/samples-load-errors/no-block-mapping-end-2.yml rename to test/core/samples-load-errors/no-block-mapping-end-2.yml diff --git a/test/samples-load-errors/no-block-mapping-end.yml b/test/core/samples-load-errors/no-block-mapping-end.yml similarity index 100% rename from test/samples-load-errors/no-block-mapping-end.yml rename to test/core/samples-load-errors/no-block-mapping-end.yml diff --git a/test/samples-load-errors/no-document-start.yml b/test/core/samples-load-errors/no-document-start.yml similarity index 100% rename from test/samples-load-errors/no-document-start.yml rename to test/core/samples-load-errors/no-document-start.yml diff --git a/test/samples-load-errors/no-flow-mapping-end.yml b/test/core/samples-load-errors/no-flow-mapping-end.yml similarity index 100% rename from test/samples-load-errors/no-flow-mapping-end.yml rename to test/core/samples-load-errors/no-flow-mapping-end.yml diff --git a/test/samples-load-errors/no-flow-sequence-end.yml b/test/core/samples-load-errors/no-flow-sequence-end.yml similarity index 100% rename from test/samples-load-errors/no-flow-sequence-end.yml rename to test/core/samples-load-errors/no-flow-sequence-end.yml diff --git a/test/samples-load-errors/no-node-1.yml b/test/core/samples-load-errors/no-node-1.yml similarity index 100% rename from test/samples-load-errors/no-node-1.yml rename to test/core/samples-load-errors/no-node-1.yml diff --git a/test/samples-load-errors/no-node-2.yml b/test/core/samples-load-errors/no-node-2.yml similarity index 100% rename from test/samples-load-errors/no-node-2.yml rename to test/core/samples-load-errors/no-node-2.yml diff --git a/test/samples-load-errors/remove-possible-simple-key-bug.yml b/test/core/samples-load-errors/remove-possible-simple-key-bug.yml similarity index 100% rename from test/samples-load-errors/remove-possible-simple-key-bug.yml rename to test/core/samples-load-errors/remove-possible-simple-key-bug.yml diff --git a/test/samples-load-errors/unclosed-bracket.yml b/test/core/samples-load-errors/unclosed-bracket.yml similarity index 100% rename from test/samples-load-errors/unclosed-bracket.yml rename to test/core/samples-load-errors/unclosed-bracket.yml diff --git a/test/samples-load-errors/unclosed-quoted-scalar.yml b/test/core/samples-load-errors/unclosed-quoted-scalar.yml similarity index 100% rename from test/samples-load-errors/unclosed-quoted-scalar.yml rename to test/core/samples-load-errors/unclosed-quoted-scalar.yml diff --git a/test/samples-load-errors/undefined-anchor.yml b/test/core/samples-load-errors/undefined-anchor.yml similarity index 100% rename from test/samples-load-errors/undefined-anchor.yml rename to test/core/samples-load-errors/undefined-anchor.yml diff --git a/test/samples-load-errors/undefined-tag-handle.yml b/test/core/samples-load-errors/undefined-tag-handle.yml similarity index 100% rename from test/samples-load-errors/undefined-tag-handle.yml rename to test/core/samples-load-errors/undefined-tag-handle.yml diff --git a/test/support/schema.js b/test/core/support/schema.js similarity index 56% rename from test/support/schema.js rename to test/core/support/schema.js index 4be287fa..f4bcf84f 100644 --- a/test/support/schema.js +++ b/test/core/support/schema.js @@ -1,36 +1,30 @@ -'use strict'; +'use strict' +const util = require('util') +const yaml = require('js-yaml') -var util = require('util'); -var yaml = require('../../'); - - -function Tag1(parameters) { - this.x = parameters.x; - this.y = parameters.y || 0; - this.z = parameters.z || 0; +function Tag1 (parameters) { + this.x = parameters.x + this.y = parameters.y || 0 + this.z = parameters.z || 0 } - -function Tag2() { - Tag1.apply(this, arguments); +function Tag2 () { + Tag1.apply(this, arguments) } -util.inherits(Tag2, Tag1); - +util.inherits(Tag2, Tag1) -function Tag3() { - Tag2.apply(this, arguments); +function Tag3 () { + Tag2.apply(this, arguments) } -util.inherits(Tag3, Tag2); +util.inherits(Tag3, Tag2) - -function Foo(parameters) { - this.myParameter = parameters.myParameter; - this.myAnotherParameter = parameters.myAnotherParameter; +function Foo (parameters) { + this.myParameter = parameters.myParameter + this.myAnotherParameter = parameters.myAnotherParameter } - -var TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([ +const TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([ // NOTE: Type order matters! // Inherited classes must precede their parents because the dumper // doesn't inspect class inheritance and just picks first suitable @@ -38,77 +32,76 @@ var TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([ new yaml.Type('!tag3', { kind: 'mapping', resolve: function (data) { - if (data === null) return false; + if (data === null) return false if (!Object.prototype.hasOwnProperty.call(data, '=') && !Object.prototype.hasOwnProperty.call(data, 'x')) { - return false; + return false } - if (!Object.keys(data).every(function (k) { return k === '=' || k === 'x' || k === 'y' || k === 'z'; })) { - return false; + if (!Object.keys(data).every(function (k) { return k === '=' || k === 'x' || k === 'y' || k === 'z' })) { + return false } - return true; + return true }, construct: function (data) { - return new Tag3({ x: (data['='] || data.x), y: data.y, z: data.z }); + return new Tag3({ x: (data['='] || data.x), y: data.y, z: data.z }) }, instanceOf: Tag3, represent: function (object) { - return { '=': object.x, y: object.y, z: object.z }; + return { '=': object.x, y: object.y, z: object.z } } }), new yaml.Type('!tag2', { kind: 'scalar', construct: function (data) { - return new Tag2({ x: (typeof data === 'number') ? data : parseInt(data, 10) }); + return new Tag2({ x: (typeof data === 'number') ? data : parseInt(data, 10) }) }, instanceOf: Tag2, represent: function (object) { - return String(object.x); + return String(object.x) } }), new yaml.Type('!tag1', { kind: 'mapping', resolve: function (data) { - if (data === null) return false; - if (!Object.prototype.hasOwnProperty.call(data, 'x')) return false; - if (!Object.keys(data).every(function (k) { return k === 'x' || k === 'y' || k === 'z'; })) { - return false; + if (data === null) return false + if (!Object.prototype.hasOwnProperty.call(data, 'x')) return false + if (!Object.keys(data).every(function (k) { return k === 'x' || k === 'y' || k === 'z' })) { + return false } - return true; + return true }, construct: function (data) { - return new Tag1({ x: data.x, y: data.y, z: data.z }); + return new Tag1({ x: data.x, y: data.y, z: data.z }) }, instanceOf: Tag1 }), new yaml.Type('!foo', { kind: 'mapping', resolve: function (data) { - if (data === null) return false; - if (!Object.keys(data).every(function (k) { return k === 'my-parameter' || k === 'my-another-parameter'; })) { - return false; + if (data === null) return false + if (!Object.keys(data).every(function (k) { return k === 'my-parameter' || k === 'my-another-parameter' })) { + return false } - return true; + return true }, construct: function (data) { return new Foo({ myParameter: data['my-parameter'], myAnotherParameter: data['my-another-parameter'] - }); + }) }, instanceOf: Foo, represent: function (object) { return { 'my-parameter': object.myParameter, 'my-another-parameter': object.myAnotherParameter - }; + } } }) -]); - +]) -module.exports.Tag1 = Tag1; -module.exports.Tag2 = Tag2; -module.exports.Tag3 = Tag3; -module.exports.Foo = Foo; -module.exports.TEST_SCHEMA = TEST_SCHEMA; +module.exports.Tag1 = Tag1 +module.exports.Tag2 = Tag2 +module.exports.Tag3 = Tag3 +module.exports.Foo = Foo +module.exports.TEST_SCHEMA = TEST_SCHEMA diff --git a/test/core/units/alias-nodes.js b/test/core/units/alias-nodes.js new file mode 100644 index 00000000..30150446 --- /dev/null +++ b/test/core/units/alias-nodes.js @@ -0,0 +1,57 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +function TestClass (data) { + const self = this + Object.keys(data).forEach(function (key) { self[key] = data[key] }) +} + +const TestClassYaml = new yaml.Type('!test', { + kind: 'mapping', + construct: function (data) { return new TestClass(data) } +}) + +const TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([TestClassYaml]) + +describe('Alias nodes', function () { + describe('Resolving of an alias node should result the resolved and contructed value of the anchored node', function () { + it('Simple built-in primitives', function () { + assert.strictEqual(yaml.load('[&1 "foobar", *1]')[1], 'foobar') + assert.strictEqual(yaml.load('[&1 ~, *1]')[1], null) + assert.strictEqual(yaml.load('[&1 true, *1]')[1], true) + assert.strictEqual(yaml.load('[&1 42, *1]')[1], 42) + }) + + it('Simple built-in objects', function () { + assert.deepStrictEqual(yaml.load('[&1 [a, b, c, d], *1]')[1], ['a', 'b', 'c', 'd']) + assert.deepStrictEqual(yaml.load('[&1 {a: b, c: d}, *1]')[1], { a: 'b', c: 'd' }) + }) + + it('Recursive built-in objects', function () { + const actual = yaml.load('[&1 {self: *1}, *1]')[1] + + assert(actual === actual.self) + }) + + it('Simple custom objects', function () { + const expected = new TestClass({ a: 'b', c: 'd' }) + const actual = yaml.load('[&1 !test {a: b, c: d}, *1]', { schema: TEST_SCHEMA })[1] + + assert(actual instanceof TestClass) + assert.deepStrictEqual(actual, expected) + }) + + // TODO: Not implemented yet (see issue #141) + it.skip('Recursive custom objects', function () { + const actual = yaml.load('[&1 !test {self: *1}, *1]', { schema: TEST_SCHEMA })[1] + + assert(actual instanceof TestClass) + assert(actual.self instanceof TestClass) + assert(actual === actual.self) + }) + }) +}) diff --git a/test/units/bom-strip.js b/test/core/units/bom-strip.js similarity index 55% rename from test/units/bom-strip.js rename to test/core/units/bom-strip.js index 87bd1115..79ce4f34 100644 --- a/test/units/bom-strip.js +++ b/test/core/units/bom-strip.js @@ -1,11 +1,11 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); - +const assert = require('assert') +const yaml = require('js-yaml') it('BOM strip', function () { - assert.deepStrictEqual(yaml.load('\uFEFFfoo: bar\n'), { foo: 'bar' }); - assert.deepStrictEqual(yaml.load('foo: bar\n'), { foo: 'bar' }); -}); + assert.deepStrictEqual(yaml.load('\uFEFFfoo: bar\n'), { foo: 'bar' }) + assert.deepStrictEqual(yaml.load('foo: bar\n'), { foo: 'bar' }) +}) diff --git a/test/core/units/character-set.js b/test/core/units/character-set.js new file mode 100644 index 00000000..180063ca --- /dev/null +++ b/test/core/units/character-set.js @@ -0,0 +1,28 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Allow astral characters', function () { + assert.deepStrictEqual(yaml.load('𝑘𝑒𝑦: 𝑣𝑎𝑙𝑢𝑒'), { '𝑘𝑒𝑦': '𝑣𝑎𝑙𝑢𝑒' }) +}) + +it('Forbid non-printable characters', function () { + assert.throws(function () { yaml.load('\x01') }, yaml.YAMLException) + assert.throws(function () { yaml.load('\x7f') }, yaml.YAMLException) + assert.throws(function () { yaml.load('\x9f') }, yaml.YAMLException) +}) + +it('Forbid lone surrogates', function () { + assert.throws(function () { yaml.load('\udc00\ud800') }, yaml.YAMLException) +}) + +it('Allow non-printable characters inside quoted scalars', function () { + assert.strictEqual(yaml.load('"\x7f\x9f\udc00\ud800"'), '\x7f\x9f\udc00\ud800') +}) + +it('Forbid control sequences inside quoted scalars', function () { + assert.throws(function () { yaml.load('"\x03"') }, yaml.YAMLException) +}) diff --git a/test/units/dump-scalar-styles.js b/test/core/units/dump-scalar-styles.js similarity index 55% rename from test/units/dump-scalar-styles.js rename to test/core/units/dump-scalar-styles.js index a9cf1f27..b0fc654a 100644 --- a/test/units/dump-scalar-styles.js +++ b/test/core/units/dump-scalar-styles.js @@ -1,27 +1,28 @@ -'use strict'; +'use strict' -var assert = require('assert'); -var yaml = require('../..'); +const { describe, it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') // Indents lines by 2 spaces. Empty lines (\n only) are not indented. -function indent(string) { - return string.replace(/^.+/gm, ' ' + '$&'); +function indent (string) { + return string.replace(/^.+/gm, ' ' + '$&') } -function getLength(s) { - return s.length; +function getLength (s) { + return s.length } // Repeats a string n times. -function repeat(string, n) { - return (new Array(n + 1)).join(string); +function repeat (string, n) { + return (new Array(n + 1)).join(string) } describe('Scalar style dump:', function () { - describe('Plain style', function () { it('is preferred', function () { - [ 'plain', + ['plain', 'hello world', 'pizza 3.14159', // cannot be misinterpreted as a number @@ -33,101 +34,102 @@ describe('Scalar style dump:', function () { '100% safe non-first characters? Of course!', 'Jack & Jill ' ].forEach(function (string) { - assert.strictEqual(yaml.dump(string), string + '\n'); - }); - }); + assert.strictEqual(yaml.dump(string), string + '\n') + }) + }) it('disallows flow indicators inside flow collections', function () { assert.strictEqual(yaml.dump({ quote: 'mispell [sic]' }, { flowLevel: 0 }), - "{quote: 'mispell [sic]'}\n"); + "{quote: 'mispell [sic]'}\n") assert.strictEqual(yaml.dump({ key: 'no commas, either' }, { flowLevel: 0 }), - "{key: 'no commas, either'}\n"); - }); - }); + "{key: 'no commas, either'}\n") + }) + }) describe('Single- and double-quoted styles', function () { it('quote strings of ambiguous type', function () { - assert.strictEqual(yaml.dump('Yes'), '\'Yes\'\n'); - assert.strictEqual(yaml.dump('true'), '\'true\'\n'); - assert.strictEqual(yaml.dump('42'), '\'42\'\n'); - assert.strictEqual(yaml.dump('99.9'), '\'99.9\'\n'); - assert.strictEqual(yaml.dump('127.0001'), '\'127.0001\'\n'); - assert.strictEqual(yaml.dump('1.23015e+3'), '\'1.23015e+3\'\n'); - }); + assert.strictEqual(yaml.dump('Yes'), '\'Yes\'\n') + assert.strictEqual(yaml.dump('true'), '\'true\'\n') + assert.strictEqual(yaml.dump('42'), '\'42\'\n') + assert.strictEqual(yaml.dump('99.9'), '\'99.9\'\n') + assert.strictEqual(yaml.dump('127.0001'), '\'127.0001\'\n') + assert.strictEqual(yaml.dump('1.23015e+3'), '\'1.23015e+3\'\n') + }) it('quote leading/trailing whitespace', function () { - assert.strictEqual(yaml.dump(' leading space'), '\' leading space\'\n'); - assert.strictEqual(yaml.dump('trailing space '), '\'trailing space \'\n'); - }); + assert.strictEqual(yaml.dump(' leading space'), '\' leading space\'\n') + assert.strictEqual(yaml.dump('trailing space '), '\'trailing space \'\n') + }) it('quote leading quotes', function () { - assert.strictEqual(yaml.dump("'singles double'"), "'''singles double'''\n"); - assert.strictEqual(yaml.dump('"single double'), '\'"single double\'\n'); - }); + assert.strictEqual(yaml.dump("'singles double'"), "'''singles double'''\n") + assert.strictEqual(yaml.dump('"single double'), '\'"single double\'\n') + }) it('escape \\ and " in double-quoted', function () { - assert.strictEqual(yaml.dump('\u0007 escape\\ escaper"'), '"\\a escape\\\\ escaper\\""\n'); - }); + assert.strictEqual(yaml.dump('\u0007 escape\\ escaper"'), '"\\a escape\\\\ escaper\\""\n') + }) it('escape non-printables', function () { - assert.strictEqual(yaml.dump('a\nb\u0001c'), '"a\\nb\\x01c"\n'); - }); - }); + assert.strictEqual(yaml.dump('a\nb\u0001c'), '"a\\nb\\x01c"\n') + }) + }) describe('Literal style', function () { - var content = 'a\nb \n\n c\n d', indented = indent(content); + const content = 'a\nb \n\n c\n d' + const indented = indent(content) it('preserves trailing newlines using chomping', function () { assert.strictEqual(yaml.dump({ a: '\n', b: '\n\n', c: 'c\n', d: 'd\nd' }), - 'a: |+\n\nb: |+\n\n\nc: |\n c\nd: |-\n d\n d\n'); - assert.strictEqual(yaml.dump('\n'), '|+\n' + '\n'); - assert.strictEqual(yaml.dump('\n\n'), '|+\n' + '\n\n'); + 'a: |+\n\nb: |+\n\n\nc: |\n c\nd: |-\n d\n d\n') + assert.strictEqual(yaml.dump('\n'), '|+\n' + '\n') + assert.strictEqual(yaml.dump('\n\n'), '|+\n' + '\n\n') - assert.strictEqual(yaml.dump(content), '|-\n' + indented + '\n'); - assert.strictEqual(yaml.dump(content + '\n'), '|\n' + indented + '\n'); - assert.strictEqual(yaml.dump(content + '\n\n'), '|+\n' + indented + '\n\n'); - assert.strictEqual(yaml.dump(content + '\n\n\n'), '|+\n' + indented + '\n\n\n'); - }); + assert.strictEqual(yaml.dump(content), '|-\n' + indented + '\n') + assert.strictEqual(yaml.dump(content + '\n'), '|\n' + indented + '\n') + assert.strictEqual(yaml.dump(content + '\n\n'), '|+\n' + indented + '\n\n') + assert.strictEqual(yaml.dump(content + '\n\n\n'), '|+\n' + indented + '\n\n\n') + }) it('accepts leading whitespace', function () { - assert.strictEqual(yaml.dump(' ' + content), '|2-\n ' + indented + '\n'); - }); + assert.strictEqual(yaml.dump(' ' + content), '|2-\n ' + indented + '\n') + }) it('falls back to quoting when required indent indicator is too large', function () { assert.strictEqual(yaml.dump(' these go\nup to\neleven', { indent: 11 }), - '" these go\\nup to\\neleven"\n'); - }); + '" these go\\nup to\\neleven"\n') + }) it('does not use block style for multiline key', function () { assert.strictEqual(yaml.dump({ 'push\nand': { you: 'pull' } - }), '"push\\nand":\n you: pull\n'); - }); - }); + }), '"push\\nand":\n you: pull\n') + }) + }) describe('Folded style', function () { (function () { - var content = (function () { - var result = ''; - var i = 1000; - for (var para = 1; para <= 7; para++) { - result += '\n'; + const content = (function () { + let result = '' + let i = 1000 + for (let para = 1; para <= 7; para++) { + result += '\n' // indent paragraphs 3 and 4 if (para === 3 || para === 4) { - result += repeat(' ', para); + result += repeat(' ', para) } // vary the number of words on the last line - for (var count = 2 * (30 / 5) + para - 1; count > 0; count--) { - result += i + ' '; - if (i % 17 === 0) result += ' '; - i++; + for (let count = 2 * (30 / 5) + para - 1; count > 0; count--) { + result += i + ' ' + if (i % 17 === 0) result += ' ' + i++ } } - return result; - }()); - var wrapped = '\n' + + return result + }()) + const wrapped = '\n' + '1000 1001 1002 1003 1004 1005\n' + '1006 1007 1008 1009 1010 1011 \n' + '\n' + @@ -146,29 +148,29 @@ describe('Scalar style dump:', function () { '\n' + '1087 1088 1089 1090 1091 1092\n' + '1093 1094 1095 1096 1097 1098\n' + - '1099 1100 1101 1102 1103 1104 '; - var indented = indent(wrapped); + '1099 1100 1101 1102 1103 1104 ' + const indented = indent(wrapped) - function dumpNarrow(s) { - return yaml.dump(s, { lineWidth: 30 + 2 }); + function dumpNarrow (s) { + return yaml.dump(s, { lineWidth: 30 + 2 }) } it('wraps lines and ignores more-indented lines ', function () { - assert.strictEqual(dumpNarrow(content), '>-\n' + indented + '\n'); - }); + assert.strictEqual(dumpNarrow(content), '>-\n' + indented + '\n') + }) it('preserves trailing newlines using chomping', function () { - assert.strictEqual(dumpNarrow(content + '\n'), '>\n' + indented + '\n'); - assert.strictEqual(dumpNarrow(content + '\n\n'), '>+\n' + indented + '\n\n'); - assert.strictEqual(dumpNarrow(content + '\n\n\n'), '>+\n' + indented + '\n\n\n'); - }); - }()); + assert.strictEqual(dumpNarrow(content + '\n'), '>\n' + indented + '\n') + assert.strictEqual(dumpNarrow(content + '\n\n'), '>+\n' + indented + '\n\n') + assert.strictEqual(dumpNarrow(content + '\n\n\n'), '>+\n' + indented + '\n\n\n') + }) + }()) // Dump and check that dump-then-load preserves content (is the identity function). - function dump(input, opts) { - var output = yaml.dump(input, opts); - assert.strictEqual(yaml.load(output), input, 'Dump then load should preserve content'); - return output; + function dump (input, opts) { + const output = yaml.dump(input, opts) + assert.strictEqual(yaml.load(output), input, 'Dump then load should preserve content') + return output } it('should not cut off a long word at the start of a line', function () { @@ -179,12 +181,12 @@ describe('Scalar style dump:', function () { repeat('1234567890', 9) + '\n' + 'hello\n' + '\n' + - 'goodbye\n')); - }); + 'goodbye\n')) + }) it('preserves consecutive spaces', function () { - var alphabet = 'a bc def ghi' + repeat(' ', 70) + 'jk lmn o\n' - + ' p qrstu v' + repeat(' ', 80) + '\nw x\n' + 'yz '; + const alphabet = 'a bc def ghi' + repeat(' ', 70) + 'jk lmn o\n' + + ' p qrstu v' + repeat(' ', 80) + '\nw x\n' + 'yz ' assert.strictEqual(dump(alphabet), '>-\n' + indent( 'a bc def \n' + @@ -193,53 +195,53 @@ describe('Scalar style dump:', function () { ' p qrstu v' + repeat(' ', 80) + '\n' + 'w x\n' + '\n' + - 'yz \n')); + 'yz \n')) - var indeed = repeat('word. ', 31) + '\n' + - [ 2, 3, 5, 7, 11, 13, 17 ] - .map(function (n) { return repeat(' ', n); }) - .join('\n'); + const indeed = repeat('word. ', 31) + '\n' + + [2, 3, 5, 7, 11, 13, 17] + .map(function (n) { return repeat(' ', n) }) + .join('\n') assert.strictEqual(dump(indeed), '>-\n' + indent( 'word. word. word. word. word. word. word. word. word. word. word. word. word.\n' + 'word. word. word. word. word. word. word. word. word. word. word. word. word.\n' + 'word. word. word. word. word. \n' + - [ 2, 3, 5, 7, 11, 13, 17 ] - .map(function (n) { return repeat(' ', n); }) - .join('\n') + '\n')); - }); - - var story = 'Call me Ishmael. Some years ago—never mind how long precisely—' - + 'having little or no money in my purse, ' - + 'and nothing particular to interest me on shore, ' - + 'I thought I would sail about a little and see the watery part of the world...'; - var prefix = 'var short_story = "",'; - var line = 'longer_story = "' + story + '";'; + [2, 3, 5, 7, 11, 13, 17] + .map(function (n) { return repeat(' ', n) }) + .join('\n') + '\n')) + }) + + const story = 'Call me Ishmael. Some years ago—never mind how long precisely—' + + 'having little or no money in my purse, ' + + 'and nothing particular to interest me on shore, ' + + 'I thought I would sail about a little and see the watery part of the world...' + const prefix = 'var short_story = "",' + const line = 'longer_story = "' + story + '";' it('should fold a long last line missing an ending newline', function () { - var content = [ prefix, line ].join('\n'); + const content = [prefix, line].join('\n') - var lengths = dump(content).split('\n').map(getLength); - assert.deepStrictEqual(lengths, [ 2, 23, 0, 69, 76, 80, 24, 0 ]); - }); + const lengths = dump(content).split('\n').map(getLength) + assert.deepStrictEqual(lengths, [2, 23, 0, 69, 76, 80, 24, 0]) + }) - it('should not fold a more-indented last line', function functionName() { - var content = [ prefix, line, ' ' + line ].join('\n'); + it('should not fold a more-indented last line', function functionName () { + const content = [prefix, line, ' ' + line].join('\n') - var lengths = dump(content).split('\n').map(getLength); - assert.deepStrictEqual(lengths, [ 2, 23, 0, 69, 76, 80, 24, 250, 0 ]); - }); + const lengths = dump(content).split('\n').map(getLength) + assert.deepStrictEqual(lengths, [2, 23, 0, 69, 76, 80, 24, 250, 0]) + }) it('should not fold when lineWidth === -1', function () { - var content = [ prefix, line, line + line, line ].join('\n'); + const content = [prefix, line, line + line, line].join('\n') - assert.strictEqual(dump(content, { lineWidth: -1 }), '|-\n' + indent(content) + '\n'); - }); + assert.strictEqual(dump(content, { lineWidth: -1 }), '|-\n' + indent(content) + '\n') + }) it('falls back to literal style when no lines are foldable', function () { - var content = [ prefix, ' ' + line, ' ' + line ].join('\n'); + const content = [prefix, ' ' + line, ' ' + line].join('\n') - assert.strictEqual(dump(content), '|-\n' + indent(content) + '\n'); - }); - }); -}); + assert.strictEqual(dump(content), '|-\n' + indent(content) + '\n') + }) + }) +}) diff --git a/test/core/units/empty-node-resolving.js b/test/core/units/empty-node-resolving.js new file mode 100644 index 00000000..b3e0fa64 --- /dev/null +++ b/test/core/units/empty-node-resolving.js @@ -0,0 +1,61 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +describe('Resolving explicit tags on empty nodes', function () { + it('!!binary', function () { + assert.throws(function () { yaml.load('!!binary') }, yaml.YAMLException) + }) + + it('!!bool', function () { + assert.throws(function () { yaml.load('!!bool') }, yaml.YAMLException) + }) + + it('!!float', function () { + assert.throws(function () { yaml.load('!!float') }, yaml.YAMLException) + }) + + it('!!int', function () { + assert.throws(function () { yaml.load('!!int') }, yaml.YAMLException) + }) + + it('!!map', function () { + assert.deepStrictEqual(yaml.load('!!map'), {}) + }) + + it('!!merge', function () { + assert.doesNotThrow(function () { yaml.load('? !!merge\n: []') }) + }) + + it('!!null', function () { + // Fetch null from an array to reduce chance that null is returned because of another bug + assert.strictEqual(yaml.load('- !!null')[0], null) + }) + + it('!!omap', function () { + assert.deepStrictEqual(yaml.load('!!omap'), []) + }) + + it('!!pairs', function () { + assert.deepStrictEqual(yaml.load('!!pairs'), []) + }) + + it('!!seq', function () { + assert.deepStrictEqual(yaml.load('!!seq'), []) + }) + + it('!!set', function () { + assert.deepStrictEqual(yaml.load('!!set'), {}) + }) + + it('!!str', function () { + assert.strictEqual(yaml.load('!!str'), '') + }) + + it('!!timestamp', function () { + assert.throws(function () { yaml.load('!!timestamp') }, yaml.YAMLException) + }) +}) diff --git a/test/core/units/is-negative-zero.js b/test/core/units/is-negative-zero.js new file mode 100644 index 00000000..64e588b7 --- /dev/null +++ b/test/core/units/is-negative-zero.js @@ -0,0 +1,14 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') + +const isNegativeZero = require('../../../lib/common').isNegativeZero + +it('isNegativeZero', function () { + assert(!isNegativeZero(0)) + assert(!isNegativeZero(0.0)) + assert(isNegativeZero(-0)) + assert(isNegativeZero(-0.0)) +}) diff --git a/test/core/units/loader-parameters.js b/test/core/units/loader-parameters.js new file mode 100644 index 00000000..ab4afdcd --- /dev/null +++ b/test/core/units/loader-parameters.js @@ -0,0 +1,56 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +describe('loader parameters', function () { + const testStr = 'test: 1 \ntest: 2' + const expected = [{ test: 2 }] + let result + + it('loadAll(input, options)', function () { + result = yaml.loadAll(testStr, { json: true }) + assert.deepStrictEqual(result, expected) + + result = [] + yaml.loadAll(testStr, function (doc) { + result.push(doc) + }, { json: true }) + assert.deepStrictEqual(result, expected) + }) + + it('loadAll(input, null, options)', function () { + result = yaml.loadAll(testStr, null, { json: true }) + assert.deepStrictEqual(result, expected) + + result = [] + yaml.loadAll(testStr, function (doc) { + result.push(doc) + }, { json: true }) + assert.deepStrictEqual(result, expected) + }) + + it('loadAll(input, options)', function () { + result = yaml.loadAll(testStr, { json: true }) + assert.deepStrictEqual(result, expected) + + result = [] + yaml.loadAll(testStr, function (doc) { + result.push(doc) + }, { json: true }) + assert.deepStrictEqual(result, expected) + }) + + it('loadAll(input, null, options)', function () { + result = yaml.loadAll(testStr, null, { json: true }) + assert.deepStrictEqual(result, expected) + + result = [] + yaml.loadAll(testStr, function (doc) { + result.push(doc) + }, { json: true }) + assert.deepStrictEqual(result, expected) + }) +}) diff --git a/test/core/units/replacer.js b/test/core/units/replacer.js new file mode 100644 index 00000000..9298ace8 --- /dev/null +++ b/test/core/units/replacer.js @@ -0,0 +1,172 @@ +'use strict' + +const { describe, it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +describe('replacer', function () { + const undef = new yaml.Type('!undefined', { + kind: 'scalar', + resolve: () => true, + construct: () => {}, + predicate: object => typeof object === 'undefined', + represent: () => '' + }) + + const undef_schema = yaml.DEFAULT_SCHEMA.extend(undef) + + it('should be called on the root of the document', function () { + let called = 0 + + const result = yaml.dump(42, { + replacer (key, value) { + called++ + assert.deepStrictEqual(this, { '': 42 }) + assert.strictEqual(key, '') + assert.strictEqual(value, 42) + return 123 + } + }) + assert.strictEqual(result, '123\n') + assert.strictEqual(called, 1) + + assert.strictEqual(yaml.dump(42, { + replacer (/* key, value */) {} + }), '') + + assert.strictEqual(yaml.dump(42, { + replacer (/* key, value */) { return 'foo' } + }), 'foo\n') + }) + + it('should be called in collections (block)', function () { + let called = 0 + + const result = yaml.dump([42], { + replacer (key, value) { + called++ + if (key === '' && called === 1) return value + assert.deepStrictEqual(this, [42]) + assert.strictEqual(key, '0') + assert.strictEqual(value, 42) + return 123 + }, + flowLevel: -1 + }) + assert.strictEqual(result, '- 123\n') + assert.strictEqual(called, 2) + }) + + it('should be called in collections (flow)', function () { + let called = 0 + + const result = yaml.dump([42], { + replacer (key, value) { + called++ + if (key === '' && called === 1) return value + assert.deepStrictEqual(this, [42]) + assert.strictEqual(key, '0') + assert.strictEqual(value, 42) + return 123 + }, + flowLevel: 0 + }) + assert.strictEqual(result, '[123]\n') + assert.strictEqual(called, 2) + }) + + it('should be called in mappings (block)', function () { + let called = 0 + + const result = yaml.dump({ a: 42 }, { + replacer (key, value) { + called++ + if (key === '' && called === 1) return value + assert.deepStrictEqual(this, { a: 42 }) + assert.strictEqual(key, 'a') + assert.strictEqual(value, 42) + return 123 + }, + flowLevel: -1 + }) + assert.strictEqual(result, 'a: 123\n') + assert.strictEqual(called, 2) + }) + + it('should be called in mappings (flow)', function () { + let called = 0 + + const result = yaml.dump({ a: 42 }, { + replacer (key, value) { + called++ + if (key === '' && called === 1) return value + assert.deepStrictEqual(this, { a: 42 }) + assert.strictEqual(key, 'a') + assert.strictEqual(value, 42) + return 123 + }, + flowLevel: 0 + }) + assert.strictEqual(result, '{a: 123}\n') + assert.strictEqual(called, 2) + }) + + it('undefined removes element from a mapping', function () { + let str = yaml.dump({ a: 1, b: 2, c: 3 }, { + replacer (key, value) { + if (key === 'b') return undefined + return value + } + }) + let result = yaml.load(str) + assert.deepStrictEqual(result, { a: 1, c: 3 }) + + str = yaml.dump({ a: 1, b: 2, c: 3 }, { + replacer (key, value) { + if (key === 'b') return undefined + return value + }, + schema: undef_schema + }) + result = yaml.load(str, { schema: undef_schema }) + assert.deepStrictEqual(result, { a: 1, b: undefined, c: 3 }) + }) + + it('undefined replaces element in an array with null', function () { + let str = yaml.dump([1, 2, 3], { + replacer (key, value) { + if (key === '1') return undefined + return value + } + }) + let result = yaml.load(str) + assert.deepStrictEqual(result, [1, null, 3]) + + str = yaml.dump([1, 2, 3], { + replacer (key, value) { + if (key === '1') return undefined + return value + }, + schema: undef_schema + }) + result = yaml.load(str, { schema: undef_schema }) + assert.deepStrictEqual(result, [1, undefined, 3]) + }) + + it('should recursively call replacer', function () { + let count = 0 + + const result = yaml.dump(42, { + replacer (key, value) { + return count++ > 3 ? value : { ['lvl' + count]: value } + } + }) + assert.strictEqual(result, ` +lvl1: + lvl2: + lvl3: + lvl4: 42 +`.replace(/^\n/, '')) + }) +}) diff --git a/test/core/units/single-document-error.js b/test/core/units/single-document-error.js new file mode 100644 index 00000000..2480bcdb --- /dev/null +++ b/test/core/units/single-document-error.js @@ -0,0 +1,20 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const yaml = require('js-yaml') + +it('Loading multidocument source using `load` should cause an error', function () { + assert.throws(function () { + yaml.load('--- # first document\n--- # second document\n') + }, yaml.YAMLException) + + assert.throws(function () { + yaml.load('---\nfoo: bar\n---\nfoo: bar\n') + }, yaml.YAMLException) + + assert.throws(function () { + yaml.load('foo: bar\n---\nfoo: bar\n') + }, yaml.YAMLException) +}) diff --git a/test/units/skip-invalid.js b/test/core/units/skip-invalid.js similarity index 53% rename from test/units/skip-invalid.js rename to test/core/units/skip-invalid.js index 54e539f2..2bb05ac2 100644 --- a/test/units/skip-invalid.js +++ b/test/core/units/skip-invalid.js @@ -1,33 +1,30 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); +const assert = require('assert') +const yaml = require('js-yaml') - -var sample = { +const sample = { number: 42, string: 'hello', - func: function (a, b) { return a + b; }, + func: function (a, b) { return a + b }, regexp: /^hel+o/, - array: [ 1, 2, 3 ] -}; - + array: [1, 2, 3] +} -var expected = { +const expected = { number: 42, string: 'hello', - array: [ 1, 2, 3 ] -}; - + array: [1, 2, 3] +} it('Dumper must throw an exception on invalid type when option `skipInvalid` is false.', function () { assert.throws(function () { - yaml.dump(sample, { skipInvalid: false }); - }, yaml.YAMLException); -}); - + yaml.dump(sample, { skipInvalid: false }) + }, yaml.YAMLException) +}) it('Dumper must skip pairs and values with invalid types when option `skipInvalid` is true.', function () { - assert.deepStrictEqual(yaml.load(yaml.dump(sample, { skipInvalid: true })), expected); -}); + assert.deepStrictEqual(yaml.load(yaml.dump(sample, { skipInvalid: true })), expected) +}) diff --git a/test/core/units/snippet.js b/test/core/units/snippet.js new file mode 100644 index 00000000..7982a0df --- /dev/null +++ b/test/core/units/snippet.js @@ -0,0 +1,52 @@ +'use strict' + +const { it } = require('node:test') + +const assert = require('assert') +const path = require('path') +const fs = require('fs') +const snippet = require('../../../lib/snippet') + +it('Snippet', function () { + const filepath = path.join(__dirname, 'snippet.txt') + const filedata = fs.readFileSync(filepath, 'utf8') + + const data = filedata.split(/(---[ \d]*\n)/).slice(1) + + for (let i = 0; i < data.length; i += 4) { + let index = 0 + let line = 0 + let column = 0 + const input = data[i + 1] + const expected = data[i + 3].replace(/\n$/, '') + + assert(input.indexOf('*') >= 0) + + while (input[index] !== '*') { + if (input[index] === '\n') { + line += 1 + column = 0 + } else { + column += 1 + } + index += 1 + } + + const mark = { + name: filepath, + buffer: input, + position: index, + line: line, + column: column + } + + const code = snippet(mark, { + indent: 1, + maxLength: 78, + linesBefore: 3, + linesAfter: 2 + }) + + assert.strictEqual(code, expected) + } +}) diff --git a/test/units/snippet.txt b/test/core/units/snippet.txt similarity index 100% rename from test/units/snippet.txt rename to test/core/units/snippet.txt diff --git a/test/units/sort-keys.js b/test/core/units/sort-keys.js similarity index 52% rename from test/units/sort-keys.js rename to test/core/units/sort-keys.js index 9cde2f4b..285a43f6 100644 --- a/test/units/sort-keys.js +++ b/test/core/units/sort-keys.js @@ -1,26 +1,27 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); +const assert = require('assert') +const yaml = require('js-yaml') -var sample = { b: 1, a: 2, c: 3 }; -var unsortedExpected = 'b: 1\na: 2\nc: 3\n'; -var simpleExpected = 'a: 2\nb: 1\nc: 3\n'; -var reverseExpected = 'c: 3\nb: 1\na: 2\n'; +const sample = { b: 1, a: 2, c: 3 } +const unsortedExpected = 'b: 1\na: 2\nc: 3\n' +const simpleExpected = 'a: 2\nb: 1\nc: 3\n' +const reverseExpected = 'c: 3\nb: 1\na: 2\n' it('Dumper should sort preserve key insertion order', function () { - assert.deepStrictEqual(yaml.dump(sample, { sortKeys: false }), unsortedExpected); -}); + assert.deepStrictEqual(yaml.dump(sample, { sortKeys: false }), unsortedExpected) +}) it('Dumper should sort keys when sortKeys is true', function () { - assert.deepStrictEqual(yaml.dump(sample, { sortKeys: true }), simpleExpected); -}); + assert.deepStrictEqual(yaml.dump(sample, { sortKeys: true }), simpleExpected) +}) it('Dumper should sort keys by sortKeys function when specified', function () { assert.deepStrictEqual(yaml.dump(sample, { sortKeys: function (a, b) { - return a < b ? 1 : a > b ? -1 : 0; + return a < b ? 1 : a > b ? -1 : 0 } - }), reverseExpected); -}); + }), reverseExpected) +}) diff --git a/test/units/tagmultikind.js b/test/core/units/tagmultikind.js similarity index 61% rename from test/units/tagmultikind.js rename to test/core/units/tagmultikind.js index 13dbc850..fe6edf30 100644 --- a/test/units/tagmultikind.js +++ b/test/core/units/tagmultikind.js @@ -1,39 +1,38 @@ -'use strict'; +'use strict' +const { it } = require('node:test') -var assert = require('assert'); -var yaml = require('../../'); +const assert = require('assert') +const yaml = require('js-yaml') -var tags = [ { +const tags = [{ tag: 'Include', type: 'scalar' }, { tag: 'Include', type: 'mapping' -} ].map(function (fn) { +}].map(function (fn) { return new yaml.Type('!' + fn.tag, { kind: fn.type, resolve: function () { - return true; + return true }, construct: function (obj) { - return obj; + return obj } - }); -}); - -var schema = yaml.DEFAULT_SCHEMA.extend(tags); + }) +}) +const schema = yaml.DEFAULT_SCHEMA.extend(tags) it('Process tag with kind: scalar', function () { assert.deepStrictEqual(yaml.load('!Include foobar', { schema: schema - }), 'foobar'); -}); - + }), 'foobar') +}) it('Process tag with kind: mapping', function () { assert.deepStrictEqual(yaml.load('!Include\n location: foobar', { schema: schema - }), { location: 'foobar' }); -}); + }), { location: 'foobar' }) +}) diff --git a/test/issues/0008.js b/test/issues/0008.js deleted file mode 100644 index c96010aa..00000000 --- a/test/issues/0008.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Parse failed when no document start present', function () { - assert.doesNotThrow(function () { - yaml.load(` -foo: !!str bar -`); - }, TypeError); -}); diff --git a/test/issues/0017.js b/test/issues/0017.js deleted file mode 100644 index ed24601d..00000000 --- a/test/issues/0017.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Non-specific "!" tags should resolve to !!str', function () { - var data = yaml.load(` -! 12 -`); - - assert.strictEqual(typeof data, 'string'); -}); diff --git a/test/issues/0026.js b/test/issues/0026.js deleted file mode 100644 index 3efbb847..00000000 --- a/test/issues/0026.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('should convert new line into white space', function () { - var data = yaml.load(` -test: > - a - b - c -`); - - assert.strictEqual(data.test, 'a b c\n'); -}); diff --git a/test/issues/0027.js b/test/issues/0027.js deleted file mode 100644 index acef8267..00000000 --- a/test/issues/0027.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -describe('Should load numbers in YAML 1.2 format', function () { - it('should not parse base60', function () { - // previously parsed as int - assert.strictEqual(yaml.load('1:23'), '1:23'); - // previously parsed as float - assert.strictEqual(yaml.load('1:23.45'), '1:23.45'); - }); - - it('should allow leading zero in int and float', function () { - assert.strictEqual(yaml.load('01234'), 1234); - assert.strictEqual(yaml.load('00999'), 999); - assert.strictEqual(yaml.load('-00999'), -999); - assert.strictEqual(yaml.load('001234.56'), 1234.56); - assert.strictEqual(yaml.load('001234e4'), 12340000); - assert.strictEqual(yaml.load('-001234.56'), -1234.56); - assert.strictEqual(yaml.load('-001234e4'), -12340000); - }); - - it('should parse 0o prefix as octal', function () { - assert.strictEqual(yaml.load('0o1234'), 668); - // not valid octal - assert.strictEqual(yaml.load('0o1289'), '0o1289'); - }); -}); - - -describe('Should dump numbers in YAML 1.2 format', function () { - it('should dump in different styles', function () { - assert.strictEqual(yaml.dump(123, { styles: { '!!int': 'binary' } }), '0b1111011\n'); - assert.strictEqual(yaml.dump(123, { styles: { '!!int': 'octal' } }), '0o173\n'); - assert.strictEqual(yaml.dump(123, { styles: { '!!int': 'hex' } }), '0x7B\n'); - }); - - it('should quote all potential numbers', function () { - var tests = '1:23 1:23.45 01234 0999 -01234 01234e4 01234.56 -01234.56 0x123 0o123'; - - tests.split(' ').forEach(function (sample) { - assert.strictEqual(yaml.dump(sample, { noCompatMode: false }), "'" + sample + "'\n"); - }); - }); - - it('should not quote base60 in noCompatMode', function () { - var tests = '1:23 1:23.45'; - - tests.split(' ').forEach(function (sample) { - assert.strictEqual(yaml.dump(sample, { noCompatMode: true }), sample + '\n'); - }); - }); -}); diff --git a/test/issues/0033.js b/test/issues/0033.js deleted file mode 100644 index bec7da74..00000000 --- a/test/issues/0033.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('refactor compact variant of MarkedYAMLError.toString', function () { - var source = ` -foo: {bar} baz -`; - - assert.throws(function () { - yaml.load(source); - }, "require('issue-33.yml') should throw, but it does not"); -}); diff --git a/test/issues/0046.js b/test/issues/0046.js deleted file mode 100644 index fe72ce13..00000000 --- a/test/issues/0046.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Timestamps are incorrectly parsed in local time', function () { - var src = ` -date1: 2010-10-20T20:45:00Z -date2: 2010-10-20T20:45:00+01:00 -`; - var data = yaml.load(src), - date1, date2; - - date1 = data.date1; // date1: 2010-10-20T20:45:00Z - assert.strictEqual(date1.getUTCFullYear(), 2010, 'year'); - assert.strictEqual(date1.getUTCMonth(), 9, 'month'); - assert.strictEqual(date1.getUTCDate(), 20, 'date'); - assert.strictEqual(date1.getUTCHours(), 20); - assert.strictEqual(date1.getUTCMinutes(), 45); - assert.strictEqual(date1.getUTCSeconds(), 0); - - date2 = data.date2; // date2: 2010-10-20T20:45:00+0100 - assert.strictEqual(date2.getUTCFullYear(), 2010, 'year'); - assert.strictEqual(date2.getUTCMonth(), 9, 'month'); - assert.strictEqual(date2.getUTCDate(), 20, 'date'); - assert.strictEqual(date2.getUTCHours(), 19); - assert.strictEqual(date2.getUTCMinutes(), 45); - assert.strictEqual(date2.getUTCSeconds(), 0); -}); diff --git a/test/issues/0063.js b/test/issues/0063.js deleted file mode 100644 index 829e83bd..00000000 --- a/test/issues/0063.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Invalid errors/warnings of invalid indentation on flow scalars', function () { - var sources = [ - 'text:\n hello\n world', // plain style - "text:\n 'hello\n world'", // single-quoted style - 'text:\n "hello\n world"' // double-quoted style - ]; - var expected = { text: 'hello world' }; - - assert.doesNotThrow(function () { yaml.load(sources[0]); }, 'Throws on plain style'); - assert.doesNotThrow(function () { yaml.load(sources[1]); }, 'Throws on single-quoted style'); - assert.doesNotThrow(function () { yaml.load(sources[2]); }, 'Throws on double-quoted style'); - - assert.deepStrictEqual(yaml.load(sources[0]), expected); - assert.deepStrictEqual(yaml.load(sources[1]), expected); - assert.deepStrictEqual(yaml.load(sources[2]), expected); -}); diff --git a/test/issues/0064.js b/test/issues/0064.js deleted file mode 100644 index 42bec2e9..00000000 --- a/test/issues/0064.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); -var readFileSync = require('fs').readFileSync; - - -it('Wrong error message when yaml file contains tabs', function () { - assert.doesNotThrow( - function () { yaml.load(readFileSync(require('path').join(__dirname, '/0064.yml'), 'utf8')); }, - yaml.YAMLException); -}); diff --git a/test/issues/0068.js b/test/issues/0068.js deleted file mode 100644 index 32b7343f..00000000 --- a/test/issues/0068.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Prevent adding unnecessary space character to end of a line within block collections', function () { - assert.strictEqual(yaml.dump({ data: [ 'foo', 'bar', 'baz' ] }), 'data:\n - foo\n - bar\n - baz\n'); - assert.strictEqual(yaml.dump({ foo: { bar: [ 'baz' ] } }), 'foo:\n bar:\n - baz\n'); -}); diff --git a/test/issues/0092.js b/test/issues/0092.js deleted file mode 100644 index 4de901f3..00000000 --- a/test/issues/0092.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Invalid parse error on whitespace between quoted scalar keys and ":" symbol in mappings', function () { - assert.doesNotThrow(function () { - yaml.load('{ "field1" : "v1", "field2": "v2" }'); - }); -}); diff --git a/test/issues/0093.js b/test/issues/0093.js deleted file mode 100644 index 05740842..00000000 --- a/test/issues/0093.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Unwanted line breaks in folded scalars', function () { - var data = yaml.load(` -first: > - a - b - c - d - e - f - -second: > - a - b - c - - d - e - f - -third: > - a - b - - c - d - e - f -`); - - assert.strictEqual(data.first, 'a b\n c\n d\ne f\n'); - assert.strictEqual(data.second, 'a b\n c\n\n d\ne f\n'); - assert.strictEqual(data.third, 'a b\n\n c\n d\ne f\n'); -}); diff --git a/test/issues/0095.js b/test/issues/0095.js deleted file mode 100644 index 35a48b74..00000000 --- a/test/issues/0095.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Empty block scalars loaded wrong', function () { - assert.deepStrictEqual(yaml.load('a: |\nb: .'), { a: '', b: '.' }); - assert.deepStrictEqual(yaml.load('a: |+\nb: .'), { a: '', b: '.' }); - assert.deepStrictEqual(yaml.load('a: |-\nb: .'), { a: '', b: '.' }); - - assert.deepStrictEqual(yaml.load('a: >\nb: .'), { a: '', b: '.' }); - assert.deepStrictEqual(yaml.load('a: >+\nb: .'), { a: '', b: '.' }); - assert.deepStrictEqual(yaml.load('a: >-\nb: .'), { a: '', b: '.' }); - - assert.deepStrictEqual(yaml.load('a: |\n\nb: .'), { a: '', b: '.' }); - assert.deepStrictEqual(yaml.load('a: |+\n\nb: .'), { a: '\n', b: '.' }); - assert.deepStrictEqual(yaml.load('a: |-\n\nb: .'), { a: '', b: '.' }); - - assert.deepStrictEqual(yaml.load('a: >\n\nb: .'), { a: '', b: '.' }); - assert.deepStrictEqual(yaml.load('a: >+\n\nb: .'), { a: '\n', b: '.' }); - assert.deepStrictEqual(yaml.load('a: >-\n\nb: .'), { a: '', b: '.' }); -}); diff --git a/test/issues/0108.js b/test/issues/0108.js deleted file mode 100644 index 56e85260..00000000 --- a/test/issues/0108.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Literal scalars have an unwanted leading line break', function () { - assert.strictEqual(yaml.load('|\n foobar\n'), 'foobar\n'); - assert.strictEqual(yaml.load('|\n hello\n world\n'), 'hello\nworld\n'); - assert.strictEqual(yaml.load('|\n war never changes\n'), 'war never changes\n'); -}); diff --git a/test/issues/0110.js b/test/issues/0110.js deleted file mode 100644 index 9710b4a9..00000000 --- a/test/issues/0110.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Circular and cross references', function () { - var source = { - a: { a: 1 }, - b: [ 1, 2 ], - c: {}, - d: [] - }; - source.crossObject = source.a; - source.crossArray = source.b; - source.c.circularObject = source; - source.d.push(source.d); - source.d.push(source); - - var obtained = yaml.load(yaml.dump(source)); - - assert.strictEqual(obtained.crossObject, obtained.a); - assert.strictEqual(obtained.crossArray, obtained.b); - assert.strictEqual(obtained.c.circularObject, obtained); - assert.strictEqual(obtained.d[0], obtained.d); - assert.strictEqual(obtained.d[1], obtained); -}); diff --git a/test/issues/0112.js b/test/issues/0112.js deleted file mode 100644 index 1195e533..00000000 --- a/test/issues/0112.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Plain scalar "constructor" parsed as `null`', function () { - assert.strictEqual(yaml.load('constructor'), 'constructor'); - assert.deepStrictEqual(yaml.load('constructor: value'), { constructor: 'value' }); - assert.deepStrictEqual(yaml.load('key: constructor'), { key: 'constructor' }); - assert.deepStrictEqual(yaml.load('{ constructor: value }'), { constructor: 'value' }); - assert.deepStrictEqual(yaml.load('{ key: constructor }'), { key: 'constructor' }); -}); diff --git a/test/issues/0117.js b/test/issues/0117.js deleted file mode 100644 index d3196ee8..00000000 --- a/test/issues/0117.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Negative zero loses the sign after dump', function () { - assert.strictEqual(yaml.dump(-0), '-0.0\n'); -}); diff --git a/test/issues/0144.js b/test/issues/0144.js deleted file mode 100644 index 4abfb6a9..00000000 --- a/test/issues/0144.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Infinite loop when attempting to parse multi-line scalar document that is not indented', function () { - assert.strictEqual(yaml.load('--- |\nfoo\n'), 'foo\n'); -}); diff --git a/test/issues/0155.js b/test/issues/0155.js deleted file mode 100644 index d6125d1d..00000000 --- a/test/issues/0155.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Named null', function () { - assert.deepStrictEqual(yaml.load('---\ntest: !!null \nfoo: bar'), { test: null, foo: 'bar' }); -}); diff --git a/test/issues/0156.js b/test/issues/0156.js deleted file mode 100644 index 0cf33dfa..00000000 --- a/test/issues/0156.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -function SuccessSignal() {} - -var TestClassYaml = new yaml.Type('!test', { - kind: 'scalar', - resolve: function () { throw new SuccessSignal(); } -}); - -var TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([ TestClassYaml ]); - - -it('Resolving of empty nodes are skipped in some cases', function () { - assert.throws(function () { yaml.load('- foo: !test\n- bar: baz', { schema: TEST_SCHEMA }); }, SuccessSignal); -}); diff --git a/test/issues/0160.js b/test/issues/0160.js deleted file mode 100644 index 6e83c33c..00000000 --- a/test/issues/0160.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Correct encoding of UTF-16 surrogate pairs', function () { - assert.strictEqual(yaml.load('"\\U0001F431"'), '🐱'); -}); diff --git a/test/issues/0194.js b/test/issues/0194.js deleted file mode 100644 index 7c433b24..00000000 --- a/test/issues/0194.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Don\'t throw on warning', function () { - var src = ` -foo: { - bar: true -} -`; - var warnings = [], - data; - - data = yaml.load(src); - - assert.deepStrictEqual(data, { foo: { bar: true } }); - - yaml.load(src, { onWarning: function (e) { warnings.push(e); } }); - - assert.strictEqual(warnings.length, 1); -}); diff --git a/test/issues/0203.js b/test/issues/0203.js deleted file mode 100644 index e3a54c34..00000000 --- a/test/issues/0203.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Don\'t throw on warning', function () { - var src = ` -test: |- - - - Hello - world -`; - - assert.deepStrictEqual(yaml.load(src), { test: '\n\nHello\nworld' }); -}); diff --git a/test/issues/0205.js b/test/issues/0205.js deleted file mode 100644 index 67f12e42..00000000 --- a/test/issues/0205.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Duplicated objects within array', function () { - var obj = { test: 'canary' }; - var arrayWithRefs = [ obj, obj ]; - - var obtained = yaml.load(yaml.dump(arrayWithRefs)); - - assert.strictEqual(obtained[0].test, 'canary'); - assert.strictEqual(obtained[0], obtained[1]); -}); - -it('Duplicated arrays within array', function () { - var array = [ 0, 1 ]; - var arrayWithRefs = [ array, array ]; - - var obtained = yaml.load(yaml.dump(arrayWithRefs)); - - assert.strictEqual(obtained[0][0], 0); - assert.strictEqual(obtained[0][1], 1); - assert.strictEqual(obtained[0], obtained[1]); -}); diff --git a/test/issues/0220.js b/test/issues/0220.js deleted file mode 100644 index edeec370..00000000 --- a/test/issues/0220.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Float type dumper should not miss dot', function () { - assert.strictEqual(5e-100.toString(10), '5e-100'); - assert.strictEqual(0.5e-100.toString(10), '5e-101'); - - assert.strictEqual(yaml.dump(0.5e-100), '5.e-101\n'); - assert.strictEqual(yaml.load(yaml.dump(5e-100)), 5e-100); -}); diff --git a/test/issues/0221.js b/test/issues/0221.js deleted file mode 100644 index 5cc81a12..00000000 --- a/test/issues/0221.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it.skip('Block scalar chomping does not work on zero indent', function () { - assert.throws(function () { yaml.load('|-\nfoo\nbar'); }, yaml.YAMLException); - assert.deepStrictEqual(yaml.dump('foo\nbar'), '|-\n foo\nbar'); -}); diff --git a/test/issues/0243.js b/test/issues/0243.js deleted file mode 100644 index 5795a225..00000000 --- a/test/issues/0243.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); -var readFileSync = require('fs').readFileSync; - - -describe('Duplicated mapping key errors throw at beginning of key', function () { - it('on top level', function () { - var src = readFileSync(require('path').join(__dirname, '/0243-basic.yml'), 'utf8'); - var lines = src.split('\n'); - - try { - yaml.load(src); - } catch (e) { - assert.strictEqual(lines[e.mark.line], 'duplicate: # 2'); - assert.strictEqual(e.mark.line, 9); - assert.strictEqual(e.mark.column, 0); - } - }); - - it('inside of mapping values', function () { - var src = readFileSync(require('path').join(__dirname, '/0243-nested.yml'), 'utf8'); - var lines = src.split('\n'); - - try { - yaml.load(src); - } catch (e) { - assert.strictEqual(lines[e.mark.line], ' duplicate: # 2'); - assert.strictEqual(e.mark.line, 9); - assert.strictEqual(e.mark.column, 2); - } - }); - - it('inside flow collection', function () { - try { - yaml.load('{ foo: 123, foo: 456 }'); - } catch (e) { - assert.strictEqual(e.mark.line, 0); - assert.strictEqual(e.mark.column, 12); - } - }); - - it('inside a set', function () { - try { - yaml.load(' ? foo\n ? foo\n ? bar'); - } catch (e) { - assert.strictEqual(e.mark.line, 1); - assert.strictEqual(e.mark.column, 4); - } - }); -}); diff --git a/test/issues/0248-listener.js b/test/issues/0248-listener.js deleted file mode 100644 index 88756043..00000000 --- a/test/issues/0248-listener.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var yaml = require('../../'); - -it('Listener informed on a very simple scalar.', function () { - var history = []; - function l(eventType, state) { - history.push([ eventType, state.position ]); - } - - yaml.load('a_simple_scalar', { listener: l }); - - // 2 open events then 2 close events - assert.strictEqual(history.length, 4); - assert.strictEqual(history[0][0], 'open'); - assert.strictEqual(history[1][0], 'open'); - assert.strictEqual(history[2][0], 'close'); - assert.strictEqual(history[3][0], 'close'); - assert.strictEqual(history[0][1], 0); - assert.strictEqual(history[3][1], 16); -}); - -it('Listener informed on a map with a list.', function () { - var history = []; - function l(eventType, state) { - history.push([ eventType, state.position, state.result ]); - } - - yaml.load('{ a: 1, b: [ 0, xyz ] }', { listener: l }); - - var i = -1; - assert.strictEqual(history[++i][0], 'open'); // doc - assert.strictEqual(history[++i][0], 'open'); // map - - assert.strictEqual(history[++i][0], 'open'); // key - assert.strictEqual(history[++i][0], 'close'); - assert.strictEqual(history[i][2], 'a'); - - assert.strictEqual(history[++i][0], 'open'); // a value - assert.strictEqual(history[++i][0], 'close'); - assert.strictEqual(history[i][2], 1); - - assert.strictEqual(history[++i][0], 'open'); // key - assert.strictEqual(history[++i][0], 'close'); - assert.strictEqual(history[i][2], 'b'); - - assert.strictEqual(history[++i][0], 'open'); // b value (list) - assert.strictEqual(history[++i][0], 'open'); // item in list - assert.strictEqual(history[++i][0], 'close'); - assert.strictEqual(history[i][2], 0); - assert.strictEqual(history[++i][0], 'open'); // item in list - assert.strictEqual(history[++i][0], 'close'); - - assert.strictEqual(history[++i][0], 'close'); // b value (list) end - assert.deepStrictEqual(history[i][2], [ 0, 'xyz' ]); - - assert.strictEqual(history[++i][0], 'close'); // map end - assert.strictEqual(history[++i][0], 'close'); // doc end - - assert.strictEqual(history.length, ++i); -}); diff --git a/test/issues/0258.js b/test/issues/0258.js deleted file mode 100644 index ef89d880..00000000 --- a/test/issues/0258.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - - -const assert = require('assert'); -const yaml = require('../../'); - - -it('should shorthand tags with !! whenever possible', function () { - let regexp = new yaml.Type('tag:yaml.org,2002:js/regexp', { - kind: 'scalar', - resolve: () => true, - construct: str => new RegExp(str), - instanceOf: RegExp, - represent: object => object.source - }); - - let schema = yaml.DEFAULT_SCHEMA.extend(regexp); - - let source = 're: !!js/regexp .*\n'; - - let object = yaml.load(source, { schema }); - assert(object.re instanceof RegExp); - - let str = yaml.dump(object, { schema }); - assert.strictEqual(str, source); -}); diff --git a/test/issues/0303.js b/test/issues/0303.js deleted file mode 100644 index ab78e433..00000000 --- a/test/issues/0303.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var yaml = require('../../'); - -it('Loader should not strip quotes before newlines', function () { - var with_space = yaml.load("'''foo'' '"); - var with_newline = yaml.load("'''foo''\n'"); - assert.strictEqual(with_space, "'foo' "); - assert.strictEqual(with_newline, "'foo' "); -}); diff --git a/test/issues/0321.js b/test/issues/0321.js deleted file mode 100644 index 4f00e106..00000000 --- a/test/issues/0321.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - - -const assert = require('assert'); -const yaml = require('../../'); - - -it('Should throw exception on extra comma in flow mappings', function () { - assert.throws(function () { - yaml.load('[foo, bar,, baz]'); - }, /expected the node content, but found ','/); - - assert.throws(function () { - yaml.load('{foo, bar,, baz}'); - }, /expected the node content, but found ','/); - - // empty key is allowed here - assert.deepStrictEqual(yaml.load('{foo,: bar}'), { foo: null, null: 'bar' }); -}); diff --git a/test/issues/0346.js b/test/issues/0346.js deleted file mode 100644 index 359b3fea..00000000 --- a/test/issues/0346.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var yaml = require('../../'); - - -it('should not emit spaces in arrays in flow mode between entries using condenseFlow: true', function () { - var array = [ 'a', 'b' ]; - var dumpedArray = yaml.dump(array, { flowLevel: 0, indent: 0, condenseFlow: true }); - assert.strictEqual( - dumpedArray, - '[a,b]\n' - ); - assert.deepStrictEqual(yaml.load(dumpedArray), array); -}); - -it('should not emit spaces between key: value and quote keys using condenseFlow: true', function () { - var object = { a: { b: 'c', d: 'e' } }; - var objectDump = yaml.dump(object, { flowLevel: 0, indent: 0, condenseFlow: true }); - assert.strictEqual( - objectDump, - '{"a":{"b":c, "d":e}}\n' - ); - assert.deepStrictEqual(yaml.load(objectDump), object); -}); diff --git a/test/issues/0350.js b/test/issues/0350.js deleted file mode 100644 index 5860fcac..00000000 --- a/test/issues/0350.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('should return parse docs from loadAll', function () { - var data = yaml.loadAll(` ---- -a: 1 ---- -b: 2 -`); - - assert.deepStrictEqual(data, [ { a: 1 }, { b: 2 } ]); -}); diff --git a/test/issues/0399.js b/test/issues/0399.js deleted file mode 100644 index cd5d96f5..00000000 --- a/test/issues/0399.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('should properly dump negative ints in different styles', function () { - var dump, src = { integer: -100 }; - - dump = yaml.dump(src, { styles: { '!!int': 'binary' } }); - assert.deepStrictEqual(yaml.load(dump), src); - - dump = yaml.dump(src, { styles: { '!!int': 'octal' } }); - assert.deepStrictEqual(yaml.load(dump), src); - - dump = yaml.dump(src, { styles: { '!!int': 'hex' } }); - assert.deepStrictEqual(yaml.load(dump), src); -}); diff --git a/test/issues/0403.js b/test/issues/0403.js deleted file mode 100644 index e63dad5a..00000000 --- a/test/issues/0403.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('should properly dump leading newlines and spaces', function () { - var dump, src; - - src = { str: '\n a\nb' }; - dump = yaml.dump(src); - assert.deepStrictEqual(yaml.load(dump), src); - - src = { str: '\n\n a\nb' }; - dump = yaml.dump(src); - assert.deepStrictEqual(yaml.load(dump), src); - - src = { str: '\n a\nb' }; - dump = yaml.dump(src, { indent: 10 }); - assert.deepStrictEqual(yaml.load(dump), src); -}); diff --git a/test/issues/0418.js b/test/issues/0418.js deleted file mode 100644 index 94754dcf..00000000 --- a/test/issues/0418.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - - -const assert = require('assert'); -const yaml = require('../../'); - - -it('should error on invalid indentation in mappings', function () { - assert.throws(() => yaml.load('foo: "1" bar: "2"'), /bad indentation of a mapping entry/); - assert.throws(() => yaml.load('- "foo" - "bar"'), /bad indentation of a sequence entry/); -}); diff --git a/test/issues/0432.js b/test/issues/0432.js deleted file mode 100644 index 940c6b96..00000000 --- a/test/issues/0432.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('should indent arrays an extra level by default', function () { - var output = yaml.dump({ array: [ 'a', 'b' ] }); - var expected = 'array:\n - a\n - b\n'; - assert.strictEqual(output, expected); -}); - -it('should not indent arrays an extra level when disabled', function () { - var output = yaml.dump({ array: [ 'a', 'b' ] }, { noArrayIndent: true }); - var expected = 'array:\n- a\n- b\n'; - assert.strictEqual(output, expected); -}); - -it('should always indent nested arrays', function () { - var output = yaml.dump({ array: [ 'a', [ 'b', 'c' ], 'd' ] }, { noArrayIndent: true }); - var expected = 'array:\n- a\n- - b\n - c\n- d\n'; - assert.strictEqual(output, expected); -}); diff --git a/test/issues/0519.js b/test/issues/0519.js deleted file mode 100644 index 38664018..00000000 --- a/test/issues/0519.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var yaml = require('../../'); - -it('Dumper should add quotes around equals sign', function () { - // pyyaml fails with unquoted `=` - // https://yaml-online-parser.appspot.com/?yaml=%3D%0A&type=json - assert.strictEqual(yaml.load(yaml.dump('=')), '='); - assert.strictEqual(yaml.dump('='), "'='\n"); -}); diff --git a/test/issues/0525-1.js b/test/issues/0525-1.js deleted file mode 100644 index 05c1bca4..00000000 --- a/test/issues/0525-1.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Should throw if there is a null-byte in input', function () { - try { - yaml.load('foo\0bar'); - } catch (err) { - assert(err.stack.startsWith('YAMLException: null byte is not allowed in input')); - return; - } - assert.fail(null, null, 'Expected an error to be thrown'); -}); diff --git a/test/issues/0525-2.js b/test/issues/0525-2.js deleted file mode 100644 index 92885c4b..00000000 --- a/test/issues/0525-2.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Should check kind type when resolving ! tag', function () { - try { - yaml.load('! [0]'); - } catch (err) { - assert(err.stack.startsWith('YAMLException: unacceptable node kind for ! tag')); - return; - } - assert.fail(null, null, 'Expected an error to be thrown'); -}); diff --git a/test/issues/0570.js b/test/issues/0570.js deleted file mode 100644 index 86c45125..00000000 --- a/test/issues/0570.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - - -const assert = require('assert'); -const yaml = require('../../'); - - -it('should dump null in different styles', function () { - let dump, src = { foo: null, bar: 1 }; - - let tests = { - lowercase: 'null', - uppercase: 'NULL', - camelcase: 'Null', - canonical: '~', - empty: '' - }; - - for (let [ name, value ] of Object.entries(tests)) { - dump = yaml.dump(src, { styles: { '!!null': name } }); - assert.strictEqual(dump, 'foo: ' + value + '\nbar: 1\n'); - assert.deepStrictEqual(yaml.load(dump), src); - } -}); diff --git a/test/issues/0586.js b/test/issues/0586.js deleted file mode 100644 index 5160f53b..00000000 --- a/test/issues/0586.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -/* eslint-disable no-use-before-define, new-cap */ - - -const assert = require('assert'); -const yaml = require('../../'); - - -it('Should allow custom formatting through implicit custom tags', function () { - function CustomDump(data, opts) { - if (!(this instanceof CustomDump)) return new CustomDump(data, opts); - this.data = data; - this.opts = opts; - } - - CustomDump.prototype.represent = function () { - let result = yaml.dump(this.data, Object.assign({ replacer, schema }, this.opts)); - result = result.trim(); - if (result.includes('\n')) result = '\n' + result; - return result; - }; - - - let CustomDumpType = new yaml.Type('!format', { - kind: 'scalar', - resolve: () => false, - instanceOf: CustomDump, - represent: d => d.represent() - }); - - - let schema = yaml.DEFAULT_SCHEMA.extend({ implicit: [ CustomDumpType ] }); - - function replacer(key, value) { - if (key === '') return value; // top-level, don't change this - if (key === 'flow_choices') return CustomDump(value, { flowLevel: 0 }); - if (key === 'block_choices') return CustomDump(value, { flowLevel: Infinity }); - return value; // default - } - - let result = CustomDump({ flow_choices : [ 1, 2 ], block_choices: [ 4, 5 ] }).represent().trim(); - - assert.strictEqual(result, ` -flow_choices: [1, 2] -block_choices: -- 4 -- 5`.replace(/^\n/, '')); -}); diff --git a/test/issues/0587.js b/test/issues/0587.js deleted file mode 100644 index 921e852a..00000000 --- a/test/issues/0587.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Should not encode astral characters', function () { - assert.strictEqual(yaml.dump('😃😊'), '😃😊\n'); -}); diff --git a/test/issues/0614.js b/test/issues/0614.js deleted file mode 100644 index 18d9e119..00000000 --- a/test/issues/0614.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -/* global BigInt */ - - -const assert = require('assert'); -const yaml = require('../../'); - - -it('Should allow int override', function () { - let options = Object.assign({}, yaml.types.int.options); - - options.construct = data => { - let value = data, sign = 1n, ch; - - if (value.indexOf('_') !== -1) { - value = value.replace(/_/g, ''); - } - - ch = value[0]; - - if (ch === '-' || ch === '+') { - if (ch === '-') sign = -1n; - value = value.slice(1); - ch = value[0]; - } - - return sign * BigInt(value); - }; - - - let BigIntType = new yaml.Type('tag:yaml.org,2002:int', options); - - const SCHEMA = yaml.DEFAULT_SCHEMA.extend({ implicit: [ BigIntType ] }); - - const data = ` -int: -123_456_789 -bigint: -12_345_678_901_234_567_890 -float: -12_345_678_901_234_567_890.1234 -`; - - assert.deepStrictEqual(yaml.load(data, { schema: SCHEMA }), { - int: -123456789n, - bigint: -12345678901234567890n, - float: -12345678901234567000 // precision loss expected - }); -}); diff --git a/test/samples-common/construct-bool.js b/test/samples-common/construct-bool.js deleted file mode 100644 index a2e7ba57..00000000 --- a/test/samples-common/construct-bool.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = { - valid_true: [ true, true, true ], - valid_false: [ false, false, false ], - deprecated_true: [ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON' ], - deprecated_false: [ 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' ] -}; diff --git a/test/samples-common/construct-custom.js b/test/samples-common/construct-custom.js deleted file mode 100644 index a2b8768f..00000000 --- a/test/samples-common/construct-custom.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var schema = require('../support/schema'); - -var expected = [ - new schema.Tag1({ x: 1 }), - new schema.Tag1({ x: 1, y: 2, z: 3 }), - new schema.Tag2({ x: 10 }), - new schema.Tag3({ x: 1 }), - new schema.Tag3({ x: 1, y: 2, z: 3 }), - new schema.Tag3({ x: 1, y: 2, z: 3 }), - new schema.Foo({ myParameter: 'foo', myAnotherParameter: [ 1, 2, 3 ] }) -]; - -function testHandler(actual) { - assert.strictEqual(Object.prototype.toString.call(actual), '[object Array]'); - assert.strictEqual(actual.length, 7); - - assert.deepStrictEqual(actual[0], expected[0]); - assert.strictEqual(Object.getPrototypeOf(actual[0]), Object.getPrototypeOf(expected[0])); - - assert.deepStrictEqual(actual[1], expected[1]); - assert.strictEqual(Object.getPrototypeOf(actual[1]), Object.getPrototypeOf(expected[1])); - - assert.deepStrictEqual(actual[2], expected[2]); - assert.strictEqual(Object.getPrototypeOf(actual[2]), Object.getPrototypeOf(expected[2])); - - assert.deepStrictEqual(actual[3], expected[3]); - assert.strictEqual(Object.getPrototypeOf(actual[3]), Object.getPrototypeOf(expected[3])); - - assert.deepStrictEqual(actual[4], expected[4]); - assert.strictEqual(Object.getPrototypeOf(actual[4]), Object.getPrototypeOf(expected[4])); - - assert.deepStrictEqual(actual[5], expected[5]); - assert.strictEqual(Object.getPrototypeOf(actual[5]), Object.getPrototypeOf(expected[5])); - - assert.deepStrictEqual(actual[6], expected[6]); - assert.strictEqual(Object.getPrototypeOf(actual[6]), Object.getPrototypeOf(expected[6])); -} - -testHandler.expected = expected; - -module.exports = testHandler; diff --git a/test/samples-common/construct-float.js b/test/samples-common/construct-float.js deleted file mode 100644 index ec76008b..00000000 --- a/test/samples-common/construct-float.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -var assert = require('assert'); - -var expected = { - canonical: 685230.15, - exponential: 685230.15, - fixed: 685230.15, - 'negative infinity': Number.NEGATIVE_INFINITY, - 'not a number': NaN -}; - -function testHandler(actual) { - assert.strictEqual(Object.prototype.toString.call(actual), '[object Object]'); - assert.strictEqual(Object.keys(actual).sort().join(','), Object.keys(expected).sort().join(',')); - - assert.strictEqual(actual['canonical'], expected['canonical']); - assert.strictEqual(actual['exponential'], expected['exponential']); - assert.strictEqual(actual['fixed'], expected['fixed']); - assert.strictEqual(actual['negative infinity'], expected['negative infinity']); - - assert(Number.isNaN(actual['not a number'])); -} - -testHandler.expected = expected; - -module.exports = testHandler; diff --git a/test/samples-common/construct-pairs.js b/test/samples-common/construct-pairs.js deleted file mode 100644 index 595a56c4..00000000 --- a/test/samples-common/construct-pairs.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = { - 'Block tasks': [ - [ 'meeting', 'with team.' ], - [ 'meeting', 'with boss.' ], - [ 'break', 'lunch.' ], - [ 'meeting', 'with client.' ] - ], - 'Flow tasks': [ - [ 'meeting', 'with team' ], - [ 'meeting', 'with boss' ] - ] -}; diff --git a/test/samples-common/construct-str-ascii.js b/test/samples-common/construct-str-ascii.js deleted file mode 100644 index ddb434d0..00000000 --- a/test/samples-common/construct-str-ascii.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = 'ascii string'; diff --git a/test/samples-common/emitting-unacceptable-unicode-character-bug.js b/test/samples-common/emitting-unacceptable-unicode-character-bug.js deleted file mode 100644 index 7d5d677f..00000000 --- a/test/samples-common/emitting-unacceptable-unicode-character-bug.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = '\udd00'; diff --git a/test/samples-common/more-floats.js b/test/samples-common/more-floats.js deleted file mode 100644 index abc24829..00000000 --- a/test/samples-common/more-floats.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -var assert = require('assert'); - -var expected = [ - 0.0, - 1.0, - -1.0, - Number.POSITIVE_INFINITY, - Number.NEGATIVE_INFINITY, - NaN, - NaN -]; - -function testHandler(actual) { - assert.strictEqual(Object.prototype.toString.call(actual), '[object Array]'); - assert.strictEqual(actual.length, 7); - assert.strictEqual(actual[0], expected[0]); - assert.strictEqual(actual[1], expected[1]); - assert.strictEqual(actual[2], expected[2]); - assert.strictEqual(actual[3], expected[3]); - assert.strictEqual(actual[4], expected[4]); - assert(Number.isNaN(actual[5])); - assert(Number.isNaN(actual[6])); -} - -testHandler.expected = expected; - -module.exports = testHandler; diff --git a/test/samples-common/negative-float-bug.js b/test/samples-common/negative-float-bug.js deleted file mode 100644 index b80bdcd8..00000000 --- a/test/samples-common/negative-float-bug.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = -1.0; diff --git a/test/samples-common/single-dot-is-not-float-bug.js b/test/samples-common/single-dot-is-not-float-bug.js deleted file mode 100644 index 980beaa2..00000000 --- a/test/samples-common/single-dot-is-not-float-bug.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = '.'; diff --git a/test/samples-common/utf8-implicit.js b/test/samples-common/utf8-implicit.js deleted file mode 100644 index 975571c1..00000000 --- a/test/samples-common/utf8-implicit.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = 'implicit UTF-8'; diff --git a/test/samples-load-errors/duplicate-key.js b/test/samples-load-errors/duplicate-key.js deleted file mode 100644 index f66c52c8..00000000 --- a/test/samples-load-errors/duplicate-key.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = { foo: 'baz' }; diff --git a/test/samples-load-errors/duplicate-value-key.js b/test/samples-load-errors/duplicate-value-key.js deleted file mode 100644 index 98882f20..00000000 --- a/test/samples-load-errors/duplicate-value-key.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = { foo: 'bar', '=': 2 }; diff --git a/test/units/alias-nodes.js b/test/units/alias-nodes.js deleted file mode 100644 index 44bc527c..00000000 --- a/test/units/alias-nodes.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -function TestClass(data) { - var self = this; - Object.keys(data).forEach(function (key) { self[key] = data[key]; }); -} - -var TestClassYaml = new yaml.Type('!test', { - kind: 'mapping', - construct: function (data) { return new TestClass(data); } -}); - -var TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([ TestClassYaml ]); - - -describe('Alias nodes', function () { - /* eslint-disable max-len */ - describe('Resolving of an alias node should result the resolved and contructed value of the anchored node', function () { - it('Simple built-in primitives', function () { - assert.strictEqual(yaml.load('[&1 "foobar", *1]')[1], 'foobar'); - assert.strictEqual(yaml.load('[&1 ~, *1]')[1], null); - assert.strictEqual(yaml.load('[&1 true, *1]')[1], true); - assert.strictEqual(yaml.load('[&1 42, *1]')[1], 42); - }); - - it('Simple built-in objects', function () { - assert.deepStrictEqual(yaml.load('[&1 [a, b, c, d], *1]')[1], [ 'a', 'b', 'c', 'd' ]); - assert.deepStrictEqual(yaml.load('[&1 {a: b, c: d}, *1]')[1], { a: 'b', c: 'd' }); - }); - - it('Recursive built-in objects', function () { - var actual = yaml.load('[&1 {self: *1}, *1]')[1]; - - assert(actual === actual.self); - }); - - it('Simple custom objects', function () { - var expected = new TestClass({ a: 'b', c: 'd' }), - actual = yaml.load('[&1 !test {a: b, c: d}, *1]', { schema: TEST_SCHEMA })[1]; - - assert(actual instanceof TestClass); - assert.deepStrictEqual(actual, expected); - }); - - // TODO: Not implemented yet (see issue #141) - it.skip('Recursive custom objects', function () { - var actual = yaml.load('[&1 !test {self: *1}, *1]', { schema: TEST_SCHEMA })[1]; - - assert(actual instanceof TestClass); - assert(actual.self instanceof TestClass); - assert(actual === actual.self); - }); - }); -}); diff --git a/test/units/character-set.js b/test/units/character-set.js deleted file mode 100644 index d529a512..00000000 --- a/test/units/character-set.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Allow astral characters', function () { - assert.deepStrictEqual(yaml.load('𝑘𝑒𝑦: 𝑣𝑎𝑙𝑢𝑒'), { '𝑘𝑒𝑦': '𝑣𝑎𝑙𝑢𝑒' }); -}); - -it('Forbid non-printable characters', function () { - assert.throws(function () { yaml.load('\x01'); }, yaml.YAMLException); - assert.throws(function () { yaml.load('\x7f'); }, yaml.YAMLException); - assert.throws(function () { yaml.load('\x9f'); }, yaml.YAMLException); -}); - -it('Forbid lone surrogates', function () { - assert.throws(function () { yaml.load('\udc00\ud800'); }, yaml.YAMLException); -}); - -it('Allow non-printable characters inside quoted scalars', function () { - assert.strictEqual(yaml.load('"\x7f\x9f\udc00\ud800"'), '\x7f\x9f\udc00\ud800'); -}); - -it('Forbid control sequences inside quoted scalars', function () { - assert.throws(function () { yaml.load('"\x03"'); }, yaml.YAMLException); -}); diff --git a/test/units/empty-node-resolving.js b/test/units/empty-node-resolving.js deleted file mode 100644 index eebc0766..00000000 --- a/test/units/empty-node-resolving.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -describe('Resolving explicit tags on empty nodes', function () { - it('!!binary', function () { - assert.throws(function () { yaml.load('!!binary'); }, yaml.YAMLException); - }); - - it('!!bool', function () { - assert.throws(function () { yaml.load('!!bool'); }, yaml.YAMLException); - }); - - it('!!float', function () { - assert.throws(function () { yaml.load('!!float'); }, yaml.YAMLException); - }); - - it('!!int', function () { - assert.throws(function () { yaml.load('!!int'); }, yaml.YAMLException); - }); - - it('!!map', function () { - assert.deepStrictEqual(yaml.load('!!map'), {}); - }); - - it('!!merge', function () { - assert.doesNotThrow(function () { yaml.load('? !!merge\n: []'); }); - }); - - it('!!null', function () { - // Fetch null from an array to reduce chance that null is returned because of another bug - assert.strictEqual(yaml.load('- !!null')[0], null); - }); - - it('!!omap', function () { - assert.deepStrictEqual(yaml.load('!!omap'), []); - }); - - it('!!pairs', function () { - assert.deepStrictEqual(yaml.load('!!pairs'), []); - }); - - it('!!seq', function () { - assert.deepStrictEqual(yaml.load('!!seq'), []); - }); - - it('!!set', function () { - assert.deepStrictEqual(yaml.load('!!set'), {}); - }); - - it('!!str', function () { - assert.strictEqual(yaml.load('!!str'), ''); - }); - - it('!!timestamp', function () { - assert.throws(function () { yaml.load('!!timestamp'); }, yaml.YAMLException); - }); -}); diff --git a/test/units/is-negative-zero.js b/test/units/is-negative-zero.js deleted file mode 100644 index acf0a914..00000000 --- a/test/units/is-negative-zero.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -var assert = require('assert'); - -var isNegativeZero = require('../../lib/common').isNegativeZero; - - -it('isNegativeZero', function () { - assert(!isNegativeZero(0)); - assert(!isNegativeZero(0.0)); - assert(isNegativeZero(-0)); - assert(isNegativeZero(-0.0)); -}); diff --git a/test/units/loader-parameters.js b/test/units/loader-parameters.js deleted file mode 100644 index 96946210..00000000 --- a/test/units/loader-parameters.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var yaml = require('../..'); - -describe('loader parameters', function () { - var testStr = 'test: 1 \ntest: 2'; - var expected = [ { test: 2 } ]; - var result; - - it('loadAll(input, options)', function () { - result = yaml.loadAll(testStr, { json: true }); - assert.deepStrictEqual(result, expected); - - result = []; - yaml.loadAll(testStr, function (doc) { - result.push(doc); - }, { json: true }); - assert.deepStrictEqual(result, expected); - }); - - it('loadAll(input, null, options)', function () { - result = yaml.loadAll(testStr, null, { json: true }); - assert.deepStrictEqual(result, expected); - - result = []; - yaml.loadAll(testStr, function (doc) { - result.push(doc); - }, { json: true }); - assert.deepStrictEqual(result, expected); - }); - - it('loadAll(input, options)', function () { - result = yaml.loadAll(testStr, { json: true }); - assert.deepStrictEqual(result, expected); - - result = []; - yaml.loadAll(testStr, function (doc) { - result.push(doc); - }, { json: true }); - assert.deepStrictEqual(result, expected); - }); - - it('loadAll(input, null, options)', function () { - result = yaml.loadAll(testStr, null, { json: true }); - assert.deepStrictEqual(result, expected); - - result = []; - yaml.loadAll(testStr, function (doc) { - result.push(doc); - }, { json: true }); - assert.deepStrictEqual(result, expected); - }); -}); diff --git a/test/units/replacer.js b/test/units/replacer.js deleted file mode 100644 index 81072d5e..00000000 --- a/test/units/replacer.js +++ /dev/null @@ -1,183 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const yaml = require('../..'); - - -describe('replacer', function () { - let undef = new yaml.Type('!undefined', { - kind: 'scalar', - resolve: () => true, - construct: () => {}, - predicate: object => typeof object === 'undefined', - represent: () => '' - }); - - let undef_schema = yaml.DEFAULT_SCHEMA.extend(undef); - - - it('should be called on the root of the document', function () { - let called = 0; - - let result = yaml.dump(42, { - replacer(key, value) { - called++; - assert.deepStrictEqual(this, { '': 42 }); - assert.strictEqual(key, ''); - assert.strictEqual(value, 42); - return 123; - } - }); - assert.strictEqual(result, '123\n'); - assert.strictEqual(called, 1); - - assert.strictEqual(yaml.dump(42, { - replacer(/* key, value */) {} - }), ''); - - assert.strictEqual(yaml.dump(42, { - replacer(/* key, value */) { return 'foo'; } - }), 'foo\n'); - }); - - - it('should be called in collections (block)', function () { - let called = 0; - - let result = yaml.dump([ 42 ], { - replacer(key, value) { - called++; - if (key === '' && called === 1) return value; - assert.deepStrictEqual(this, [ 42 ]); - assert.strictEqual(key, '0'); - assert.strictEqual(value, 42); - return 123; - }, - flowLevel: -1 - }); - assert.strictEqual(result, '- 123\n'); - assert.strictEqual(called, 2); - }); - - - it('should be called in collections (flow)', function () { - let called = 0; - - let result = yaml.dump([ 42 ], { - replacer(key, value) { - called++; - if (key === '' && called === 1) return value; - assert.deepStrictEqual(this, [ 42 ]); - assert.strictEqual(key, '0'); - assert.strictEqual(value, 42); - return 123; - }, - flowLevel: 0 - }); - assert.strictEqual(result, '[123]\n'); - assert.strictEqual(called, 2); - }); - - - it('should be called in mappings (block)', function () { - let called = 0; - - let result = yaml.dump({ a: 42 }, { - replacer(key, value) { - called++; - if (key === '' && called === 1) return value; - assert.deepStrictEqual(this, { a: 42 }); - assert.strictEqual(key, 'a'); - assert.strictEqual(value, 42); - return 123; - }, - flowLevel: -1 - }); - assert.strictEqual(result, 'a: 123\n'); - assert.strictEqual(called, 2); - }); - - - it('should be called in mappings (flow)', function () { - let called = 0; - - let result = yaml.dump({ a: 42 }, { - replacer(key, value) { - called++; - if (key === '' && called === 1) return value; - assert.deepStrictEqual(this, { a: 42 }); - assert.strictEqual(key, 'a'); - assert.strictEqual(value, 42); - return 123; - }, - flowLevel: 0 - }); - assert.strictEqual(result, '{a: 123}\n'); - assert.strictEqual(called, 2); - }); - - - it('undefined removes element from a mapping', function () { - let str, result; - - str = yaml.dump({ a: 1, b: 2, c: 3 }, { - replacer(key, value) { - if (key === 'b') return undefined; - return value; - } - }); - result = yaml.load(str); - assert.deepStrictEqual(result, { a: 1, c: 3 }); - - str = yaml.dump({ a: 1, b: 2, c: 3 }, { - replacer(key, value) { - if (key === 'b') return undefined; - return value; - }, - schema: undef_schema - }); - result = yaml.load(str, { schema: undef_schema }); - assert.deepStrictEqual(result, { a: 1, b: undefined, c: 3 }); - }); - - - it('undefined replaces element in an array with null', function () { - let str, result; - - str = yaml.dump([ 1, 2, 3 ], { - replacer(key, value) { - if (key === '1') return undefined; - return value; - } - }); - result = yaml.load(str); - assert.deepStrictEqual(result, [ 1, null, 3 ]); - - str = yaml.dump([ 1, 2, 3 ], { - replacer(key, value) { - if (key === '1') return undefined; - return value; - }, - schema: undef_schema - }); - result = yaml.load(str, { schema: undef_schema }); - assert.deepStrictEqual(result, [ 1, undefined, 3 ]); - }); - - - it('should recursively call replacer', function () { - let count = 0; - - let result = yaml.dump(42, { - replacer(key, value) { - return count++ > 3 ? value : { ['lvl' + count]: value }; - } - }); - assert.strictEqual(result, ` -lvl1: - lvl2: - lvl3: - lvl4: 42 -`.replace(/^\n/, '')); - }); -}); diff --git a/test/units/single-document-error.js b/test/units/single-document-error.js deleted file mode 100644 index 1ae8b141..00000000 --- a/test/units/single-document-error.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var yaml = require('../../'); - - -it('Loading multidocument source using `load` should cause an error', function () { - assert.throws(function () { - yaml.load('--- # first document\n--- # second document\n'); - }, yaml.YAMLException); - - assert.throws(function () { - yaml.load('---\nfoo: bar\n---\nfoo: bar\n'); - }, yaml.YAMLException); - - assert.throws(function () { - yaml.load('foo: bar\n---\nfoo: bar\n'); - }, yaml.YAMLException); -}); diff --git a/test/units/snippet.js b/test/units/snippet.js deleted file mode 100644 index 47d82c22..00000000 --- a/test/units/snippet.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; - - -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); -var snippet = require('../../lib/snippet'); - - -it('Snippet', function () { - let filepath = path.join(__dirname, 'snippet.txt'), - filedata = fs.readFileSync(filepath, 'utf8'); - - let data = filedata.split(/(---[ \d]*\n)/).slice(1); - - for (let i = 0; i < data.length; i += 4) { - let index = 0, line = 0, column = 0, input = data[i + 1], - expected = data[i + 3].replace(/\n$/, ''), - mark, code; - - assert(input.indexOf('*') >= 0); - - while (input[index] !== '*') { - if (input[index] === '\n') { - line += 1; - column = 0; - } else { - column += 1; - } - index += 1; - } - - mark = { - name: filepath, - buffer: input, - position: index, - line: line, - column: column - }; - - code = snippet(mark, { - indent: 1, - maxLength: 78, - linesBefore: 3, - linesAfter: 2 - }); - - assert.strictEqual(code, expected); - } -}); diff --git a/test/unported/aliases-cdumper-bug.code b/test/unported/aliases-cdumper-bug.code deleted file mode 100644 index 01684417..00000000 --- a/test/unported/aliases-cdumper-bug.code +++ /dev/null @@ -1 +0,0 @@ -[ today, today ] diff --git a/test/unported/aliases.events b/test/unported/aliases.events deleted file mode 100644 index 9139b515..00000000 --- a/test/unported/aliases.events +++ /dev/null @@ -1,8 +0,0 @@ -- !StreamStart -- !DocumentStart -- !SequenceStart -- !Scalar { anchor: 'myanchor', tag: '!mytag', value: 'data' } -- !Alias { anchor: 'myanchor' } -- !SequenceEnd -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/documents.events b/test/unported/documents.events deleted file mode 100644 index 775a51a7..00000000 --- a/test/unported/documents.events +++ /dev/null @@ -1,11 +0,0 @@ -- !StreamStart -- !DocumentStart { explicit: false } -- !Scalar { implicit: [true,false], value: 'data' } -- !DocumentEnd -- !DocumentStart -- !Scalar { implicit: [true,false] } -- !DocumentEnd -- !DocumentStart { version: [1,1], tags: { '!': '!foo', '!yaml!': 'tag:yaml.org,2002:', '!ugly!': '!!!!!!!' } } -- !Scalar { implicit: [true,false] } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/emit-block-scalar-in-simple-key-context-bug.canonical b/test/unported/emit-block-scalar-in-simple-key-context-bug.canonical deleted file mode 100644 index 473bed5d..00000000 --- a/test/unported/emit-block-scalar-in-simple-key-context-bug.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- !!map -{ - ? !!str "foo" - : !!str "bar" -} diff --git a/test/unported/emit-block-scalar-in-simple-key-context-bug.data b/test/unported/emit-block-scalar-in-simple-key-context-bug.data deleted file mode 100644 index b6b42ba5..00000000 --- a/test/unported/emit-block-scalar-in-simple-key-context-bug.data +++ /dev/null @@ -1,4 +0,0 @@ -? |- - foo -: |- - bar diff --git a/test/unported/emitting-unacceptable-unicode-character-bug.skip-ext b/test/unported/emitting-unacceptable-unicode-character-bug.skip-ext deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/empty-anchor.emitter-error b/test/unported/empty-anchor.emitter-error deleted file mode 100644 index ce663b63..00000000 --- a/test/unported/empty-anchor.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart -- !Scalar { anchor: '', value: 'foo' } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/empty-document-bug.canonical b/test/unported/empty-document-bug.canonical deleted file mode 100644 index 28a6cf13..00000000 --- a/test/unported/empty-document-bug.canonical +++ /dev/null @@ -1 +0,0 @@ -# This YAML stream contains no YAML documents. diff --git a/test/unported/empty-document-bug.data b/test/unported/empty-document-bug.data deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/empty-document-bug.empty b/test/unported/empty-document-bug.empty deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/empty-tag-handle.emitter-error b/test/unported/empty-tag-handle.emitter-error deleted file mode 100644 index 235c8998..00000000 --- a/test/unported/empty-tag-handle.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart { tags: { '': 'bar' } } -- !Scalar { value: 'foo' } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/empty-tag-prefix.emitter-error b/test/unported/empty-tag-prefix.emitter-error deleted file mode 100644 index c6c0e955..00000000 --- a/test/unported/empty-tag-prefix.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart { tags: { '!': '' } } -- !Scalar { value: 'foo' } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/empty-tag.emitter-error b/test/unported/empty-tag.emitter-error deleted file mode 100644 index b7ca5931..00000000 --- a/test/unported/empty-tag.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart -- !Scalar { tag: '', value: 'key', implicit: [false,false] } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/expected-document-end.emitter-error b/test/unported/expected-document-end.emitter-error deleted file mode 100644 index 0cbab899..00000000 --- a/test/unported/expected-document-end.emitter-error +++ /dev/null @@ -1,6 +0,0 @@ -- !StreamStart -- !DocumentStart -- !Scalar { value: 'data 1' } -- !Scalar { value: 'data 2' } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/expected-document-start.emitter-error b/test/unported/expected-document-start.emitter-error deleted file mode 100644 index 8ce575ec..00000000 --- a/test/unported/expected-document-start.emitter-error +++ /dev/null @@ -1,4 +0,0 @@ -- !StreamStart -- !MappingStart -- !MappingEnd -- !StreamEnd diff --git a/test/unported/expected-node-1.emitter-error b/test/unported/expected-node-1.emitter-error deleted file mode 100644 index 36ceca3e..00000000 --- a/test/unported/expected-node-1.emitter-error +++ /dev/null @@ -1,4 +0,0 @@ -- !StreamStart -- !DocumentStart -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/expected-node-2.emitter-error b/test/unported/expected-node-2.emitter-error deleted file mode 100644 index 891ee370..00000000 --- a/test/unported/expected-node-2.emitter-error +++ /dev/null @@ -1,7 +0,0 @@ -- !StreamStart -- !DocumentStart -- !MappingStart -- !Scalar { value: 'key' } -- !MappingEnd -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/expected-nothing.emitter-error b/test/unported/expected-nothing.emitter-error deleted file mode 100644 index 62c54d3e..00000000 --- a/test/unported/expected-nothing.emitter-error +++ /dev/null @@ -1,4 +0,0 @@ -- !StreamStart -- !StreamEnd -- !StreamStart -- !StreamEnd diff --git a/test/unported/expected-stream-start.emitter-error b/test/unported/expected-stream-start.emitter-error deleted file mode 100644 index 480dc2eb..00000000 --- a/test/unported/expected-stream-start.emitter-error +++ /dev/null @@ -1,2 +0,0 @@ -- !DocumentStart -- !DocumentEnd diff --git a/test/unported/invalid-anchor.emitter-error b/test/unported/invalid-anchor.emitter-error deleted file mode 100644 index 3d2a8148..00000000 --- a/test/unported/invalid-anchor.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart -- !Scalar { anchor: '5*5=25', value: 'foo' } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/invalid-tag-handle-1.emitter-error b/test/unported/invalid-tag-handle-1.emitter-error deleted file mode 100644 index d5df9a26..00000000 --- a/test/unported/invalid-tag-handle-1.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart { tags: { '!foo': 'bar' } } -- !Scalar { value: 'foo' } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/invalid-tag-handle-2.emitter-error b/test/unported/invalid-tag-handle-2.emitter-error deleted file mode 100644 index d1831d55..00000000 --- a/test/unported/invalid-tag-handle-2.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart { tags: { '!!!': 'bar' } } -- !Scalar { value: 'foo' } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/invalid-utf8-byte.loader-error b/test/unported/invalid-utf8-byte.loader-error deleted file mode 100644 index 0a58c70f..00000000 --- a/test/unported/invalid-utf8-byte.loader-error +++ /dev/null @@ -1,66 +0,0 @@ -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -Invalid byte ('\xFF'): <-- -############################################################### diff --git a/test/unported/invalid-utf8-byte.stream-error b/test/unported/invalid-utf8-byte.stream-error deleted file mode 100644 index 0a58c70f..00000000 --- a/test/unported/invalid-utf8-byte.stream-error +++ /dev/null @@ -1,66 +0,0 @@ -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -############################################################### -Invalid byte ('\xFF'): <-- -############################################################### diff --git a/test/unported/latin.unicode b/test/unported/latin.unicode deleted file mode 100644 index 4fb799c2..00000000 --- a/test/unported/latin.unicode +++ /dev/null @@ -1,384 +0,0 @@ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ -ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ -ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ -őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ -ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ -ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ -ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ -ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ -ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ -ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ -ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ -єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ -ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ -ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ -ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ -ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ -ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ -ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ -ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ -ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố -ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ -ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ -ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ -ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ diff --git a/test/unported/mappings.events b/test/unported/mappings.events deleted file mode 100644 index 3cb5579f..00000000 --- a/test/unported/mappings.events +++ /dev/null @@ -1,44 +0,0 @@ -- !StreamStart - -- !DocumentStart -- !MappingStart -- !Scalar { implicit: [true,true], value: 'key' } -- !Scalar { implicit: [true,true], value: 'value' } -- !Scalar { implicit: [true,true], value: 'empty mapping' } -- !MappingStart -- !MappingEnd -- !Scalar { implicit: [true,true], value: 'empty mapping with tag' } -- !MappingStart { tag: '!mytag', implicit: false } -- !MappingEnd -- !Scalar { implicit: [true,true], value: 'block mapping' } -- !MappingStart -- !MappingStart -- !Scalar { implicit: [true,true], value: 'complex' } -- !Scalar { implicit: [true,true], value: 'key' } -- !Scalar { implicit: [true,true], value: 'complex' } -- !Scalar { implicit: [true,true], value: 'key' } -- !MappingEnd -- !MappingStart -- !Scalar { implicit: [true,true], value: 'complex' } -- !Scalar { implicit: [true,true], value: 'key' } -- !MappingEnd -- !MappingEnd -- !Scalar { implicit: [true,true], value: 'flow mapping' } -- !MappingStart { flow_style: true } -- !Scalar { implicit: [true,true], value: 'key' } -- !Scalar { implicit: [true,true], value: 'value' } -- !MappingStart -- !Scalar { implicit: [true,true], value: 'complex' } -- !Scalar { implicit: [true,true], value: 'key' } -- !Scalar { implicit: [true,true], value: 'complex' } -- !Scalar { implicit: [true,true], value: 'key' } -- !MappingEnd -- !MappingStart -- !Scalar { implicit: [true,true], value: 'complex' } -- !Scalar { implicit: [true,true], value: 'key' } -- !MappingEnd -- !MappingEnd -- !MappingEnd -- !DocumentEnd - -- !StreamEnd diff --git a/test/unported/no-alias-anchor.emitter-error b/test/unported/no-alias-anchor.emitter-error deleted file mode 100644 index 5ff065c1..00000000 --- a/test/unported/no-alias-anchor.emitter-error +++ /dev/null @@ -1,8 +0,0 @@ -- !StreamStart -- !DocumentStart -- !SequenceStart -- !Scalar { anchor: A, value: data } -- !Alias { } -- !SequenceEnd -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/no-alias-anchor.skip-ext b/test/unported/no-alias-anchor.skip-ext deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/no-tag.emitter-error b/test/unported/no-tag.emitter-error deleted file mode 100644 index 384c62f0..00000000 --- a/test/unported/no-tag.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart -- !Scalar { value: 'foo', implicit: [false,false] } -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/recursive-anchor.former-loader-error b/test/unported/recursive-anchor.former-loader-error deleted file mode 100644 index 661166ce..00000000 --- a/test/unported/recursive-anchor.former-loader-error +++ /dev/null @@ -1,4 +0,0 @@ -- &foo [1 - 2, - 3, - *foo] diff --git a/test/unported/recursive-dict.recursive b/test/unported/recursive-dict.recursive deleted file mode 100644 index 8f326f5e..00000000 --- a/test/unported/recursive-dict.recursive +++ /dev/null @@ -1,3 +0,0 @@ -value = {} -instance = AnInstance(value, value) -value[instance] = instance diff --git a/test/unported/recursive-list.recursive b/test/unported/recursive-list.recursive deleted file mode 100644 index 27a4ae50..00000000 --- a/test/unported/recursive-list.recursive +++ /dev/null @@ -1,2 +0,0 @@ -value = [] -value.append(value) diff --git a/test/unported/recursive-set.recursive b/test/unported/recursive-set.recursive deleted file mode 100644 index 457c50de..00000000 --- a/test/unported/recursive-set.recursive +++ /dev/null @@ -1,7 +0,0 @@ -try: - set -except NameError: - from sets import Set as set -value = set() -value.add(AnInstance(foo=value, bar=value)) -value.add(AnInstance(foo=value, bar=value)) diff --git a/test/unported/recursive-state.recursive b/test/unported/recursive-state.recursive deleted file mode 100644 index bffe61ed..00000000 --- a/test/unported/recursive-state.recursive +++ /dev/null @@ -1,2 +0,0 @@ -value = [] -value.append(AnInstanceWithState(value, value)) diff --git a/test/unported/recursive-tuple.recursive b/test/unported/recursive-tuple.recursive deleted file mode 100644 index dc08d029..00000000 --- a/test/unported/recursive-tuple.recursive +++ /dev/null @@ -1,3 +0,0 @@ -value = ([], []) -value[0].append(value) -value[1].append(value[0]) diff --git a/test/unported/recursive.former-dumper-error b/test/unported/recursive.former-dumper-error deleted file mode 100644 index 3c7cc2f8..00000000 --- a/test/unported/recursive.former-dumper-error +++ /dev/null @@ -1,3 +0,0 @@ -data = [] -data.append(data) -dump(data) diff --git a/test/unported/resolver.data b/test/unported/resolver.data deleted file mode 100644 index a2964048..00000000 --- a/test/unported/resolver.data +++ /dev/null @@ -1,30 +0,0 @@ ---- -"this scalar should be selected" ---- -key11: !foo - key12: - is: [selected] - key22: - key13: [not, selected] - key23: [not, selected] - key32: - key31: [not, selected] - key32: [not, selected] - key33: {not: selected} -key21: !bar - - not selected - - selected - - not selected -key31: !baz - key12: - key13: - key14: {selected} - key23: - key14: [not, selected] - key33: - key14: {selected} - key24: {not: selected} - key22: - - key14: {selected} - key24: {not: selected} - - key14: {selected} diff --git a/test/unported/run-parser-crash-bug.data b/test/unported/run-parser-crash-bug.data deleted file mode 100644 index fe017342..00000000 --- a/test/unported/run-parser-crash-bug.data +++ /dev/null @@ -1,8 +0,0 @@ ---- -- Harry Potter and the Prisoner of Azkaban -- Harry Potter and the Goblet of Fire -- Harry Potter and the Order of the Phoenix ---- -- Memoirs Found in a Bathtub -- Snow Crash -- Ghost World diff --git a/test/unported/scalars.events b/test/unported/scalars.events deleted file mode 100644 index 32c40f46..00000000 --- a/test/unported/scalars.events +++ /dev/null @@ -1,28 +0,0 @@ -- !StreamStart - -- !DocumentStart -- !MappingStart -- !Scalar { implicit: [true,true], value: 'empty scalar' } -- !Scalar { implicit: [true,false], value: '' } -- !Scalar { implicit: [true,true], value: 'implicit scalar' } -- !Scalar { implicit: [true,true], value: 'data' } -- !Scalar { implicit: [true,true], value: 'quoted scalar' } -- !Scalar { value: 'data', style: '"' } -- !Scalar { implicit: [true,true], value: 'block scalar' } -- !Scalar { value: 'data', style: '|' } -- !Scalar { implicit: [true,true], value: 'empty scalar with tag' } -- !Scalar { implicit: [false,false], tag: '!mytag', value: '' } -- !Scalar { implicit: [true,true], value: 'implicit scalar with tag' } -- !Scalar { implicit: [false,false], tag: '!mytag', value: 'data' } -- !Scalar { implicit: [true,true], value: 'quoted scalar with tag' } -- !Scalar { value: 'data', style: '"', tag: '!mytag', implicit: [false,false] } -- !Scalar { implicit: [true,true], value: 'block scalar with tag' } -- !Scalar { value: 'data', style: '|', tag: '!mytag', implicit: [false,false] } -- !Scalar { implicit: [true,true], value: 'single character' } -- !Scalar { value: 'a', implicit: [true,true] } -- !Scalar { implicit: [true,true], value: 'single digit' } -- !Scalar { value: '1', implicit: [true,false] } -- !MappingEnd -- !DocumentEnd - -- !StreamEnd diff --git a/test/unported/scan-document-end-bug.canonical b/test/unported/scan-document-end-bug.canonical deleted file mode 100644 index 4a0e8a82..00000000 --- a/test/unported/scan-document-end-bug.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!null "" diff --git a/test/unported/scan-document-end-bug.data b/test/unported/scan-document-end-bug.data deleted file mode 100644 index 3c70543b..00000000 --- a/test/unported/scan-document-end-bug.data +++ /dev/null @@ -1,3 +0,0 @@ -# Ticket #4 ---- -... \ No newline at end of file diff --git a/test/unported/scan-line-break-bug.canonical b/test/unported/scan-line-break-bug.canonical deleted file mode 100644 index 79f08b74..00000000 --- a/test/unported/scan-line-break-bug.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!map { ? !!str "foo" : !!str "bar baz" } diff --git a/test/unported/scan-line-break-bug.data b/test/unported/scan-line-break-bug.data deleted file mode 100644 index c974fab0..00000000 --- a/test/unported/scan-line-break-bug.data +++ /dev/null @@ -1,3 +0,0 @@ -foo: - bar - baz diff --git a/test/unported/sequences.events b/test/unported/sequences.events deleted file mode 100644 index 692a3290..00000000 --- a/test/unported/sequences.events +++ /dev/null @@ -1,81 +0,0 @@ -- !StreamStart - -- !DocumentStart -- !SequenceStart -- !SequenceEnd -- !DocumentEnd - -- !DocumentStart -- !SequenceStart { tag: '!mytag', implicit: false } -- !SequenceEnd -- !DocumentEnd - -- !DocumentStart -- !SequenceStart -- !SequenceStart -- !SequenceEnd -- !SequenceStart { tag: '!mytag', implicit: false } -- !SequenceEnd -- !SequenceStart -- !Scalar -- !Scalar { value: 'data' } -- !Scalar { tag: '!mytag', implicit: [false,false], value: 'data' } -- !SequenceEnd -- !SequenceStart -- !SequenceStart -- !SequenceStart -- !Scalar -- !SequenceEnd -- !SequenceEnd -- !SequenceEnd -- !SequenceStart -- !SequenceStart { tag: '!mytag', implicit: false } -- !SequenceStart -- !Scalar { value: 'data' } -- !SequenceEnd -- !SequenceEnd -- !SequenceEnd -- !SequenceEnd -- !DocumentEnd - -- !DocumentStart -- !SequenceStart -- !MappingStart -- !Scalar { value: 'key1' } -- !SequenceStart -- !Scalar { value: 'data1' } -- !Scalar { value: 'data2' } -- !SequenceEnd -- !Scalar { value: 'key2' } -- !SequenceStart { tag: '!mytag1', implicit: false } -- !Scalar { value: 'data3' } -- !SequenceStart -- !Scalar { value: 'data4' } -- !Scalar { value: 'data5' } -- !SequenceEnd -- !SequenceStart { tag: '!mytag2', implicit: false } -- !Scalar { value: 'data6' } -- !Scalar { value: 'data7' } -- !SequenceEnd -- !SequenceEnd -- !MappingEnd -- !SequenceEnd -- !DocumentEnd - -- !DocumentStart -- !SequenceStart -- !SequenceStart { flow_style: true } -- !SequenceStart -- !SequenceEnd -- !Scalar -- !Scalar { value: 'data' } -- !Scalar { tag: '!mytag', implicit: [false,false], value: 'data' } -- !SequenceStart { tag: '!mytag', implicit: false } -- !Scalar { value: 'data' } -- !Scalar { value: 'data' } -- !SequenceEnd -- !SequenceEnd -- !SequenceEnd -- !DocumentEnd - -- !StreamEnd diff --git a/test/unported/serializer-is-already-opened.dumper-error b/test/unported/serializer-is-already-opened.dumper-error deleted file mode 100644 index 9a23525d..00000000 --- a/test/unported/serializer-is-already-opened.dumper-error +++ /dev/null @@ -1,3 +0,0 @@ -dumper = yaml.Dumper(StringIO()) -dumper.open() -dumper.open() diff --git a/test/unported/serializer-is-closed-1.dumper-error b/test/unported/serializer-is-closed-1.dumper-error deleted file mode 100644 index 8e7e6005..00000000 --- a/test/unported/serializer-is-closed-1.dumper-error +++ /dev/null @@ -1,4 +0,0 @@ -dumper = yaml.Dumper(StringIO()) -dumper.open() -dumper.close() -dumper.open() diff --git a/test/unported/serializer-is-closed-2.dumper-error b/test/unported/serializer-is-closed-2.dumper-error deleted file mode 100644 index 89aef7e9..00000000 --- a/test/unported/serializer-is-closed-2.dumper-error +++ /dev/null @@ -1,4 +0,0 @@ -dumper = yaml.Dumper(StringIO()) -dumper.open() -dumper.close() -dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar')) diff --git a/test/unported/serializer-is-not-opened-1.dumper-error b/test/unported/serializer-is-not-opened-1.dumper-error deleted file mode 100644 index 8f22e73f..00000000 --- a/test/unported/serializer-is-not-opened-1.dumper-error +++ /dev/null @@ -1,2 +0,0 @@ -dumper = yaml.Dumper(StringIO()) -dumper.close() diff --git a/test/unported/serializer-is-not-opened-2.dumper-error b/test/unported/serializer-is-not-opened-2.dumper-error deleted file mode 100644 index ebd9df15..00000000 --- a/test/unported/serializer-is-not-opened-2.dumper-error +++ /dev/null @@ -1,2 +0,0 @@ -dumper = yaml.Dumper(StringIO()) -dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar')) diff --git a/test/unported/sloppy-indentation.canonical b/test/unported/sloppy-indentation.canonical deleted file mode 100644 index 438bc04a..00000000 --- a/test/unported/sloppy-indentation.canonical +++ /dev/null @@ -1,18 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "in the block context" - : !!map { - ? !!str "indentation should be kept" - : !!map { - ? !!str "but in the flow context" - : !!seq [ !!str "it may be violated" ] - } - } -} ---- !!str -"the parser does not require scalars to be indented with at least one space" ---- !!str -"the parser does not require scalars to be indented with at least one space" ---- !!map -{ ? !!str "foo": { ? !!str "bar" : !!str "quoted scalars may not adhere indentation" } } diff --git a/test/unported/sloppy-indentation.data b/test/unported/sloppy-indentation.data deleted file mode 100644 index 2eb4f5a5..00000000 --- a/test/unported/sloppy-indentation.data +++ /dev/null @@ -1,17 +0,0 @@ ---- -in the block context: - indentation should be kept: { - but in the flow context: [ -it may be violated] -} ---- -the parser does not require scalars -to be indented with at least one space -... ---- -"the parser does not require scalars -to be indented with at least one space" ---- -foo: - bar: 'quoted scalars -may not adhere indentation' diff --git a/test/unported/spec-02-01.data b/test/unported/spec-02-01.data deleted file mode 100644 index d12e6711..00000000 --- a/test/unported/spec-02-01.data +++ /dev/null @@ -1,3 +0,0 @@ -- Mark McGwire -- Sammy Sosa -- Ken Griffey diff --git a/test/unported/spec-02-02.data b/test/unported/spec-02-02.data deleted file mode 100644 index 7b7ec948..00000000 --- a/test/unported/spec-02-02.data +++ /dev/null @@ -1,3 +0,0 @@ -hr: 65 # Home runs -avg: 0.278 # Batting average -rbi: 147 # Runs Batted In diff --git a/test/unported/spec-02-03.data b/test/unported/spec-02-03.data deleted file mode 100644 index 656d628e..00000000 --- a/test/unported/spec-02-03.data +++ /dev/null @@ -1,8 +0,0 @@ -american: - - Boston Red Sox - - Detroit Tigers - - New York Yankees -national: - - New York Mets - - Chicago Cubs - - Atlanta Braves diff --git a/test/unported/spec-02-04.data b/test/unported/spec-02-04.data deleted file mode 100644 index 430f6b3d..00000000 --- a/test/unported/spec-02-04.data +++ /dev/null @@ -1,8 +0,0 @@ -- - name: Mark McGwire - hr: 65 - avg: 0.278 -- - name: Sammy Sosa - hr: 63 - avg: 0.288 diff --git a/test/unported/spec-02-05.data b/test/unported/spec-02-05.data deleted file mode 100644 index cdd77706..00000000 --- a/test/unported/spec-02-05.data +++ /dev/null @@ -1,3 +0,0 @@ -- [name , hr, avg ] -- [Mark McGwire, 65, 0.278] -- [Sammy Sosa , 63, 0.288] diff --git a/test/unported/spec-02-06.data b/test/unported/spec-02-06.data deleted file mode 100644 index 7a957b23..00000000 --- a/test/unported/spec-02-06.data +++ /dev/null @@ -1,5 +0,0 @@ -Mark McGwire: {hr: 65, avg: 0.278} -Sammy Sosa: { - hr: 63, - avg: 0.288 - } diff --git a/test/unported/spec-02-07.data b/test/unported/spec-02-07.data deleted file mode 100644 index bc711d54..00000000 --- a/test/unported/spec-02-07.data +++ /dev/null @@ -1,10 +0,0 @@ -# Ranking of 1998 home runs ---- -- Mark McGwire -- Sammy Sosa -- Ken Griffey - -# Team ranking ---- -- Chicago Cubs -- St Louis Cardinals diff --git a/test/unported/spec-02-08.data b/test/unported/spec-02-08.data deleted file mode 100644 index 05e102d8..00000000 --- a/test/unported/spec-02-08.data +++ /dev/null @@ -1,10 +0,0 @@ ---- -time: 20:03:20 -player: Sammy Sosa -action: strike (miss) -... ---- -time: 20:03:47 -player: Sammy Sosa -action: grand slam -... diff --git a/test/unported/spec-02-09.data b/test/unported/spec-02-09.data deleted file mode 100644 index e2641805..00000000 --- a/test/unported/spec-02-09.data +++ /dev/null @@ -1,8 +0,0 @@ ---- -hr: # 1998 hr ranking - - Mark McGwire - - Sammy Sosa -rbi: - # 1998 rbi ranking - - Sammy Sosa - - Ken Griffey diff --git a/test/unported/spec-02-10.data b/test/unported/spec-02-10.data deleted file mode 100644 index 61808f67..00000000 --- a/test/unported/spec-02-10.data +++ /dev/null @@ -1,8 +0,0 @@ ---- -hr: - - Mark McGwire - # Following node labeled SS - - &SS Sammy Sosa -rbi: - - *SS # Subsequent occurrence - - Ken Griffey diff --git a/test/unported/spec-02-11.data b/test/unported/spec-02-11.data deleted file mode 100644 index 9123ce21..00000000 --- a/test/unported/spec-02-11.data +++ /dev/null @@ -1,9 +0,0 @@ -? - Detroit Tigers - - Chicago cubs -: - - 2001-07-23 - -? [ New York Yankees, - Atlanta Braves ] -: [ 2001-07-02, 2001-08-12, - 2001-08-14 ] diff --git a/test/unported/spec-02-12.data b/test/unported/spec-02-12.data deleted file mode 100644 index 1fc33f9d..00000000 --- a/test/unported/spec-02-12.data +++ /dev/null @@ -1,8 +0,0 @@ ---- -# products purchased -- item : Super Hoop - quantity: 1 -- item : Basketball - quantity: 4 -- item : Big Shoes - quantity: 1 diff --git a/test/unported/spec-02-13.data b/test/unported/spec-02-13.data deleted file mode 100644 index 13fb6560..00000000 --- a/test/unported/spec-02-13.data +++ /dev/null @@ -1,4 +0,0 @@ -# ASCII Art ---- | - \//||\/|| - // || ||__ diff --git a/test/unported/spec-02-14.data b/test/unported/spec-02-14.data deleted file mode 100644 index 59943def..00000000 --- a/test/unported/spec-02-14.data +++ /dev/null @@ -1,4 +0,0 @@ ---- - Mark McGwire's - year was crippled - by a knee injury. diff --git a/test/unported/spec-02-15.data b/test/unported/spec-02-15.data deleted file mode 100644 index 80b89a6d..00000000 --- a/test/unported/spec-02-15.data +++ /dev/null @@ -1,8 +0,0 @@ -> - Sammy Sosa completed another - fine season with great stats. - - 63 Home Runs - 0.288 Batting Average - - What a year! diff --git a/test/unported/spec-02-16.data b/test/unported/spec-02-16.data deleted file mode 100644 index 9f66d881..00000000 --- a/test/unported/spec-02-16.data +++ /dev/null @@ -1,7 +0,0 @@ -name: Mark McGwire -accomplishment: > - Mark set a major league - home run record in 1998. -stats: | - 65 Home Runs - 0.278 Batting Average diff --git a/test/unported/spec-02-17.data b/test/unported/spec-02-17.data deleted file mode 100644 index b2870c53..00000000 --- a/test/unported/spec-02-17.data +++ /dev/null @@ -1,7 +0,0 @@ -unicode: "Sosa did fine.\u263A" -control: "\b1998\t1999\t2000\n" -hexesc: "\x13\x10 is \r\n" - -single: '"Howdy!" he cried.' -quoted: ' # not a ''comment''.' -tie-fighter: '|\-*-/|' diff --git a/test/unported/spec-02-18.data b/test/unported/spec-02-18.data deleted file mode 100644 index e0a8bfa9..00000000 --- a/test/unported/spec-02-18.data +++ /dev/null @@ -1,6 +0,0 @@ -plain: - This unquoted scalar - spans many lines. - -quoted: "So does this - quoted scalar.\n" diff --git a/test/unported/spec-02-19.data b/test/unported/spec-02-19.data deleted file mode 100644 index bf69de69..00000000 --- a/test/unported/spec-02-19.data +++ /dev/null @@ -1,5 +0,0 @@ -canonical: 12345 -decimal: +12,345 -sexagesimal: 3:25:45 -octal: 014 -hexadecimal: 0xC diff --git a/test/unported/spec-02-20.data b/test/unported/spec-02-20.data deleted file mode 100644 index 1d4897ff..00000000 --- a/test/unported/spec-02-20.data +++ /dev/null @@ -1,6 +0,0 @@ -canonical: 1.23015e+3 -exponential: 12.3015e+02 -sexagesimal: 20:30.15 -fixed: 1,230.15 -negative infinity: -.inf -not a number: .NaN diff --git a/test/unported/spec-02-21.data b/test/unported/spec-02-21.data deleted file mode 100644 index dec6a56b..00000000 --- a/test/unported/spec-02-21.data +++ /dev/null @@ -1,4 +0,0 @@ -null: ~ -true: y -false: n -string: '12345' diff --git a/test/unported/spec-02-22.data b/test/unported/spec-02-22.data deleted file mode 100644 index aaac185a..00000000 --- a/test/unported/spec-02-22.data +++ /dev/null @@ -1,4 +0,0 @@ -canonical: 2001-12-15T02:59:43.1Z -iso8601: 2001-12-14t21:59:43.10-05:00 -spaced: 2001-12-14 21:59:43.10 -5 -date: 2002-12-14 diff --git a/test/unported/spec-02-23.data b/test/unported/spec-02-23.data deleted file mode 100644 index 5dbd992d..00000000 --- a/test/unported/spec-02-23.data +++ /dev/null @@ -1,13 +0,0 @@ ---- -not-date: !!str 2002-04-28 - -picture: !!binary | - R0lGODlhDAAMAIQAAP//9/X - 17unp5WZmZgAAAOfn515eXv - Pz7Y6OjuDg4J+fn5OTk6enp - 56enmleECcgggoBADs= - -application specific tag: !something | - The semantics of the tag - above may be different for - different documents. diff --git a/test/unported/spec-02-24.data b/test/unported/spec-02-24.data deleted file mode 100644 index 1180757d..00000000 --- a/test/unported/spec-02-24.data +++ /dev/null @@ -1,14 +0,0 @@ -%TAG ! tag:clarkevans.com,2002: ---- !shape - # Use the ! handle for presenting - # tag:clarkevans.com,2002:circle -- !circle - center: &ORIGIN {x: 73, y: 129} - radius: 7 -- !line - start: *ORIGIN - finish: { x: 89, y: 102 } -- !label - start: *ORIGIN - color: 0xFFEEBB - text: Pretty vector drawing. diff --git a/test/unported/spec-02-25.data b/test/unported/spec-02-25.data deleted file mode 100644 index 769ac319..00000000 --- a/test/unported/spec-02-25.data +++ /dev/null @@ -1,7 +0,0 @@ -# sets are represented as a -# mapping where each key is -# associated with the empty string ---- !!set -? Mark McGwire -? Sammy Sosa -? Ken Griff diff --git a/test/unported/spec-02-26.data b/test/unported/spec-02-26.data deleted file mode 100644 index 3143763d..00000000 --- a/test/unported/spec-02-26.data +++ /dev/null @@ -1,7 +0,0 @@ -# ordered maps are represented as -# a sequence of mappings, with -# each mapping having one key ---- !!omap -- Mark McGwire: 65 -- Sammy Sosa: 63 -- Ken Griffy: 58 diff --git a/test/unported/spec-02-27.data b/test/unported/spec-02-27.data deleted file mode 100644 index 4625739d..00000000 --- a/test/unported/spec-02-27.data +++ /dev/null @@ -1,29 +0,0 @@ ---- ! -invoice: 34843 -date : 2001-01-23 -bill-to: &id001 - given : Chris - family : Dumars - address: - lines: | - 458 Walkman Dr. - Suite #292 - city : Royal Oak - state : MI - postal : 48046 -ship-to: *id001 -product: - - sku : BL394D - quantity : 4 - description : Basketball - price : 450.00 - - sku : BL4438H - quantity : 1 - description : Super Hoop - price : 2392.00 -tax : 251.42 -total: 4443.52 -comments: - Late afternoon is best. - Backup contact is Nancy - Billsmer @ 338-4338. diff --git a/test/unported/spec-02-28.data b/test/unported/spec-02-28.data deleted file mode 100644 index a5c8dc85..00000000 --- a/test/unported/spec-02-28.data +++ /dev/null @@ -1,26 +0,0 @@ ---- -Time: 2001-11-23 15:01:42 -5 -User: ed -Warning: - This is an error message - for the log file ---- -Time: 2001-11-23 15:02:31 -5 -User: ed -Warning: - A slightly different error - message. ---- -Date: 2001-11-23 15:03:17 -5 -User: ed -Fatal: - Unknown variable "bar" -Stack: - - file: TopClass.py - line: 23 - code: | - x = MoreObject("345\n") - - file: MoreClass.py - line: 58 - code: |- - foo = bar diff --git a/test/unported/spec-05-01-utf8.data b/test/unported/spec-05-01-utf8.data deleted file mode 100644 index 780d25bf..00000000 --- a/test/unported/spec-05-01-utf8.data +++ /dev/null @@ -1 +0,0 @@ -# Comment only. diff --git a/test/unported/spec-05-01-utf8.empty b/test/unported/spec-05-01-utf8.empty deleted file mode 100644 index bfffa8b6..00000000 --- a/test/unported/spec-05-01-utf8.empty +++ /dev/null @@ -1,2 +0,0 @@ -# This stream contains no -# documents, only comments. diff --git a/test/unported/spec-05-02-utf8.data b/test/unported/spec-05-02-utf8.data deleted file mode 100644 index fb74866f..00000000 --- a/test/unported/spec-05-02-utf8.data +++ /dev/null @@ -1,3 +0,0 @@ -# Invalid use of BOM -# inside a -# document. diff --git a/test/unported/spec-05-02-utf8.error b/test/unported/spec-05-02-utf8.error deleted file mode 100644 index 1df36161..00000000 --- a/test/unported/spec-05-02-utf8.error +++ /dev/null @@ -1,3 +0,0 @@ -ERROR: - A BOM must not appear - inside a document. diff --git a/test/unported/spec-05-03.canonical b/test/unported/spec-05-03.canonical deleted file mode 100644 index a143a73f..00000000 --- a/test/unported/spec-05-03.canonical +++ /dev/null @@ -1,14 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "sequence" - : !!seq [ - !!str "one", !!str "two" - ], - ? !!str "mapping" - : !!map { - ? !!str "sky" : !!str "blue", -# ? !!str "sea" : !!str "green", - ? !!map { ? !!str "sea" : !!str "green" } : !!null "", - } -} diff --git a/test/unported/spec-05-03.data b/test/unported/spec-05-03.data deleted file mode 100644 index 4661f333..00000000 --- a/test/unported/spec-05-03.data +++ /dev/null @@ -1,7 +0,0 @@ -sequence: -- one -- two -mapping: - ? sky - : blue - ? sea : green diff --git a/test/unported/spec-05-04.canonical b/test/unported/spec-05-04.canonical deleted file mode 100644 index 00c97236..00000000 --- a/test/unported/spec-05-04.canonical +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "sequence" - : !!seq [ - !!str "one", !!str "two" - ], - ? !!str "mapping" - : !!map { - ? !!str "sky" : !!str "blue", - ? !!str "sea" : !!str "green", - } -} diff --git a/test/unported/spec-05-04.data b/test/unported/spec-05-04.data deleted file mode 100644 index df338477..00000000 --- a/test/unported/spec-05-04.data +++ /dev/null @@ -1,2 +0,0 @@ -sequence: [ one, two, ] -mapping: { sky: blue, sea: green } diff --git a/test/unported/spec-05-05.data b/test/unported/spec-05-05.data deleted file mode 100644 index 62524c0d..00000000 --- a/test/unported/spec-05-05.data +++ /dev/null @@ -1 +0,0 @@ -# Comment only. diff --git a/test/unported/spec-05-05.empty b/test/unported/spec-05-05.empty deleted file mode 100644 index bfffa8b6..00000000 --- a/test/unported/spec-05-05.empty +++ /dev/null @@ -1,2 +0,0 @@ -# This stream contains no -# documents, only comments. diff --git a/test/unported/spec-05-06.canonical b/test/unported/spec-05-06.canonical deleted file mode 100644 index 4f30c111..00000000 --- a/test/unported/spec-05-06.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "anchored" - : &A1 !local "value", - ? !!str "alias" - : *A1, -} diff --git a/test/unported/spec-05-06.data b/test/unported/spec-05-06.data deleted file mode 100644 index 7a1f9b30..00000000 --- a/test/unported/spec-05-06.data +++ /dev/null @@ -1,2 +0,0 @@ -anchored: !local &anchor value -alias: *anchor diff --git a/test/unported/spec-05-07.canonical b/test/unported/spec-05-07.canonical deleted file mode 100644 index dc3732a5..00000000 --- a/test/unported/spec-05-07.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "literal" - : !!str "text\n", - ? !!str "folded" - : !!str "text\n", -} diff --git a/test/unported/spec-05-07.data b/test/unported/spec-05-07.data deleted file mode 100644 index 97eb3a34..00000000 --- a/test/unported/spec-05-07.data +++ /dev/null @@ -1,4 +0,0 @@ -literal: | - text -folded: > - text diff --git a/test/unported/spec-05-08.canonical b/test/unported/spec-05-08.canonical deleted file mode 100644 index 610bd687..00000000 --- a/test/unported/spec-05-08.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "single" - : !!str "text", - ? !!str "double" - : !!str "text", -} diff --git a/test/unported/spec-05-08.data b/test/unported/spec-05-08.data deleted file mode 100644 index 04ebf691..00000000 --- a/test/unported/spec-05-08.data +++ /dev/null @@ -1,2 +0,0 @@ -single: 'text' -double: "text" diff --git a/test/unported/spec-05-09.canonical b/test/unported/spec-05-09.canonical deleted file mode 100644 index 597e3dea..00000000 --- a/test/unported/spec-05-09.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "text" diff --git a/test/unported/spec-05-09.data b/test/unported/spec-05-09.data deleted file mode 100644 index a43431bd..00000000 --- a/test/unported/spec-05-09.data +++ /dev/null @@ -1,2 +0,0 @@ -%YAML 1.1 ---- text diff --git a/test/unported/spec-05-10.data b/test/unported/spec-05-10.data deleted file mode 100644 index a4caf911..00000000 --- a/test/unported/spec-05-10.data +++ /dev/null @@ -1,2 +0,0 @@ -commercial-at: @text -grave-accent: `text diff --git a/test/unported/spec-05-10.error b/test/unported/spec-05-10.error deleted file mode 100644 index 46f776e5..00000000 --- a/test/unported/spec-05-10.error +++ /dev/null @@ -1,3 +0,0 @@ -ERROR: - Reserved indicators can't - start a plain scalar. diff --git a/test/unported/spec-05-11.canonical b/test/unported/spec-05-11.canonical deleted file mode 100644 index fc25bef4..00000000 --- a/test/unported/spec-05-11.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- !!str -"Generic line break (no glyph)\n\ - Generic line break (glyphed)\n\ - Line separator\u2028\ - Paragraph separator\u2029" diff --git a/test/unported/spec-05-11.data b/test/unported/spec-05-11.data deleted file mode 100644 index b448b759..00000000 --- a/test/unported/spec-05-11.data +++ /dev/null @@ -1,3 +0,0 @@ -| - Generic line break (no glyph) - Generic line break (glyphed)… Line separator
 Paragraph separator
 \ No newline at end of file diff --git a/test/unported/spec-05-12.data b/test/unported/spec-05-12.data deleted file mode 100644 index 7c3ad7f3..00000000 --- a/test/unported/spec-05-12.data +++ /dev/null @@ -1,9 +0,0 @@ -# Tabs do's and don'ts: -# comment: -quoted: "Quoted " -block: | - void main() { - printf("Hello, world!\n"); - } -elsewhere: # separation - indentation, in plain scalar diff --git a/test/unported/spec-05-12.error b/test/unported/spec-05-12.error deleted file mode 100644 index 8aad4c8a..00000000 --- a/test/unported/spec-05-12.error +++ /dev/null @@ -1,8 +0,0 @@ -ERROR: - Tabs may appear inside - comments and quoted or - block scalar content. - Tabs must not appear - elsewhere, such as - in indentation and - separation spaces. diff --git a/test/unported/spec-05-13.canonical b/test/unported/spec-05-13.canonical deleted file mode 100644 index 90c1c5c3..00000000 --- a/test/unported/spec-05-13.canonical +++ /dev/null @@ -1,5 +0,0 @@ -%YAML 1.1 ---- !!str -"Text containing \ - both space and \ - tab characters" diff --git a/test/unported/spec-05-13.data b/test/unported/spec-05-13.data deleted file mode 100644 index fce7951c..00000000 --- a/test/unported/spec-05-13.data +++ /dev/null @@ -1,3 +0,0 @@ - "Text containing - both space and - tab characters" diff --git a/test/unported/spec-05-14.canonical b/test/unported/spec-05-14.canonical deleted file mode 100644 index 4bff01cb..00000000 --- a/test/unported/spec-05-14.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -"Fun with \x5C - \x22 \x07 \x08 \x1B \x0C - \x0A \x0D \x09 \x0B \x00 - \x20 \xA0 \x85 \u2028 \u2029 - A A A" diff --git a/test/unported/spec-05-14.data b/test/unported/spec-05-14.data deleted file mode 100644 index d6e8ce49..00000000 --- a/test/unported/spec-05-14.data +++ /dev/null @@ -1,2 +0,0 @@ -"Fun with \\ - \" \a \b \e \f \… \n \r \t \v \0 \
 \ \_ \N \L \P \
 \x41 \u0041 \U00000041" diff --git a/test/unported/spec-05-15.data b/test/unported/spec-05-15.data deleted file mode 100644 index 7bf12b6c..00000000 --- a/test/unported/spec-05-15.data +++ /dev/null @@ -1,3 +0,0 @@ -Bad escapes: - "\c - \xq-" diff --git a/test/unported/spec-05-15.error b/test/unported/spec-05-15.error deleted file mode 100644 index 71ffbd96..00000000 --- a/test/unported/spec-05-15.error +++ /dev/null @@ -1,3 +0,0 @@ -ERROR: -- c is an invalid escaped character. -- q and - are invalid hex digits. diff --git a/test/unported/spec-06-01.canonical b/test/unported/spec-06-01.canonical deleted file mode 100644 index f17ec922..00000000 --- a/test/unported/spec-06-01.canonical +++ /dev/null @@ -1,15 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "Not indented" - : !!map { - ? !!str "By one space" - : !!str "By four\n spaces\n", - ? !!str "Flow style" - : !!seq [ - !!str "By two", - !!str "Also by two", - !!str "Still by two", - ] - } -} diff --git a/test/unported/spec-06-01.data b/test/unported/spec-06-01.data deleted file mode 100644 index 6134ba12..00000000 --- a/test/unported/spec-06-01.data +++ /dev/null @@ -1,14 +0,0 @@ - # Leading comment line spaces are - # neither content nor indentation. - -Not indented: - By one space: | - By four - spaces - Flow style: [ # Leading spaces - By two, # in flow style - Also by two, # are neither -# Tabs are not allowed: -# Still by two # content nor - Still by two # content nor - ] # indentation. diff --git a/test/unported/spec-06-02.data b/test/unported/spec-06-02.data deleted file mode 100644 index ff741e5f..00000000 --- a/test/unported/spec-06-02.data +++ /dev/null @@ -1,3 +0,0 @@ - # Comment - - diff --git a/test/unported/spec-06-02.empty b/test/unported/spec-06-02.empty deleted file mode 100644 index bfffa8b6..00000000 --- a/test/unported/spec-06-02.empty +++ /dev/null @@ -1,2 +0,0 @@ -# This stream contains no -# documents, only comments. diff --git a/test/unported/spec-06-03.canonical b/test/unported/spec-06-03.canonical deleted file mode 100644 index ec269022..00000000 --- a/test/unported/spec-06-03.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "key" - : !!str "value" -} diff --git a/test/unported/spec-06-03.data b/test/unported/spec-06-03.data deleted file mode 100644 index 9db09129..00000000 --- a/test/unported/spec-06-03.data +++ /dev/null @@ -1,2 +0,0 @@ -key: # Comment - value diff --git a/test/unported/spec-06-04.canonical b/test/unported/spec-06-04.canonical deleted file mode 100644 index ec269022..00000000 --- a/test/unported/spec-06-04.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "key" - : !!str "value" -} diff --git a/test/unported/spec-06-04.data b/test/unported/spec-06-04.data deleted file mode 100644 index 86308dd3..00000000 --- a/test/unported/spec-06-04.data +++ /dev/null @@ -1,4 +0,0 @@ -key: # Comment - # lines - value - diff --git a/test/unported/spec-06-05.canonical b/test/unported/spec-06-05.canonical deleted file mode 100644 index 8da431d0..00000000 --- a/test/unported/spec-06-05.canonical +++ /dev/null @@ -1,16 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!map { - ? !!str "first" - : !!str "Sammy", - ? !!str "last" - : !!str "Sosa" - } - : !!map { - ? !!str "hr" - : !!int "65", - ? !!str "avg" - : !!float "0.278" - } -} diff --git a/test/unported/spec-06-05.data b/test/unported/spec-06-05.data deleted file mode 100644 index 37613f5b..00000000 --- a/test/unported/spec-06-05.data +++ /dev/null @@ -1,6 +0,0 @@ -{ first: Sammy, last: Sosa }: -# Statistics: - hr: # Home runs - 65 - avg: # Average - 0.278 diff --git a/test/unported/spec-06-06.canonical b/test/unported/spec-06-06.canonical deleted file mode 100644 index 513d07a1..00000000 --- a/test/unported/spec-06-06.canonical +++ /dev/null @@ -1,10 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "plain" - : !!str "text lines", - ? !!str "quoted" - : !!str "text lines", - ? !!str "block" - : !!str "text\n lines\n" -} diff --git a/test/unported/spec-06-06.data b/test/unported/spec-06-06.data deleted file mode 100644 index 2f62d082..00000000 --- a/test/unported/spec-06-06.data +++ /dev/null @@ -1,7 +0,0 @@ -plain: text - lines -quoted: "text - lines" -block: | - text - lines diff --git a/test/unported/spec-06-07.canonical b/test/unported/spec-06-07.canonical deleted file mode 100644 index 11357e45..00000000 --- a/test/unported/spec-06-07.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "foo\nbar", - !!str "foo\n\nbar" -] diff --git a/test/unported/spec-06-07.data b/test/unported/spec-06-07.data deleted file mode 100644 index 130cfa74..00000000 --- a/test/unported/spec-06-07.data +++ /dev/null @@ -1,8 +0,0 @@ -- foo - - bar -- |- - foo - - bar - diff --git a/test/unported/spec-06-08.canonical b/test/unported/spec-06-08.canonical deleted file mode 100644 index cc72bc84..00000000 --- a/test/unported/spec-06-08.canonical +++ /dev/null @@ -1,5 +0,0 @@ -%YAML 1.1 ---- !!str -"specific\L\ - trimmed\n\n\n\ - as space" diff --git a/test/unported/spec-06-08.data b/test/unported/spec-06-08.data deleted file mode 100644 index f2896edb..00000000 --- a/test/unported/spec-06-08.data +++ /dev/null @@ -1,2 +0,0 @@ ->- - specific
 trimmed… … …… as… space diff --git a/test/unported/spec-07-01.canonical b/test/unported/spec-07-01.canonical deleted file mode 100644 index 8c8c48db..00000000 --- a/test/unported/spec-07-01.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- !!str -"foo" diff --git a/test/unported/spec-07-01.data b/test/unported/spec-07-01.data deleted file mode 100644 index 2113eb61..00000000 --- a/test/unported/spec-07-01.data +++ /dev/null @@ -1,3 +0,0 @@ -%FOO bar baz # Should be ignored - # with a warning. ---- "foo" diff --git a/test/unported/spec-07-01.skip-ext b/test/unported/spec-07-01.skip-ext deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/spec-07-02.canonical b/test/unported/spec-07-02.canonical deleted file mode 100644 index cb7dd1c3..00000000 --- a/test/unported/spec-07-02.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "foo" diff --git a/test/unported/spec-07-02.data b/test/unported/spec-07-02.data deleted file mode 100644 index c8b73229..00000000 --- a/test/unported/spec-07-02.data +++ /dev/null @@ -1,4 +0,0 @@ -%YAML 1.2 # Attempt parsing - # with a warning ---- -"foo" diff --git a/test/unported/spec-07-02.skip-ext b/test/unported/spec-07-02.skip-ext deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/spec-07-03.data b/test/unported/spec-07-03.data deleted file mode 100644 index 4bfa07ac..00000000 --- a/test/unported/spec-07-03.data +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 -%YAML 1.1 -foo diff --git a/test/unported/spec-07-03.error b/test/unported/spec-07-03.error deleted file mode 100644 index b0ac446b..00000000 --- a/test/unported/spec-07-03.error +++ /dev/null @@ -1,3 +0,0 @@ -ERROR: -The YAML directive must only be -given at most once per document. diff --git a/test/unported/spec-07-04.canonical b/test/unported/spec-07-04.canonical deleted file mode 100644 index cb7dd1c3..00000000 --- a/test/unported/spec-07-04.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "foo" diff --git a/test/unported/spec-07-04.data b/test/unported/spec-07-04.data deleted file mode 100644 index 50f5ab93..00000000 --- a/test/unported/spec-07-04.data +++ /dev/null @@ -1,3 +0,0 @@ -%TAG !yaml! tag:yaml.org,2002: ---- -!yaml!str "foo" diff --git a/test/unported/spec-07-05.data b/test/unported/spec-07-05.data deleted file mode 100644 index 7276eae9..00000000 --- a/test/unported/spec-07-05.data +++ /dev/null @@ -1,3 +0,0 @@ -%TAG ! !foo -%TAG ! !foo -bar diff --git a/test/unported/spec-07-05.error b/test/unported/spec-07-05.error deleted file mode 100644 index 5601b194..00000000 --- a/test/unported/spec-07-05.error +++ /dev/null @@ -1,4 +0,0 @@ -ERROR: -The TAG directive must only -be given at most once per -handle in the same document. diff --git a/test/unported/spec-07-06.canonical b/test/unported/spec-07-06.canonical deleted file mode 100644 index bddf6168..00000000 --- a/test/unported/spec-07-06.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - ! "baz", - ! "string" -] diff --git a/test/unported/spec-07-06.data b/test/unported/spec-07-06.data deleted file mode 100644 index d9854cbd..00000000 --- a/test/unported/spec-07-06.data +++ /dev/null @@ -1,5 +0,0 @@ -%TAG ! !foo -%TAG !yaml! tag:yaml.org,2002: ---- -- !bar "baz" -- !yaml!str "string" diff --git a/test/unported/spec-07-07a.canonical b/test/unported/spec-07-07a.canonical deleted file mode 100644 index fa086df9..00000000 --- a/test/unported/spec-07-07a.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -! "bar" diff --git a/test/unported/spec-07-07a.data b/test/unported/spec-07-07a.data deleted file mode 100644 index 9d42ec3d..00000000 --- a/test/unported/spec-07-07a.data +++ /dev/null @@ -1,2 +0,0 @@ -# Private application: -!foo "bar" diff --git a/test/unported/spec-07-07b.canonical b/test/unported/spec-07-07b.canonical deleted file mode 100644 index fe917d84..00000000 --- a/test/unported/spec-07-07b.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -! "bar" diff --git a/test/unported/spec-07-07b.data b/test/unported/spec-07-07b.data deleted file mode 100644 index 2d36d0e0..00000000 --- a/test/unported/spec-07-07b.data +++ /dev/null @@ -1,4 +0,0 @@ -# Migrated to global: -%TAG ! tag:ben-kiki.org,2000:app/ ---- -!foo "bar" diff --git a/test/unported/spec-07-08.canonical b/test/unported/spec-07-08.canonical deleted file mode 100644 index 703aa7b4..00000000 --- a/test/unported/spec-07-08.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - ! "bar", - ! "string", - ! "baz" -] diff --git a/test/unported/spec-07-08.data b/test/unported/spec-07-08.data deleted file mode 100644 index e2c6d9e1..00000000 --- a/test/unported/spec-07-08.data +++ /dev/null @@ -1,9 +0,0 @@ -# Explicitly specify default settings: -%TAG ! ! -%TAG !! tag:yaml.org,2002: -# Named handles have no default: -%TAG !o! tag:ben-kiki.org,2000: ---- -- !foo "bar" -- !!str "string" -- !o!type "baz" diff --git a/test/unported/spec-07-09.canonical b/test/unported/spec-07-09.canonical deleted file mode 100644 index 32d9e943..00000000 --- a/test/unported/spec-07-09.canonical +++ /dev/null @@ -1,9 +0,0 @@ -%YAML 1.1 ---- -!!str "foo" -%YAML 1.1 ---- -!!str "bar" -%YAML 1.1 ---- -!!str "baz" diff --git a/test/unported/spec-07-09.data b/test/unported/spec-07-09.data deleted file mode 100644 index 1209d47b..00000000 --- a/test/unported/spec-07-09.data +++ /dev/null @@ -1,11 +0,0 @@ ---- -foo -... -# Repeated end marker. -... ---- -bar -# No end marker. ---- -baz -... diff --git a/test/unported/spec-07-10.canonical b/test/unported/spec-07-10.canonical deleted file mode 100644 index 1db650a8..00000000 --- a/test/unported/spec-07-10.canonical +++ /dev/null @@ -1,15 +0,0 @@ -%YAML 1.1 ---- -!!str "Root flow scalar" -%YAML 1.1 ---- -!!str "Root block scalar\n" -%YAML 1.1 ---- -!!map { - ? !!str "foo" - : !!str "bar" -} ---- -#!!str "" -!!null "" diff --git a/test/unported/spec-07-10.data b/test/unported/spec-07-10.data deleted file mode 100644 index 6939b392..00000000 --- a/test/unported/spec-07-10.data +++ /dev/null @@ -1,11 +0,0 @@ -"Root flow - scalar" ---- !!str > - Root block - scalar ---- -# Root collection: -foo : bar -... # Is optional. ---- -# Explicit document may be empty. diff --git a/test/unported/spec-07-11.data b/test/unported/spec-07-11.data deleted file mode 100644 index d11302da..00000000 --- a/test/unported/spec-07-11.data +++ /dev/null @@ -1,2 +0,0 @@ -# A stream may contain -# no documents. diff --git a/test/unported/spec-07-11.empty b/test/unported/spec-07-11.empty deleted file mode 100644 index bfffa8b6..00000000 --- a/test/unported/spec-07-11.empty +++ /dev/null @@ -1,2 +0,0 @@ -# This stream contains no -# documents, only comments. diff --git a/test/unported/spec-07-12a.canonical b/test/unported/spec-07-12a.canonical deleted file mode 100644 index efc116f1..00000000 --- a/test/unported/spec-07-12a.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "foo" - : !!str "bar" -} diff --git a/test/unported/spec-07-12a.data b/test/unported/spec-07-12a.data deleted file mode 100644 index 3807d57d..00000000 --- a/test/unported/spec-07-12a.data +++ /dev/null @@ -1,3 +0,0 @@ -# Implicit document. Root -# collection (mapping) node. -foo : bar diff --git a/test/unported/spec-07-12b.canonical b/test/unported/spec-07-12b.canonical deleted file mode 100644 index 04bcffc8..00000000 --- a/test/unported/spec-07-12b.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "Text content\n" diff --git a/test/unported/spec-07-12b.data b/test/unported/spec-07-12b.data deleted file mode 100644 index 43250db3..00000000 --- a/test/unported/spec-07-12b.data +++ /dev/null @@ -1,4 +0,0 @@ -# Explicit document. Root -# scalar (literal) node. ---- | - Text content diff --git a/test/unported/spec-07-13.canonical b/test/unported/spec-07-13.canonical deleted file mode 100644 index 5af71e91..00000000 --- a/test/unported/spec-07-13.canonical +++ /dev/null @@ -1,9 +0,0 @@ -%YAML 1.1 ---- -!!str "First document" ---- -! "No directives" ---- -! "With directives" ---- -! "Reset settings" diff --git a/test/unported/spec-07-13.data b/test/unported/spec-07-13.data deleted file mode 100644 index ba7ec63e..00000000 --- a/test/unported/spec-07-13.data +++ /dev/null @@ -1,9 +0,0 @@ -! "First document" ---- -!foo "No directives" -%TAG ! !foo ---- -!bar "With directives" -%YAML 1.1 ---- -!baz "Reset settings" diff --git a/test/unported/spec-08-01.canonical b/test/unported/spec-08-01.canonical deleted file mode 100644 index 69e4161b..00000000 --- a/test/unported/spec-08-01.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? &A1 !!str "foo" - : !!str "bar", - ? &A2 !!str "baz" - : *A1 -} diff --git a/test/unported/spec-08-01.data b/test/unported/spec-08-01.data deleted file mode 100644 index 48986ecb..00000000 --- a/test/unported/spec-08-01.data +++ /dev/null @@ -1,2 +0,0 @@ -!!str &a1 "foo" : !!str bar -&a2 baz : *a1 diff --git a/test/unported/spec-08-02.canonical b/test/unported/spec-08-02.canonical deleted file mode 100644 index dd6f76ec..00000000 --- a/test/unported/spec-08-02.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "First occurrence" - : &A !!str "Value", - ? !!str "Second occurrence" - : *A -} diff --git a/test/unported/spec-08-02.data b/test/unported/spec-08-02.data deleted file mode 100644 index 600d1792..00000000 --- a/test/unported/spec-08-02.data +++ /dev/null @@ -1,2 +0,0 @@ -First occurrence: &anchor Value -Second occurrence: *anchor diff --git a/test/unported/spec-08-03.canonical b/test/unported/spec-08-03.canonical deleted file mode 100644 index be7ea8f3..00000000 --- a/test/unported/spec-08-03.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? ! "foo" - : ! "baz" -} diff --git a/test/unported/spec-08-03.data b/test/unported/spec-08-03.data deleted file mode 100644 index 8e51f52a..00000000 --- a/test/unported/spec-08-03.data +++ /dev/null @@ -1,2 +0,0 @@ -! foo : - ! baz diff --git a/test/unported/spec-08-04.data b/test/unported/spec-08-04.data deleted file mode 100644 index f7d1b01e..00000000 --- a/test/unported/spec-08-04.data +++ /dev/null @@ -1,2 +0,0 @@ -- ! foo -- !<$:?> bar diff --git a/test/unported/spec-08-04.error b/test/unported/spec-08-04.error deleted file mode 100644 index 60663755..00000000 --- a/test/unported/spec-08-04.error +++ /dev/null @@ -1,6 +0,0 @@ -ERROR: -- Verbatim tags aren't resolved, - so ! is invalid. -- The $:? tag is neither a global - URI tag nor a local tag starting - with “!”. diff --git a/test/unported/spec-08-05.canonical b/test/unported/spec-08-05.canonical deleted file mode 100644 index a5c710ae..00000000 --- a/test/unported/spec-08-05.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - ! "foo", - ! "bar", - ! "baz", -] diff --git a/test/unported/spec-08-05.data b/test/unported/spec-08-05.data deleted file mode 100644 index 93576ed7..00000000 --- a/test/unported/spec-08-05.data +++ /dev/null @@ -1,5 +0,0 @@ -%TAG !o! tag:ben-kiki.org,2000: ---- -- !local foo -- !!str bar -- !o!type baz diff --git a/test/unported/spec-08-06.data b/test/unported/spec-08-06.data deleted file mode 100644 index 85800105..00000000 --- a/test/unported/spec-08-06.data +++ /dev/null @@ -1,5 +0,0 @@ -%TAG !o! tag:ben-kiki.org,2000: ---- -- !$a!b foo -- !o! bar -- !h!type baz diff --git a/test/unported/spec-08-06.error b/test/unported/spec-08-06.error deleted file mode 100644 index fb76f426..00000000 --- a/test/unported/spec-08-06.error +++ /dev/null @@ -1,4 +0,0 @@ -ERROR: -- The !$a! looks like a handle. -- The !o! handle has no suffix. -- The !h! handle wasn't declared. diff --git a/test/unported/spec-08-07.canonical b/test/unported/spec-08-07.canonical deleted file mode 100644 index e2f43d97..00000000 --- a/test/unported/spec-08-07.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - ! "12", - ! "12", -# ! "12", - ! "12", -] diff --git a/test/unported/spec-08-07.data b/test/unported/spec-08-07.data deleted file mode 100644 index 98aa565e..00000000 --- a/test/unported/spec-08-07.data +++ /dev/null @@ -1,4 +0,0 @@ -# Assuming conventional resolution: -- "12" -- 12 -- ! 12 diff --git a/test/unported/spec-08-08.canonical b/test/unported/spec-08-08.canonical deleted file mode 100644 index d3f8b1a7..00000000 --- a/test/unported/spec-08-08.canonical +++ /dev/null @@ -1,15 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "foo" - : !!str "bar baz" -} -%YAML 1.1 ---- -!!str "foo bar" -%YAML 1.1 ---- -!!str "foo bar" -%YAML 1.1 ---- -!!str "foo\n" diff --git a/test/unported/spec-08-08.data b/test/unported/spec-08-08.data deleted file mode 100644 index 757a93dd..00000000 --- a/test/unported/spec-08-08.data +++ /dev/null @@ -1,13 +0,0 @@ ---- -foo: - "bar - baz" ---- -"foo - bar" ---- -foo - bar ---- | - foo -... diff --git a/test/unported/spec-08-09.canonical b/test/unported/spec-08-09.canonical deleted file mode 100644 index 3805daf0..00000000 --- a/test/unported/spec-08-09.canonical +++ /dev/null @@ -1,21 +0,0 @@ -%YAML 1.1 ---- !!map { - ? !!str "scalars" : !!map { - ? !!str "plain" - : !!str "some text", - ? !!str "quoted" - : !!map { - ? !!str "single" - : !!str "some text", - ? !!str "double" - : !!str "some text" - } }, - ? !!str "collections" : !!map { - ? !!str "sequence" : !!seq [ - !!str "entry", - !!map { - ? !!str "key" : !!str "value" - } ], - ? !!str "mapping" : !!map { - ? !!str "key" : !!str "value" -} } } diff --git a/test/unported/spec-08-09.data b/test/unported/spec-08-09.data deleted file mode 100644 index 69da0422..00000000 --- a/test/unported/spec-08-09.data +++ /dev/null @@ -1,11 +0,0 @@ ---- -scalars: - plain: !!str some text - quoted: - single: 'some text' - double: "some text" -collections: - sequence: !!seq [ !!str entry, - # Mapping entry: - key: value ] - mapping: { key: value } diff --git a/test/unported/spec-08-10.canonical b/test/unported/spec-08-10.canonical deleted file mode 100644 index 8281c5ef..00000000 --- a/test/unported/spec-08-10.canonical +++ /dev/null @@ -1,23 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "block styles" : !!map { - ? !!str "scalars" : !!map { - ? !!str "literal" - : !!str "#!/usr/bin/perl\n\ - print \"Hello, - world!\\n\";\n", - ? !!str "folded" - : !!str "This sentence - is false.\n" - }, - ? !!str "collections" : !!map { - ? !!str "sequence" : !!seq [ - !!str "entry", - !!map { - ? !!str "key" : !!str "value" - } - ], - ? !!str "mapping" : !!map { - ? !!str "key" : !!str "value" -} } } } diff --git a/test/unported/spec-08-10.data b/test/unported/spec-08-10.data deleted file mode 100644 index 72acc56b..00000000 --- a/test/unported/spec-08-10.data +++ /dev/null @@ -1,15 +0,0 @@ -block styles: - scalars: - literal: !!str | - #!/usr/bin/perl - print "Hello, world!\n"; - folded: > - This sentence - is false. - collections: !!map - sequence: !!seq # Entry: - - entry # Plain - # Mapping entry: - - key: value - mapping: - key: value diff --git a/test/unported/spec-08-11.canonical b/test/unported/spec-08-11.canonical deleted file mode 100644 index dd6f76ec..00000000 --- a/test/unported/spec-08-11.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "First occurrence" - : &A !!str "Value", - ? !!str "Second occurrence" - : *A -} diff --git a/test/unported/spec-08-11.data b/test/unported/spec-08-11.data deleted file mode 100644 index 600d1792..00000000 --- a/test/unported/spec-08-11.data +++ /dev/null @@ -1,2 +0,0 @@ -First occurrence: &anchor Value -Second occurrence: *anchor diff --git a/test/unported/spec-08-12.canonical b/test/unported/spec-08-12.canonical deleted file mode 100644 index 93899f4e..00000000 --- a/test/unported/spec-08-12.canonical +++ /dev/null @@ -1,10 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "Without properties", - &A !!str "Anchored", - !!str "Tagged", - *A, - !!str "", - !!str "", -] diff --git a/test/unported/spec-08-12.data b/test/unported/spec-08-12.data deleted file mode 100644 index 3d4c6b7c..00000000 --- a/test/unported/spec-08-12.data +++ /dev/null @@ -1,8 +0,0 @@ -[ - Without properties, - &anchor "Anchored", - !!str 'Tagged', - *anchor, # Alias node - !!str , # Empty plain scalar - '', # Empty plain scalar -] diff --git a/test/unported/spec-08-13.canonical b/test/unported/spec-08-13.canonical deleted file mode 100644 index 618bb7bd..00000000 --- a/test/unported/spec-08-13.canonical +++ /dev/null @@ -1,10 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "foo" -# : !!str "", -# ? !!str "" - : !!null "", - ? !!null "" - : !!str "bar", -} diff --git a/test/unported/spec-08-13.data b/test/unported/spec-08-13.data deleted file mode 100644 index ebe663ac..00000000 --- a/test/unported/spec-08-13.data +++ /dev/null @@ -1,4 +0,0 @@ -{ - ? foo :, - ? : bar, -} diff --git a/test/unported/spec-08-13.skip-ext b/test/unported/spec-08-13.skip-ext deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/spec-08-14.canonical b/test/unported/spec-08-14.canonical deleted file mode 100644 index 11db439f..00000000 --- a/test/unported/spec-08-14.canonical +++ /dev/null @@ -1,10 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "flow in block", - !!str "Block scalar\n", - !!map { - ? !!str "foo" - : !!str "bar" - } -] diff --git a/test/unported/spec-08-14.data b/test/unported/spec-08-14.data deleted file mode 100644 index 2fbb1f70..00000000 --- a/test/unported/spec-08-14.data +++ /dev/null @@ -1,5 +0,0 @@ -- "flow in block" -- > - Block scalar -- !!map # Block collection - foo : bar diff --git a/test/unported/spec-08-15.canonical b/test/unported/spec-08-15.canonical deleted file mode 100644 index 76f028e6..00000000 --- a/test/unported/spec-08-15.canonical +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!null "", - !!map { - ? !!str "foo" - : !!null "", - ? !!null "" - : !!str "bar", - } -] diff --git a/test/unported/spec-08-15.data b/test/unported/spec-08-15.data deleted file mode 100644 index 7c86bcf3..00000000 --- a/test/unported/spec-08-15.data +++ /dev/null @@ -1,5 +0,0 @@ -- # Empty plain scalar -- ? foo - : - ? - : bar diff --git a/test/unported/spec-09-01.canonical b/test/unported/spec-09-01.canonical deleted file mode 100644 index e71a5484..00000000 --- a/test/unported/spec-09-01.canonical +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "simple key" - : !!map { - ? !!str "also simple" - : !!str "value", - ? !!str "not a simple key" - : !!str "any value" - } -} diff --git a/test/unported/spec-09-01.data b/test/unported/spec-09-01.data deleted file mode 100644 index 9e83eaff..00000000 --- a/test/unported/spec-09-01.data +++ /dev/null @@ -1,6 +0,0 @@ -"simple key" : { - "also simple" : value, - ? "not a - simple key" : "any - value" -} diff --git a/test/unported/spec-09-02.canonical b/test/unported/spec-09-02.canonical deleted file mode 100644 index 6f8f41ad..00000000 --- a/test/unported/spec-09-02.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!str "as space \ - trimmed\n\ - specific\L\n\ - escaped\t\n\ - none" diff --git a/test/unported/spec-09-02.data b/test/unported/spec-09-02.data deleted file mode 100644 index d84883dc..00000000 --- a/test/unported/spec-09-02.data +++ /dev/null @@ -1,6 +0,0 @@ - "as space - trimmed - - specific
 - escaped \
 - none" diff --git a/test/unported/spec-09-03.canonical b/test/unported/spec-09-03.canonical deleted file mode 100644 index 658c6df8..00000000 --- a/test/unported/spec-09-03.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str " last", - !!str " last", - !!str " \tfirst last", -] diff --git a/test/unported/spec-09-03.data b/test/unported/spec-09-03.data deleted file mode 100644 index e0b914d7..00000000 --- a/test/unported/spec-09-03.data +++ /dev/null @@ -1,6 +0,0 @@ -- " - last" -- " - last" -- " first - last" diff --git a/test/unported/spec-09-04.canonical b/test/unported/spec-09-04.canonical deleted file mode 100644 index fa466324..00000000 --- a/test/unported/spec-09-04.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!str "first \ - inner 1 \ - inner 2 \ - last" diff --git a/test/unported/spec-09-04.data b/test/unported/spec-09-04.data deleted file mode 100644 index 313a91b4..00000000 --- a/test/unported/spec-09-04.data +++ /dev/null @@ -1,4 +0,0 @@ - "first - inner 1 - \ inner 2 \ - last" diff --git a/test/unported/spec-09-05.canonical b/test/unported/spec-09-05.canonical deleted file mode 100644 index 24d10528..00000000 --- a/test/unported/spec-09-05.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "first ", - !!str "first\nlast", - !!str "first inner \tlast", -] diff --git a/test/unported/spec-09-05.data b/test/unported/spec-09-05.data deleted file mode 100644 index 624c30ea..00000000 --- a/test/unported/spec-09-05.data +++ /dev/null @@ -1,8 +0,0 @@ -- "first - " -- "first - - last" -- "first - inner - \ last" diff --git a/test/unported/spec-09-06.canonical b/test/unported/spec-09-06.canonical deleted file mode 100644 index 50287722..00000000 --- a/test/unported/spec-09-06.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "here's to \"quotes\"" diff --git a/test/unported/spec-09-06.data b/test/unported/spec-09-06.data deleted file mode 100644 index b038078e..00000000 --- a/test/unported/spec-09-06.data +++ /dev/null @@ -1 +0,0 @@ - 'here''s to "quotes"' diff --git a/test/unported/spec-09-07.canonical b/test/unported/spec-09-07.canonical deleted file mode 100644 index e71a5484..00000000 --- a/test/unported/spec-09-07.canonical +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "simple key" - : !!map { - ? !!str "also simple" - : !!str "value", - ? !!str "not a simple key" - : !!str "any value" - } -} diff --git a/test/unported/spec-09-07.data b/test/unported/spec-09-07.data deleted file mode 100644 index 755b54a0..00000000 --- a/test/unported/spec-09-07.data +++ /dev/null @@ -1,6 +0,0 @@ -'simple key' : { - 'also simple' : value, - ? 'not a - simple key' : 'any - value' -} diff --git a/test/unported/spec-09-08.canonical b/test/unported/spec-09-08.canonical deleted file mode 100644 index 06abdb5f..00000000 --- a/test/unported/spec-09-08.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!str "as space \ - trimmed\n\ - specific\L\n\ - none" diff --git a/test/unported/spec-09-08.data b/test/unported/spec-09-08.data deleted file mode 100644 index aa4d4589..00000000 --- a/test/unported/spec-09-08.data +++ /dev/null @@ -1 +0,0 @@ - 'as space … trimmed …… specific
… none' diff --git a/test/unported/spec-09-09.canonical b/test/unported/spec-09-09.canonical deleted file mode 100644 index 658c6df8..00000000 --- a/test/unported/spec-09-09.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str " last", - !!str " last", - !!str " \tfirst last", -] diff --git a/test/unported/spec-09-09.data b/test/unported/spec-09-09.data deleted file mode 100644 index 52171df3..00000000 --- a/test/unported/spec-09-09.data +++ /dev/null @@ -1,6 +0,0 @@ -- ' - last' -- ' - last' -- ' first - last' diff --git a/test/unported/spec-09-10.canonical b/test/unported/spec-09-10.canonical deleted file mode 100644 index 2028d044..00000000 --- a/test/unported/spec-09-10.canonical +++ /dev/null @@ -1,5 +0,0 @@ -%YAML 1.1 ---- -!!str "first \ - inner \ - last" diff --git a/test/unported/spec-09-10.data b/test/unported/spec-09-10.data deleted file mode 100644 index 0e414495..00000000 --- a/test/unported/spec-09-10.data +++ /dev/null @@ -1,3 +0,0 @@ - 'first - inner - last' diff --git a/test/unported/spec-09-11.canonical b/test/unported/spec-09-11.canonical deleted file mode 100644 index 4eb222c9..00000000 --- a/test/unported/spec-09-11.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "first ", - !!str "first\nlast", -] diff --git a/test/unported/spec-09-11.data b/test/unported/spec-09-11.data deleted file mode 100644 index 5efa873b..00000000 --- a/test/unported/spec-09-11.data +++ /dev/null @@ -1,5 +0,0 @@ -- 'first - ' -- 'first - - last' diff --git a/test/unported/spec-09-12.canonical b/test/unported/spec-09-12.canonical deleted file mode 100644 index d8e6dce7..00000000 --- a/test/unported/spec-09-12.canonical +++ /dev/null @@ -1,12 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "::std::vector", - !!str "Up, up, and away!", - !!int "-123", - !!seq [ - !!str "::std::vector", - !!str "Up, up, and away!", - !!int "-123", - ] -] diff --git a/test/unported/spec-09-12.data b/test/unported/spec-09-12.data deleted file mode 100644 index b9a3ac53..00000000 --- a/test/unported/spec-09-12.data +++ /dev/null @@ -1,8 +0,0 @@ -# Outside flow collection: -- ::std::vector -- Up, up, and away! -- -123 -# Inside flow collection: -- [ '::std::vector', - "Up, up, and away!", - -123 ] diff --git a/test/unported/spec-09-13.canonical b/test/unported/spec-09-13.canonical deleted file mode 100644 index e71a5484..00000000 --- a/test/unported/spec-09-13.canonical +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "simple key" - : !!map { - ? !!str "also simple" - : !!str "value", - ? !!str "not a simple key" - : !!str "any value" - } -} diff --git a/test/unported/spec-09-13.data b/test/unported/spec-09-13.data deleted file mode 100644 index b156386a..00000000 --- a/test/unported/spec-09-13.data +++ /dev/null @@ -1,6 +0,0 @@ -simple key : { - also simple : value, - ? not a - simple key : any - value -} diff --git a/test/unported/spec-09-14.data b/test/unported/spec-09-14.data deleted file mode 100644 index 97f23162..00000000 --- a/test/unported/spec-09-14.data +++ /dev/null @@ -1,14 +0,0 @@ ---- ---- ||| : foo -... >>>: bar ---- -[ ---- -, -... , -{ ---- : -... # Nested -} -] -... diff --git a/test/unported/spec-09-14.error b/test/unported/spec-09-14.error deleted file mode 100644 index 9f3db7b0..00000000 --- a/test/unported/spec-09-14.error +++ /dev/null @@ -1,6 +0,0 @@ -ERROR: - The --- and ... document - start and end markers must - not be specified as the - first content line of a - non-indented plain scalar. diff --git a/test/unported/spec-09-15.canonical b/test/unported/spec-09-15.canonical deleted file mode 100644 index df020407..00000000 --- a/test/unported/spec-09-15.canonical +++ /dev/null @@ -1,18 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "---" - : !!str "foo", - ? !!str "..." - : !!str "bar" -} -%YAML 1.1 ---- -!!seq [ - !!str "---", - !!str "...", - !!map { - ? !!str "---" - : !!str "..." - } -] diff --git a/test/unported/spec-09-15.data b/test/unported/spec-09-15.data deleted file mode 100644 index e6863b04..00000000 --- a/test/unported/spec-09-15.data +++ /dev/null @@ -1,13 +0,0 @@ ---- -"---" : foo -...: bar ---- -[ ----, -..., -{ -? --- -: ... -} -] -... diff --git a/test/unported/spec-09-16.canonical b/test/unported/spec-09-16.canonical deleted file mode 100644 index 06abdb5f..00000000 --- a/test/unported/spec-09-16.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!str "as space \ - trimmed\n\ - specific\L\n\ - none" diff --git a/test/unported/spec-09-16.data b/test/unported/spec-09-16.data deleted file mode 100644 index 473beb9a..00000000 --- a/test/unported/spec-09-16.data +++ /dev/null @@ -1,3 +0,0 @@ -# Tabs are confusing: -# as space/trimmed/specific/none - as space … trimmed …… specific
… none diff --git a/test/unported/spec-09-17.canonical b/test/unported/spec-09-17.canonical deleted file mode 100644 index 68cb70d1..00000000 --- a/test/unported/spec-09-17.canonical +++ /dev/null @@ -1,4 +0,0 @@ -%YAML 1.1 ---- -!!str "first line\n\ - more line" diff --git a/test/unported/spec-09-17.data b/test/unported/spec-09-17.data deleted file mode 100644 index 97bc46c4..00000000 --- a/test/unported/spec-09-17.data +++ /dev/null @@ -1,3 +0,0 @@ - first line - - more line diff --git a/test/unported/spec-09-18.canonical b/test/unported/spec-09-18.canonical deleted file mode 100644 index f21428f6..00000000 --- a/test/unported/spec-09-18.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "literal\n", - !!str " folded\n", - !!str "keep\n\n", - !!str " strip", -] diff --git a/test/unported/spec-09-18.data b/test/unported/spec-09-18.data deleted file mode 100644 index 68c5d7cc..00000000 --- a/test/unported/spec-09-18.data +++ /dev/null @@ -1,9 +0,0 @@ -- | # Just the style - literal -- >1 # Indentation indicator - folded -- |+ # Chomping indicator - keep - -- >-1 # Both indicators - strip diff --git a/test/unported/spec-09-19.canonical b/test/unported/spec-09-19.canonical deleted file mode 100644 index 3e828d7d..00000000 --- a/test/unported/spec-09-19.canonical +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "literal\n", - !!str "folded\n", -] diff --git a/test/unported/spec-09-19.data b/test/unported/spec-09-19.data deleted file mode 100644 index f0e589dc..00000000 --- a/test/unported/spec-09-19.data +++ /dev/null @@ -1,4 +0,0 @@ -- | - literal -- > - folded diff --git a/test/unported/spec-09-20.canonical b/test/unported/spec-09-20.canonical deleted file mode 100644 index d03bef51..00000000 --- a/test/unported/spec-09-20.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "detected\n", - !!str "\n\n# detected\n", - !!str " explicit\n", - !!str "\t\ndetected\n", -] diff --git a/test/unported/spec-09-20.data b/test/unported/spec-09-20.data deleted file mode 100644 index 39bee044..00000000 --- a/test/unported/spec-09-20.data +++ /dev/null @@ -1,11 +0,0 @@ -- | - detected -- > - - - # detected -- |1 - explicit -- > - - detected diff --git a/test/unported/spec-09-20.skip-ext b/test/unported/spec-09-20.skip-ext deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unported/spec-09-21.data b/test/unported/spec-09-21.data deleted file mode 100644 index 0fdd14f2..00000000 --- a/test/unported/spec-09-21.data +++ /dev/null @@ -1,8 +0,0 @@ -- | - - text -- > - text - text -- |1 - text diff --git a/test/unported/spec-09-21.error b/test/unported/spec-09-21.error deleted file mode 100644 index 1379ca50..00000000 --- a/test/unported/spec-09-21.error +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: -- A leading all-space line must - not have too many spaces. -- A following text line must - not be less indented. -- The text is less indented - than the indicated level. diff --git a/test/unported/spec-09-22.canonical b/test/unported/spec-09-22.canonical deleted file mode 100644 index c1bbcd22..00000000 --- a/test/unported/spec-09-22.canonical +++ /dev/null @@ -1,10 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "strip" - : !!str "text", - ? !!str "clip" - : !!str "text\n", - ? !!str "keep" - : !!str "text\L", -} diff --git a/test/unported/spec-09-22.data b/test/unported/spec-09-22.data deleted file mode 100644 index 0dd51eb3..00000000 --- a/test/unported/spec-09-22.data +++ /dev/null @@ -1,4 +0,0 @@ -strip: |- - text
clip: | - text…keep: |+ - text
 \ No newline at end of file diff --git a/test/unported/spec-09-23.canonical b/test/unported/spec-09-23.canonical deleted file mode 100644 index c4444caa..00000000 --- a/test/unported/spec-09-23.canonical +++ /dev/null @@ -1,10 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "strip" - : !!str "# text", - ? !!str "clip" - : !!str "# text\n", - ? !!str "keep" - : !!str "# text\L\n", -} diff --git a/test/unported/spec-09-23.data b/test/unported/spec-09-23.data deleted file mode 100644 index 8972d2b6..00000000 --- a/test/unported/spec-09-23.data +++ /dev/null @@ -1,11 +0,0 @@ - # Strip - # Comments: -strip: |- - # text
 
 # Clip - # comments: -…clip: | - # text… 
 # Keep - # comments: -…keep: |+ - # text
… # Trail - # comments. diff --git a/test/unported/spec-09-24.canonical b/test/unported/spec-09-24.canonical deleted file mode 100644 index 45a99b01..00000000 --- a/test/unported/spec-09-24.canonical +++ /dev/null @@ -1,10 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "strip" - : !!str "", - ? !!str "clip" - : !!str "", - ? !!str "keep" - : !!str "\n", -} diff --git a/test/unported/spec-09-24.data b/test/unported/spec-09-24.data deleted file mode 100644 index de0b64bb..00000000 --- a/test/unported/spec-09-24.data +++ /dev/null @@ -1,6 +0,0 @@ -strip: >- - -clip: > - -keep: |+ - diff --git a/test/unported/spec-09-25.canonical b/test/unported/spec-09-25.canonical deleted file mode 100644 index 9d2327bb..00000000 --- a/test/unported/spec-09-25.canonical +++ /dev/null @@ -1,4 +0,0 @@ -%YAML 1.1 ---- -!!str "literal\n\ - \ttext\n" diff --git a/test/unported/spec-09-25.data b/test/unported/spec-09-25.data deleted file mode 100644 index f6303a14..00000000 --- a/test/unported/spec-09-25.data +++ /dev/null @@ -1,3 +0,0 @@ -| # Simple block scalar - literal - text diff --git a/test/unported/spec-09-26.canonical b/test/unported/spec-09-26.canonical deleted file mode 100644 index 3029a116..00000000 --- a/test/unported/spec-09-26.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "\n\nliteral\n\ntext\n" diff --git a/test/unported/spec-09-26.data b/test/unported/spec-09-26.data deleted file mode 100644 index f28555ab..00000000 --- a/test/unported/spec-09-26.data +++ /dev/null @@ -1,8 +0,0 @@ -| - - - literal - - text - - # Comment diff --git a/test/unported/spec-09-27.canonical b/test/unported/spec-09-27.canonical deleted file mode 100644 index 3029a116..00000000 --- a/test/unported/spec-09-27.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "\n\nliteral\n\ntext\n" diff --git a/test/unported/spec-09-27.data b/test/unported/spec-09-27.data deleted file mode 100644 index f28555ab..00000000 --- a/test/unported/spec-09-27.data +++ /dev/null @@ -1,8 +0,0 @@ -| - - - literal - - text - - # Comment diff --git a/test/unported/spec-09-28.canonical b/test/unported/spec-09-28.canonical deleted file mode 100644 index 3029a116..00000000 --- a/test/unported/spec-09-28.canonical +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.1 ---- -!!str "\n\nliteral\n\ntext\n" diff --git a/test/unported/spec-09-28.data b/test/unported/spec-09-28.data deleted file mode 100644 index f28555ab..00000000 --- a/test/unported/spec-09-28.data +++ /dev/null @@ -1,8 +0,0 @@ -| - - - literal - - text - - # Comment diff --git a/test/unported/spec-09-29.canonical b/test/unported/spec-09-29.canonical deleted file mode 100644 index 0980789a..00000000 --- a/test/unported/spec-09-29.canonical +++ /dev/null @@ -1,4 +0,0 @@ -%YAML 1.1 ---- -!!str "folded text\n\ - \tlines\n" diff --git a/test/unported/spec-09-29.data b/test/unported/spec-09-29.data deleted file mode 100644 index 82e611fc..00000000 --- a/test/unported/spec-09-29.data +++ /dev/null @@ -1,4 +0,0 @@ -> # Simple folded scalar - folded - text - lines diff --git a/test/unported/spec-09-30.canonical b/test/unported/spec-09-30.canonical deleted file mode 100644 index fc37db1c..00000000 --- a/test/unported/spec-09-30.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!str "folded line\n\ - next line\n\n\ - \ * bullet\n\ - \ * list\n\n\ - last line\n" diff --git a/test/unported/spec-09-30.data b/test/unported/spec-09-30.data deleted file mode 100644 index a4d8c36a..00000000 --- a/test/unported/spec-09-30.data +++ /dev/null @@ -1,14 +0,0 @@ -> - folded - line - - next - line - - * bullet - * list - - last - line - -# Comment diff --git a/test/unported/spec-09-31.canonical b/test/unported/spec-09-31.canonical deleted file mode 100644 index fc37db1c..00000000 --- a/test/unported/spec-09-31.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!str "folded line\n\ - next line\n\n\ - \ * bullet\n\ - \ * list\n\n\ - last line\n" diff --git a/test/unported/spec-09-31.data b/test/unported/spec-09-31.data deleted file mode 100644 index a4d8c36a..00000000 --- a/test/unported/spec-09-31.data +++ /dev/null @@ -1,14 +0,0 @@ -> - folded - line - - next - line - - * bullet - * list - - last - line - -# Comment diff --git a/test/unported/spec-09-32.canonical b/test/unported/spec-09-32.canonical deleted file mode 100644 index fc37db1c..00000000 --- a/test/unported/spec-09-32.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!str "folded line\n\ - next line\n\n\ - \ * bullet\n\ - \ * list\n\n\ - last line\n" diff --git a/test/unported/spec-09-32.data b/test/unported/spec-09-32.data deleted file mode 100644 index a4d8c36a..00000000 --- a/test/unported/spec-09-32.data +++ /dev/null @@ -1,14 +0,0 @@ -> - folded - line - - next - line - - * bullet - * list - - last - line - -# Comment diff --git a/test/unported/spec-09-33.canonical b/test/unported/spec-09-33.canonical deleted file mode 100644 index fc37db1c..00000000 --- a/test/unported/spec-09-33.canonical +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 ---- -!!str "folded line\n\ - next line\n\n\ - \ * bullet\n\ - \ * list\n\n\ - last line\n" diff --git a/test/unported/spec-09-33.data b/test/unported/spec-09-33.data deleted file mode 100644 index a4d8c36a..00000000 --- a/test/unported/spec-09-33.data +++ /dev/null @@ -1,14 +0,0 @@ -> - folded - line - - next - line - - * bullet - * list - - last - line - -# Comment diff --git a/test/unported/spec-10-01.canonical b/test/unported/spec-10-01.canonical deleted file mode 100644 index d08cdd40..00000000 --- a/test/unported/spec-10-01.canonical +++ /dev/null @@ -1,12 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!seq [ - !!str "inner", - !!str "inner", - ], - !!seq [ - !!str "inner", - !!str "last", - ], -] diff --git a/test/unported/spec-10-01.data b/test/unported/spec-10-01.data deleted file mode 100644 index e668d38d..00000000 --- a/test/unported/spec-10-01.data +++ /dev/null @@ -1,2 +0,0 @@ -- [ inner, inner, ] -- [inner,last] diff --git a/test/unported/spec-10-02.canonical b/test/unported/spec-10-02.canonical deleted file mode 100644 index 82fe0d94..00000000 --- a/test/unported/spec-10-02.canonical +++ /dev/null @@ -1,14 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!str "double quoted", - !!str "single quoted", - !!str "plain text", - !!seq [ - !!str "nested", - ], - !!map { - ? !!str "single" - : !!str "pair" - } -] diff --git a/test/unported/spec-10-02.data b/test/unported/spec-10-02.data deleted file mode 100644 index 3b233515..00000000 --- a/test/unported/spec-10-02.data +++ /dev/null @@ -1,8 +0,0 @@ -[ -"double - quoted", 'single - quoted', -plain - text, [ nested ], -single: pair , -] diff --git a/test/unported/spec-10-03.canonical b/test/unported/spec-10-03.canonical deleted file mode 100644 index 1443395b..00000000 --- a/test/unported/spec-10-03.canonical +++ /dev/null @@ -1,12 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "block" - : !!seq [ - !!str "one", - !!map { - ? !!str "two" - : !!str "three" - } - ] -} diff --git a/test/unported/spec-10-03.data b/test/unported/spec-10-03.data deleted file mode 100644 index 9e15f83b..00000000 --- a/test/unported/spec-10-03.data +++ /dev/null @@ -1,4 +0,0 @@ -block: # Block - # sequence -- one -- two : three diff --git a/test/unported/spec-10-04.canonical b/test/unported/spec-10-04.canonical deleted file mode 100644 index ae486a3c..00000000 --- a/test/unported/spec-10-04.canonical +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "block" - : !!seq [ - !!str "one", - !!seq [ - !!str "two" - ] - ] -} diff --git a/test/unported/spec-10-04.data b/test/unported/spec-10-04.data deleted file mode 100644 index 2905b0d9..00000000 --- a/test/unported/spec-10-04.data +++ /dev/null @@ -1,4 +0,0 @@ -block: -- one -- - - two diff --git a/test/unported/spec-10-05.canonical b/test/unported/spec-10-05.canonical deleted file mode 100644 index 07cc0c98..00000000 --- a/test/unported/spec-10-05.canonical +++ /dev/null @@ -1,14 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!null "", - !!str "block node\n", - !!seq [ - !!str "one", - !!str "two", - ], - !!map { - ? !!str "one" - : !!str "two", - } -] diff --git a/test/unported/spec-10-05.data b/test/unported/spec-10-05.data deleted file mode 100644 index f19a99e3..00000000 --- a/test/unported/spec-10-05.data +++ /dev/null @@ -1,7 +0,0 @@ -- # Empty -- | - block node -- - one # in-line - - two # sequence -- one: two # in-line - # mapping diff --git a/test/unported/spec-10-06.canonical b/test/unported/spec-10-06.canonical deleted file mode 100644 index d9986c28..00000000 --- a/test/unported/spec-10-06.canonical +++ /dev/null @@ -1,16 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!map { - ? !!str "inner" - : !!str "entry", - ? !!str "also" - : !!str "inner" - }, - !!map { - ? !!str "inner" - : !!str "entry", - ? !!str "last" - : !!str "entry" - } -] diff --git a/test/unported/spec-10-06.data b/test/unported/spec-10-06.data deleted file mode 100644 index 860ba25b..00000000 --- a/test/unported/spec-10-06.data +++ /dev/null @@ -1,2 +0,0 @@ -- { inner : entry , also: inner , } -- {inner: entry,last : entry} diff --git a/test/unported/spec-10-07.canonical b/test/unported/spec-10-07.canonical deleted file mode 100644 index ec74230a..00000000 --- a/test/unported/spec-10-07.canonical +++ /dev/null @@ -1,16 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!null "" - : !!str "value", - ? !!str "explicit key" - : !!str "value", - ? !!str "simple key" - : !!str "value", - ? !!seq [ - !!str "collection", - !!str "simple", - !!str "key" - ] - : !!str "value" -} diff --git a/test/unported/spec-10-07.data b/test/unported/spec-10-07.data deleted file mode 100644 index ff943fbc..00000000 --- a/test/unported/spec-10-07.data +++ /dev/null @@ -1,7 +0,0 @@ -{ -? : value, # Empty key -? explicit - key: value, -simple key : value, -[ collection, simple, key ]: value -} diff --git a/test/unported/spec-10-08.data b/test/unported/spec-10-08.data deleted file mode 100644 index 55bd788a..00000000 --- a/test/unported/spec-10-08.data +++ /dev/null @@ -1,5 +0,0 @@ -{ -multi-line - simple key : value, -very long ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................(>1KB)................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... key: value -} diff --git a/test/unported/spec-10-08.error b/test/unported/spec-10-08.error deleted file mode 100644 index 3979e1f7..00000000 --- a/test/unported/spec-10-08.error +++ /dev/null @@ -1,5 +0,0 @@ -ERROR: -- A simple key is restricted - to only one line. -- A simple key must not be - longer than 1024 characters. diff --git a/test/unported/spec-10-09.canonical b/test/unported/spec-10-09.canonical deleted file mode 100644 index 4d9827b1..00000000 --- a/test/unported/spec-10-09.canonical +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "key" - : !!str "value", - ? !!str "empty" - : !!null "", -} diff --git a/test/unported/spec-10-09.data b/test/unported/spec-10-09.data deleted file mode 100644 index 4d55e21d..00000000 --- a/test/unported/spec-10-09.data +++ /dev/null @@ -1,4 +0,0 @@ -{ -key : value, -empty: # empty value↓ -} diff --git a/test/unported/spec-10-10.canonical b/test/unported/spec-10-10.canonical deleted file mode 100644 index 016fb640..00000000 --- a/test/unported/spec-10-10.canonical +++ /dev/null @@ -1,16 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "explicit key1" - : !!str "explicit value", - ? !!str "explicit key2" - : !!null "", - ? !!str "explicit key3" - : !!null "", - ? !!str "simple key1" - : !!str "explicit value", - ? !!str "simple key2" - : !!null "", - ? !!str "simple key3" - : !!null "", -} diff --git a/test/unported/spec-10-10.data b/test/unported/spec-10-10.data deleted file mode 100644 index 0888b054..00000000 --- a/test/unported/spec-10-10.data +++ /dev/null @@ -1,8 +0,0 @@ -{ -? explicit key1 : explicit value, -? explicit key2 : , # Explicit empty -? explicit key3, # Empty value -simple key1 : explicit value, -simple key2 : , # Explicit empty -simple key3, # Empty value -} diff --git a/test/unported/spec-10-11.canonical b/test/unported/spec-10-11.canonical deleted file mode 100644 index 7309544c..00000000 --- a/test/unported/spec-10-11.canonical +++ /dev/null @@ -1,24 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!map { - ? !!str "explicit key1" - : !!str "explicit value", - }, - !!map { - ? !!str "explicit key2" - : !!null "", - }, - !!map { - ? !!str "explicit key3" - : !!null "", - }, - !!map { - ? !!str "simple key1" - : !!str "explicit value", - }, - !!map { - ? !!str "simple key2" - : !!null "", - }, -] diff --git a/test/unported/spec-10-11.data b/test/unported/spec-10-11.data deleted file mode 100644 index 9f055684..00000000 --- a/test/unported/spec-10-11.data +++ /dev/null @@ -1,7 +0,0 @@ -[ -? explicit key1 : explicit value, -? explicit key2 : , # Explicit empty -? explicit key3, # Implicit empty -simple key1 : explicit value, -simple key2 : , # Explicit empty -] diff --git a/test/unported/spec-10-12.canonical b/test/unported/spec-10-12.canonical deleted file mode 100644 index a95dd40c..00000000 --- a/test/unported/spec-10-12.canonical +++ /dev/null @@ -1,9 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "block" - : !!map { - ? !!str "key" - : !!str "value" - } -} diff --git a/test/unported/spec-10-12.data b/test/unported/spec-10-12.data deleted file mode 100644 index 55214435..00000000 --- a/test/unported/spec-10-12.data +++ /dev/null @@ -1,3 +0,0 @@ -block: # Block - # mapping - key: value diff --git a/test/unported/spec-10-13.canonical b/test/unported/spec-10-13.canonical deleted file mode 100644 index e183c50f..00000000 --- a/test/unported/spec-10-13.canonical +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "explicit key" - : !!null "", - ? !!str "block key\n" - : !!seq [ - !!str "one", - !!str "two", - ] -} diff --git a/test/unported/spec-10-13.data b/test/unported/spec-10-13.data deleted file mode 100644 index b5b97db1..00000000 --- a/test/unported/spec-10-13.data +++ /dev/null @@ -1,5 +0,0 @@ -? explicit key # implicit value -? | - block key -: - one # explicit in-line - - two # block value diff --git a/test/unported/spec-10-14.canonical b/test/unported/spec-10-14.canonical deleted file mode 100644 index e87c8805..00000000 --- a/test/unported/spec-10-14.canonical +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 ---- -!!map { - ? !!str "plain key" - : !!null "", - ? !!str "quoted key" - : !!seq [ - !!str "one", - !!str "two", - ] -} diff --git a/test/unported/spec-10-14.data b/test/unported/spec-10-14.data deleted file mode 100644 index 7f5995ca..00000000 --- a/test/unported/spec-10-14.data +++ /dev/null @@ -1,4 +0,0 @@ -plain key: # empty value -"quoted key": -- one # explicit next-line -- two # block value diff --git a/test/unported/spec-10-15.canonical b/test/unported/spec-10-15.canonical deleted file mode 100644 index 85fbbd06..00000000 --- a/test/unported/spec-10-15.canonical +++ /dev/null @@ -1,18 +0,0 @@ -%YAML 1.1 ---- -!!seq [ - !!map { - ? !!str "sun" - : !!str "yellow" - }, - !!map { - ? !!map { - ? !!str "earth" - : !!str "blue" - } - : !!map { - ? !!str "moon" - : !!str "white" - } - } -] diff --git a/test/unported/spec-10-15.data b/test/unported/spec-10-15.data deleted file mode 100644 index d675cfd6..00000000 --- a/test/unported/spec-10-15.data +++ /dev/null @@ -1,3 +0,0 @@ -- sun: yellow -- ? earth: blue - : moon: white diff --git a/test/unported/tags.events b/test/unported/tags.events deleted file mode 100644 index bb93dce1..00000000 --- a/test/unported/tags.events +++ /dev/null @@ -1,12 +0,0 @@ -- !StreamStart -- !DocumentStart -- !SequenceStart -- !Scalar { value: 'data' } -#- !Scalar { tag: '!', value: 'data' } -- !Scalar { tag: 'tag:yaml.org,2002:str', value: 'data' } -- !Scalar { tag: '!myfunnytag', value: 'data' } -- !Scalar { tag: '!my!ugly!tag', value: 'data' } -- !Scalar { tag: 'tag:my.domain.org,2002:data!? #', value: 'data' } -- !SequenceEnd -- !DocumentEnd -- !StreamEnd diff --git a/test/unported/unknown.dumper-error b/test/unported/unknown.dumper-error deleted file mode 100644 index 83204d29..00000000 --- a/test/unported/unknown.dumper-error +++ /dev/null @@ -1 +0,0 @@ -yaml.safe_dump(object) diff --git a/test/unported/unsupported-version.emitter-error b/test/unported/unsupported-version.emitter-error deleted file mode 100644 index f9c61976..00000000 --- a/test/unported/unsupported-version.emitter-error +++ /dev/null @@ -1,5 +0,0 @@ -- !StreamStart -- !DocumentStart { version: [5,6] } -- !Scalar { value: foo } -- !DocumentEnd -- !StreamEnd diff --git a/test/unsupported/bool.detect b/test/unsupported/bool.detect deleted file mode 100644 index 947ebbb9..00000000 --- a/test/unsupported/bool.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:bool diff --git a/test/unsupported/colon-in-flow-context.loader-error b/test/unsupported/colon-in-flow-context.loader-error deleted file mode 100644 index 13d50875..00000000 --- a/test/unsupported/colon-in-flow-context.loader-error +++ /dev/null @@ -1 +0,0 @@ -{ foo:bar } diff --git a/test/unsupported/construct-python-bool.code b/test/unsupported/construct-python-bool.code deleted file mode 100644 index 170da013..00000000 --- a/test/unsupported/construct-python-bool.code +++ /dev/null @@ -1 +0,0 @@ -[ True, False ] diff --git a/test/unsupported/construct-python-bool.data b/test/unsupported/construct-python-bool.data deleted file mode 100644 index 00688696..00000000 --- a/test/unsupported/construct-python-bool.data +++ /dev/null @@ -1 +0,0 @@ -[ !!python/bool True, !!python/bool False ] diff --git a/test/unsupported/construct-python-bytes-py3.code b/test/unsupported/construct-python-bytes-py3.code deleted file mode 100644 index b9051d8d..00000000 --- a/test/unsupported/construct-python-bytes-py3.code +++ /dev/null @@ -1 +0,0 @@ -b'some binary data' diff --git a/test/unsupported/construct-python-bytes-py3.data b/test/unsupported/construct-python-bytes-py3.data deleted file mode 100644 index 95287259..00000000 --- a/test/unsupported/construct-python-bytes-py3.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/bytes 'c29tZSBiaW5hcnkgZGF0YQ==' diff --git a/test/unsupported/construct-python-complex.code b/test/unsupported/construct-python-complex.code deleted file mode 100644 index e582dff2..00000000 --- a/test/unsupported/construct-python-complex.code +++ /dev/null @@ -1 +0,0 @@ -[0.5+0j, 0.5+0.5j, 0.5j, -0.5+0.5j, -0.5+0j, -0.5-0.5j, -0.5j, 0.5-0.5j] diff --git a/test/unsupported/construct-python-complex.data b/test/unsupported/construct-python-complex.data deleted file mode 100644 index 17ebad46..00000000 --- a/test/unsupported/construct-python-complex.data +++ /dev/null @@ -1,8 +0,0 @@ -- !!python/complex 0.5+0j -- !!python/complex 0.5+0.5j -- !!python/complex 0.5j -- !!python/complex -0.5+0.5j -- !!python/complex -0.5+0j -- !!python/complex -0.5-0.5j -- !!python/complex -0.5j -- !!python/complex 0.5-0.5j diff --git a/test/unsupported/construct-python-float.code b/test/unsupported/construct-python-float.code deleted file mode 100644 index d5910a0a..00000000 --- a/test/unsupported/construct-python-float.code +++ /dev/null @@ -1 +0,0 @@ -123.456 diff --git a/test/unsupported/construct-python-float.data b/test/unsupported/construct-python-float.data deleted file mode 100644 index b460eb88..00000000 --- a/test/unsupported/construct-python-float.data +++ /dev/null @@ -1 +0,0 @@ -!!python/float 123.456 diff --git a/test/unsupported/construct-python-int.code b/test/unsupported/construct-python-int.code deleted file mode 100644 index 190a1803..00000000 --- a/test/unsupported/construct-python-int.code +++ /dev/null @@ -1 +0,0 @@ -123 diff --git a/test/unsupported/construct-python-int.data b/test/unsupported/construct-python-int.data deleted file mode 100644 index 741d6698..00000000 --- a/test/unsupported/construct-python-int.data +++ /dev/null @@ -1 +0,0 @@ -!!python/int 123 diff --git a/test/unsupported/construct-python-long-short-py2.code b/test/unsupported/construct-python-long-short-py2.code deleted file mode 100644 index fafc3f15..00000000 --- a/test/unsupported/construct-python-long-short-py2.code +++ /dev/null @@ -1 +0,0 @@ -123L diff --git a/test/unsupported/construct-python-long-short-py2.data b/test/unsupported/construct-python-long-short-py2.data deleted file mode 100644 index 4bd5dc2b..00000000 --- a/test/unsupported/construct-python-long-short-py2.data +++ /dev/null @@ -1 +0,0 @@ -!!python/long 123 diff --git a/test/unsupported/construct-python-long-short-py3.code b/test/unsupported/construct-python-long-short-py3.code deleted file mode 100644 index 190a1803..00000000 --- a/test/unsupported/construct-python-long-short-py3.code +++ /dev/null @@ -1 +0,0 @@ -123 diff --git a/test/unsupported/construct-python-long-short-py3.data b/test/unsupported/construct-python-long-short-py3.data deleted file mode 100644 index 4bd5dc2b..00000000 --- a/test/unsupported/construct-python-long-short-py3.data +++ /dev/null @@ -1 +0,0 @@ -!!python/long 123 diff --git a/test/unsupported/construct-python-name-module.code b/test/unsupported/construct-python-name-module.code deleted file mode 100644 index 6f391488..00000000 --- a/test/unsupported/construct-python-name-module.code +++ /dev/null @@ -1 +0,0 @@ -[str, yaml.Loader, yaml.dump, abs, yaml.tokens] diff --git a/test/unsupported/construct-python-name-module.data b/test/unsupported/construct-python-name-module.data deleted file mode 100644 index f0c9712b..00000000 --- a/test/unsupported/construct-python-name-module.data +++ /dev/null @@ -1,5 +0,0 @@ -- !!python/name:str -- !!python/name:yaml.Loader -- !!python/name:yaml.dump -- !!python/name:abs -- !!python/module:yaml.tokens diff --git a/test/unsupported/construct-python-none.code b/test/unsupported/construct-python-none.code deleted file mode 100644 index b0047fa4..00000000 --- a/test/unsupported/construct-python-none.code +++ /dev/null @@ -1 +0,0 @@ -None diff --git a/test/unsupported/construct-python-none.data b/test/unsupported/construct-python-none.data deleted file mode 100644 index 7907ec3e..00000000 --- a/test/unsupported/construct-python-none.data +++ /dev/null @@ -1 +0,0 @@ -!!python/none diff --git a/test/unsupported/construct-python-object.code b/test/unsupported/construct-python-object.code deleted file mode 100644 index 7f1edf12..00000000 --- a/test/unsupported/construct-python-object.code +++ /dev/null @@ -1,23 +0,0 @@ -[ -AnObject(1, 'two', [3,3,3]), -AnInstance(1, 'two', [3,3,3]), - -AnObject(1, 'two', [3,3,3]), -AnInstance(1, 'two', [3,3,3]), - -AState(1, 'two', [3,3,3]), -ACustomState(1, 'two', [3,3,3]), - -InitArgs(1, 'two', [3,3,3]), -InitArgsWithState(1, 'two', [3,3,3]), - -NewArgs(1, 'two', [3,3,3]), -NewArgsWithState(1, 'two', [3,3,3]), - -Reduce(1, 'two', [3,3,3]), -ReduceWithState(1, 'two', [3,3,3]), - -MyInt(3), -MyList(3), -MyDict(3), -] diff --git a/test/unsupported/construct-python-object.data b/test/unsupported/construct-python-object.data deleted file mode 100644 index bce8b2ed..00000000 --- a/test/unsupported/construct-python-object.data +++ /dev/null @@ -1,21 +0,0 @@ -- !!python/object:test_constructor.AnObject { foo: 1, bar: two, baz: [3,3,3] } -- !!python/object:test_constructor.AnInstance { foo: 1, bar: two, baz: [3,3,3] } - -- !!python/object/new:test_constructor.AnObject { args: [1, two], kwds: {baz: [3,3,3]} } -- !!python/object/apply:test_constructor.AnInstance { args: [1, two], kwds: {baz: [3,3,3]} } - -- !!python/object:test_constructor.AState { _foo: 1, _bar: two, _baz: [3,3,3] } -- !!python/object/new:test_constructor.ACustomState { state: !!python/tuple [1, two, [3,3,3]] } - -- !!python/object/new:test_constructor.InitArgs [1, two, [3,3,3]] -- !!python/object/new:test_constructor.InitArgsWithState { args: [1, two], state: [3,3,3] } - -- !!python/object/new:test_constructor.NewArgs [1, two, [3,3,3]] -- !!python/object/new:test_constructor.NewArgsWithState { args: [1, two], state: [3,3,3] } - -- !!python/object/apply:test_constructor.Reduce [1, two, [3,3,3]] -- !!python/object/apply:test_constructor.ReduceWithState { args: [1, two], state: [3,3,3] } - -- !!python/object/new:test_constructor.MyInt [3] -- !!python/object/new:test_constructor.MyList { listitems: [~, ~, ~] } -- !!python/object/new:test_constructor.MyDict { dictitems: {0, 1, 2} } diff --git a/test/unsupported/construct-python-str-ascii.code b/test/unsupported/construct-python-str-ascii.code deleted file mode 100644 index d9d62f63..00000000 --- a/test/unsupported/construct-python-str-ascii.code +++ /dev/null @@ -1 +0,0 @@ -"ascii string" diff --git a/test/unsupported/construct-python-str-ascii.data b/test/unsupported/construct-python-str-ascii.data deleted file mode 100644 index a83349e2..00000000 --- a/test/unsupported/construct-python-str-ascii.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/str "ascii string" diff --git a/test/unsupported/construct-python-str-utf8-py2.code b/test/unsupported/construct-python-str-utf8-py2.code deleted file mode 100644 index 47b28ab2..00000000 --- a/test/unsupported/construct-python-str-utf8-py2.code +++ /dev/null @@ -1 +0,0 @@ -u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'.encode('utf-8') diff --git a/test/unsupported/construct-python-str-utf8-py2.data b/test/unsupported/construct-python-str-utf8-py2.data deleted file mode 100644 index 9ef2c72e..00000000 --- a/test/unsupported/construct-python-str-utf8-py2.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/str "Это уникодная строка" diff --git a/test/unsupported/construct-python-str-utf8-py3.code b/test/unsupported/construct-python-str-utf8-py3.code deleted file mode 100644 index 9f66032c..00000000 --- a/test/unsupported/construct-python-str-utf8-py3.code +++ /dev/null @@ -1 +0,0 @@ -'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' diff --git a/test/unsupported/construct-python-str-utf8-py3.data b/test/unsupported/construct-python-str-utf8-py3.data deleted file mode 100644 index 9ef2c72e..00000000 --- a/test/unsupported/construct-python-str-utf8-py3.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/str "Это уникодная строка" diff --git a/test/unsupported/construct-python-tuple-list-dict.code b/test/unsupported/construct-python-tuple-list-dict.code deleted file mode 100644 index 20ced988..00000000 --- a/test/unsupported/construct-python-tuple-list-dict.code +++ /dev/null @@ -1,6 +0,0 @@ -[ - [1, 2, 3, 4], - (1, 2, 3, 4), - {1: 2, 3: 4}, - {(0,0): 0, (0,1): 1, (1,0): 1, (1,1): 0}, -] diff --git a/test/unsupported/construct-python-tuple-list-dict.data b/test/unsupported/construct-python-tuple-list-dict.data deleted file mode 100644 index c56159b5..00000000 --- a/test/unsupported/construct-python-tuple-list-dict.data +++ /dev/null @@ -1,8 +0,0 @@ -- !!python/list [1, 2, 3, 4] -- !!python/tuple [1, 2, 3, 4] -- !!python/dict {1: 2, 3: 4} -- !!python/dict - !!python/tuple [0,0]: 0 - !!python/tuple [0,1]: 1 - !!python/tuple [1,0]: 1 - !!python/tuple [1,1]: 0 diff --git a/test/unsupported/construct-python-unicode-ascii-py2.code b/test/unsupported/construct-python-unicode-ascii-py2.code deleted file mode 100644 index d4cd82c6..00000000 --- a/test/unsupported/construct-python-unicode-ascii-py2.code +++ /dev/null @@ -1 +0,0 @@ -u"ascii string" diff --git a/test/unsupported/construct-python-unicode-ascii-py2.data b/test/unsupported/construct-python-unicode-ascii-py2.data deleted file mode 100644 index 3a0647b3..00000000 --- a/test/unsupported/construct-python-unicode-ascii-py2.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/unicode "ascii string" diff --git a/test/unsupported/construct-python-unicode-ascii-py3.code b/test/unsupported/construct-python-unicode-ascii-py3.code deleted file mode 100644 index d9d62f63..00000000 --- a/test/unsupported/construct-python-unicode-ascii-py3.code +++ /dev/null @@ -1 +0,0 @@ -"ascii string" diff --git a/test/unsupported/construct-python-unicode-ascii-py3.data b/test/unsupported/construct-python-unicode-ascii-py3.data deleted file mode 100644 index 3a0647b3..00000000 --- a/test/unsupported/construct-python-unicode-ascii-py3.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/unicode "ascii string" diff --git a/test/unsupported/construct-python-unicode-utf8-py2.code b/test/unsupported/construct-python-unicode-utf8-py2.code deleted file mode 100644 index 2793ac7f..00000000 --- a/test/unsupported/construct-python-unicode-utf8-py2.code +++ /dev/null @@ -1 +0,0 @@ -u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' diff --git a/test/unsupported/construct-python-unicode-utf8-py2.data b/test/unsupported/construct-python-unicode-utf8-py2.data deleted file mode 100644 index 5a980ea0..00000000 --- a/test/unsupported/construct-python-unicode-utf8-py2.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/unicode "Это уникодная строка" diff --git a/test/unsupported/construct-python-unicode-utf8-py3.code b/test/unsupported/construct-python-unicode-utf8-py3.code deleted file mode 100644 index 9f66032c..00000000 --- a/test/unsupported/construct-python-unicode-utf8-py3.code +++ /dev/null @@ -1 +0,0 @@ -'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' diff --git a/test/unsupported/construct-python-unicode-utf8-py3.data b/test/unsupported/construct-python-unicode-utf8-py3.data deleted file mode 100644 index 5a980ea0..00000000 --- a/test/unsupported/construct-python-unicode-utf8-py3.data +++ /dev/null @@ -1 +0,0 @@ ---- !!python/unicode "Это уникодная строка" diff --git a/test/unsupported/duplicate-anchor-1.loader-error b/test/unsupported/duplicate-anchor-1.loader-error deleted file mode 100644 index 906cf29d..00000000 --- a/test/unsupported/duplicate-anchor-1.loader-error +++ /dev/null @@ -1,3 +0,0 @@ -- &foo bar -- &bar bar -- &foo bar diff --git a/test/unsupported/duplicate-anchor-2.loader-error b/test/unsupported/duplicate-anchor-2.loader-error deleted file mode 100644 index 62b43897..00000000 --- a/test/unsupported/duplicate-anchor-2.loader-error +++ /dev/null @@ -1 +0,0 @@ -&foo [1, 2, 3, &foo 4] diff --git a/test/unsupported/duplicate-mapping-key.data b/test/unsupported/duplicate-mapping-key.data deleted file mode 100644 index 7e7b4d13..00000000 --- a/test/unsupported/duplicate-mapping-key.data +++ /dev/null @@ -1,6 +0,0 @@ ---- -&anchor foo: - foo: bar - *anchor: duplicate key - baz: bat - *anchor: duplicate key diff --git a/test/unsupported/empty-python-module.loader-error b/test/unsupported/empty-python-module.loader-error deleted file mode 100644 index 83d3232b..00000000 --- a/test/unsupported/empty-python-module.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python:module: diff --git a/test/unsupported/empty-python-name.loader-error b/test/unsupported/empty-python-name.loader-error deleted file mode 100644 index 61629572..00000000 --- a/test/unsupported/empty-python-name.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/name: empty diff --git a/test/unsupported/float-representer-2.3-bug.code b/test/unsupported/float-representer-2.3-bug.code deleted file mode 100644 index d8db834b..00000000 --- a/test/unsupported/float-representer-2.3-bug.code +++ /dev/null @@ -1,7 +0,0 @@ -{ -# 0.0: 0, - 1.0: 1, - 1e300000: +10, - -1e300000: -10, - 1e300000/1e300000: 100, -} diff --git a/test/unsupported/float-representer-2.3-bug.data b/test/unsupported/float-representer-2.3-bug.data deleted file mode 100644 index efd17163..00000000 --- a/test/unsupported/float-representer-2.3-bug.data +++ /dev/null @@ -1,5 +0,0 @@ -#0.0: # hash(0) == hash(nan) and 0 == nan in Python 2.3 -1.0: 1 -+.inf: 10 --.inf: -10 -.nan: 100 diff --git a/test/unsupported/float.detect b/test/unsupported/float.detect deleted file mode 100644 index 1e12343b..00000000 --- a/test/unsupported/float.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:float diff --git a/test/unsupported/function.detect b/test/unsupported/function.detect deleted file mode 100644 index 54e7fda6..00000000 --- a/test/unsupported/function.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:js/function diff --git a/test/unsupported/int.detect b/test/unsupported/int.detect deleted file mode 100644 index 575c9eb4..00000000 --- a/test/unsupported/int.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:int diff --git a/test/unsupported/invalid-anchor-1.loader-error b/test/unsupported/invalid-anchor-1.loader-error deleted file mode 100644 index fcf7d0f6..00000000 --- a/test/unsupported/invalid-anchor-1.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- &? foo # we allow only ascii and numeric characters in anchor names. diff --git a/test/unsupported/invalid-python-bytes-2-py3.loader-error b/test/unsupported/invalid-python-bytes-2-py3.loader-error deleted file mode 100644 index f43af59e..00000000 --- a/test/unsupported/invalid-python-bytes-2-py3.loader-error +++ /dev/null @@ -1,2 +0,0 @@ ---- !!python/bytes - двоичные данные в base64 diff --git a/test/unsupported/invalid-python-bytes-py3.loader-error b/test/unsupported/invalid-python-bytes-py3.loader-error deleted file mode 100644 index a19dfd0d..00000000 --- a/test/unsupported/invalid-python-bytes-py3.loader-error +++ /dev/null @@ -1,2 +0,0 @@ ---- !!python/bytes - binary data encoded in base64 should be here. diff --git a/test/unsupported/invalid-python-module-kind.loader-error b/test/unsupported/invalid-python-module-kind.loader-error deleted file mode 100644 index 4f71cb55..00000000 --- a/test/unsupported/invalid-python-module-kind.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/module:sys { must, be, scalar } diff --git a/test/unsupported/invalid-python-module-value.loader-error b/test/unsupported/invalid-python-module-value.loader-error deleted file mode 100644 index f6797fc3..00000000 --- a/test/unsupported/invalid-python-module-value.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/module:sys "non-empty value" diff --git a/test/unsupported/invalid-python-module.loader-error b/test/unsupported/invalid-python-module.loader-error deleted file mode 100644 index 4e240728..00000000 --- a/test/unsupported/invalid-python-module.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/module:no.such.module diff --git a/test/unsupported/invalid-python-name-kind.loader-error b/test/unsupported/invalid-python-name-kind.loader-error deleted file mode 100644 index 6ff8eb6b..00000000 --- a/test/unsupported/invalid-python-name-kind.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/name:sys.modules {} diff --git a/test/unsupported/invalid-python-name-module-2.loader-error b/test/unsupported/invalid-python-name-module-2.loader-error deleted file mode 100644 index debc3139..00000000 --- a/test/unsupported/invalid-python-name-module-2.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/name:xml.parsers diff --git a/test/unsupported/invalid-python-name-module.loader-error b/test/unsupported/invalid-python-name-module.loader-error deleted file mode 100644 index 1966f6a2..00000000 --- a/test/unsupported/invalid-python-name-module.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/name:sys.modules.keys diff --git a/test/unsupported/invalid-python-name-object.loader-error b/test/unsupported/invalid-python-name-object.loader-error deleted file mode 100644 index 50f386f2..00000000 --- a/test/unsupported/invalid-python-name-object.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/name:os.path.rm_rf diff --git a/test/unsupported/invalid-python-name-value.loader-error b/test/unsupported/invalid-python-name-value.loader-error deleted file mode 100644 index 7be1401e..00000000 --- a/test/unsupported/invalid-python-name-value.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !!python/name:sys.modules 5 diff --git a/test/unsupported/invalid-tag-1.loader-error b/test/unsupported/invalid-tag-1.loader-error deleted file mode 100644 index a68cd384..00000000 --- a/test/unsupported/invalid-tag-1.loader-error +++ /dev/null @@ -1 +0,0 @@ -- ! baz diff --git a/test/unsupported/invalid-tag-directive-prefix.loader-error b/test/unsupported/invalid-tag-directive-prefix.loader-error deleted file mode 100644 index 0cb482c9..00000000 --- a/test/unsupported/invalid-tag-directive-prefix.loader-error +++ /dev/null @@ -1,2 +0,0 @@ -%TAG ! tag:zz.com/foo#bar # '#' is not allowed in URLs ---- diff --git a/test/unsupported/invalid-uri-escapes-2.loader-error b/test/unsupported/invalid-uri-escapes-2.loader-error deleted file mode 100644 index b89e8f6a..00000000 --- a/test/unsupported/invalid-uri-escapes-2.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !<%FF> foo diff --git a/test/unsupported/invalid-uri-escapes-3.loader-error b/test/unsupported/invalid-uri-escapes-3.loader-error deleted file mode 100644 index f2e4cb82..00000000 --- a/test/unsupported/invalid-uri-escapes-3.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- ! baz diff --git a/test/unsupported/merge.detect b/test/unsupported/merge.detect deleted file mode 100644 index 1672d0d9..00000000 --- a/test/unsupported/merge.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:merge diff --git a/test/unsupported/null.detect b/test/unsupported/null.detect deleted file mode 100644 index 19110c7c..00000000 --- a/test/unsupported/null.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:null diff --git a/test/unsupported/odd-utf16.stream-error b/test/unsupported/odd-utf16.stream-error deleted file mode 100644 index b59e4344..00000000 Binary files a/test/unsupported/odd-utf16.stream-error and /dev/null differ diff --git a/test/unsupported/spec-02-01.structure b/test/unsupported/spec-02-01.structure deleted file mode 100644 index 601ef4cf..00000000 --- a/test/unsupported/spec-02-01.structure +++ /dev/null @@ -1 +0,0 @@ -[true, true, true] diff --git a/test/unsupported/spec-02-01.tokens b/test/unsupported/spec-02-01.tokens deleted file mode 100644 index ce44caca..00000000 --- a/test/unsupported/spec-02-01.tokens +++ /dev/null @@ -1 +0,0 @@ -[[ , _ , _ , _ ]} diff --git a/test/unsupported/spec-02-02.structure b/test/unsupported/spec-02-02.structure deleted file mode 100644 index 50892071..00000000 --- a/test/unsupported/spec-02-02.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-02.tokens b/test/unsupported/spec-02-02.tokens deleted file mode 100644 index e4e381b4..00000000 --- a/test/unsupported/spec-02-02.tokens +++ /dev/null @@ -1,5 +0,0 @@ -{{ -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-03.structure b/test/unsupported/spec-02-03.structure deleted file mode 100644 index 13d1d2d6..00000000 --- a/test/unsupported/spec-02-03.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, [true, true, true]], [true, [true, true, true]]] diff --git a/test/unsupported/spec-02-03.tokens b/test/unsupported/spec-02-03.tokens deleted file mode 100644 index 89815f29..00000000 --- a/test/unsupported/spec-02-03.tokens +++ /dev/null @@ -1,4 +0,0 @@ -{{ -? _ : [[ , _ , _ , _ ]} -? _ : [[ , _ , _ , _ ]} -]} diff --git a/test/unsupported/spec-02-04.structure b/test/unsupported/spec-02-04.structure deleted file mode 100644 index f1870b3d..00000000 --- a/test/unsupported/spec-02-04.structure +++ /dev/null @@ -1,4 +0,0 @@ -[ - [[true, true], [true, true], [true, true]], - [[true, true], [true, true], [true, true]] -] diff --git a/test/unsupported/spec-02-04.tokens b/test/unsupported/spec-02-04.tokens deleted file mode 100644 index 9cb98156..00000000 --- a/test/unsupported/spec-02-04.tokens +++ /dev/null @@ -1,4 +0,0 @@ -[[ -, {{ ? _ : _ ? _ : _ ? _ : _ ]} -, {{ ? _ : _ ? _ : _ ? _ : _ ]} -]} diff --git a/test/unsupported/spec-02-05.structure b/test/unsupported/spec-02-05.structure deleted file mode 100644 index fe1e058a..00000000 --- a/test/unsupported/spec-02-05.structure +++ /dev/null @@ -1,5 +0,0 @@ -[ - [true, true, true], - [true, true, true], - [true, true, true] -] diff --git a/test/unsupported/spec-02-05.tokens b/test/unsupported/spec-02-05.tokens deleted file mode 100644 index 3f6f1ab5..00000000 --- a/test/unsupported/spec-02-05.tokens +++ /dev/null @@ -1,5 +0,0 @@ -[[ -, [ _ , _ , _ ] -, [ _ , _ , _ ] -, [ _ , _ , _ ] -]} diff --git a/test/unsupported/spec-02-06.structure b/test/unsupported/spec-02-06.structure deleted file mode 100644 index 7d107115..00000000 --- a/test/unsupported/spec-02-06.structure +++ /dev/null @@ -1,4 +0,0 @@ -[ - [true, [[true, true], [true, true]]], - [true, [[true, true], [true, true]]] -] diff --git a/test/unsupported/spec-02-06.tokens b/test/unsupported/spec-02-06.tokens deleted file mode 100644 index a1a5eef2..00000000 --- a/test/unsupported/spec-02-06.tokens +++ /dev/null @@ -1,4 +0,0 @@ -{{ -? _ : { ? _ : _ , ? _ : _ } -? _ : { ? _ : _ , ? _ : _ } -]} diff --git a/test/unsupported/spec-02-07.structure b/test/unsupported/spec-02-07.structure deleted file mode 100644 index 73457a81..00000000 --- a/test/unsupported/spec-02-07.structure +++ /dev/null @@ -1,4 +0,0 @@ -[ -[true, true, true], -[true, true] -] diff --git a/test/unsupported/spec-02-07.tokens b/test/unsupported/spec-02-07.tokens deleted file mode 100644 index ed48883c..00000000 --- a/test/unsupported/spec-02-07.tokens +++ /dev/null @@ -1,12 +0,0 @@ ---- -[[ -, _ -, _ -, _ -]} - ---- -[[ -, _ -, _ -]} diff --git a/test/unsupported/spec-02-08.structure b/test/unsupported/spec-02-08.structure deleted file mode 100644 index cb95786a..00000000 --- a/test/unsupported/spec-02-08.structure +++ /dev/null @@ -1,4 +0,0 @@ -[ -[[true, true], [true, true], [true, true]], -[[true, true], [true, true], [true, true]] -] diff --git a/test/unsupported/spec-02-08.tokens b/test/unsupported/spec-02-08.tokens deleted file mode 100644 index 7d2c03df..00000000 --- a/test/unsupported/spec-02-08.tokens +++ /dev/null @@ -1,15 +0,0 @@ ---- -{{ -? _ : _ -? _ : _ -? _ : _ -]} -... - ---- -{{ -? _ : _ -? _ : _ -? _ : _ -]} -... diff --git a/test/unsupported/spec-02-09.structure b/test/unsupported/spec-02-09.structure deleted file mode 100644 index 231fd207..00000000 --- a/test/unsupported/spec-02-09.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, [true, true]], [true, [true, true]]] diff --git a/test/unsupported/spec-02-09.tokens b/test/unsupported/spec-02-09.tokens deleted file mode 100644 index b2ec10ea..00000000 --- a/test/unsupported/spec-02-09.tokens +++ /dev/null @@ -1,5 +0,0 @@ ---- -{{ -? _ : [[ , _ , _ ]} -? _ : [[ , _ , _ ]} -]} diff --git a/test/unsupported/spec-02-10.structure b/test/unsupported/spec-02-10.structure deleted file mode 100644 index d09f5bbf..00000000 --- a/test/unsupported/spec-02-10.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, [true, true]], [true, ["*", true]]] diff --git a/test/unsupported/spec-02-10.tokens b/test/unsupported/spec-02-10.tokens deleted file mode 100644 index 26caa2b1..00000000 --- a/test/unsupported/spec-02-10.tokens +++ /dev/null @@ -1,5 +0,0 @@ ---- -{{ -? _ : [[ , _ , & _ ]} -? _ : [[ , * , _ ]} -]} diff --git a/test/unsupported/spec-02-11.structure b/test/unsupported/spec-02-11.structure deleted file mode 100644 index 9b473993..00000000 --- a/test/unsupported/spec-02-11.structure +++ /dev/null @@ -1,4 +0,0 @@ -[ -[[true, true], [true]], -[[true, true], [true, true, true]] -] diff --git a/test/unsupported/spec-02-11.tokens b/test/unsupported/spec-02-11.tokens deleted file mode 100644 index fe242033..00000000 --- a/test/unsupported/spec-02-11.tokens +++ /dev/null @@ -1,6 +0,0 @@ -{{ -? [[ , _ , _ ]} -: [[ , _ ]} -? [ _ , _ ] -: [ _ , _ , _ ] -]} diff --git a/test/unsupported/spec-02-12.structure b/test/unsupported/spec-02-12.structure deleted file mode 100644 index 402284a7..00000000 --- a/test/unsupported/spec-02-12.structure +++ /dev/null @@ -1,5 +0,0 @@ -[ -[[true, true], [true, true]], -[[true, true], [true, true]], -[[true, true], [true, true]] -] diff --git a/test/unsupported/spec-02-12.tokens b/test/unsupported/spec-02-12.tokens deleted file mode 100644 index ea21e506..00000000 --- a/test/unsupported/spec-02-12.tokens +++ /dev/null @@ -1,6 +0,0 @@ ---- -[[ -, {{ ? _ : _ ? _ : _ ]} -, {{ ? _ : _ ? _ : _ ]} -, {{ ? _ : _ ? _ : _ ]} -]} diff --git a/test/unsupported/spec-02-13.structure b/test/unsupported/spec-02-13.structure deleted file mode 100644 index 27ba77dd..00000000 --- a/test/unsupported/spec-02-13.structure +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/test/unsupported/spec-02-13.tokens b/test/unsupported/spec-02-13.tokens deleted file mode 100644 index 7456c055..00000000 --- a/test/unsupported/spec-02-13.tokens +++ /dev/null @@ -1 +0,0 @@ ---- _ diff --git a/test/unsupported/spec-02-14.structure b/test/unsupported/spec-02-14.structure deleted file mode 100644 index 27ba77dd..00000000 --- a/test/unsupported/spec-02-14.structure +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/test/unsupported/spec-02-14.tokens b/test/unsupported/spec-02-14.tokens deleted file mode 100644 index 7456c055..00000000 --- a/test/unsupported/spec-02-14.tokens +++ /dev/null @@ -1 +0,0 @@ ---- _ diff --git a/test/unsupported/spec-02-15.structure b/test/unsupported/spec-02-15.structure deleted file mode 100644 index 27ba77dd..00000000 --- a/test/unsupported/spec-02-15.structure +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/test/unsupported/spec-02-15.tokens b/test/unsupported/spec-02-15.tokens deleted file mode 100644 index 31354ec1..00000000 --- a/test/unsupported/spec-02-15.tokens +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/test/unsupported/spec-02-16.structure b/test/unsupported/spec-02-16.structure deleted file mode 100644 index 50892071..00000000 --- a/test/unsupported/spec-02-16.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-16.tokens b/test/unsupported/spec-02-16.tokens deleted file mode 100644 index e4e381b4..00000000 --- a/test/unsupported/spec-02-16.tokens +++ /dev/null @@ -1,5 +0,0 @@ -{{ -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-17.structure b/test/unsupported/spec-02-17.structure deleted file mode 100644 index 951f95bb..00000000 --- a/test/unsupported/spec-02-17.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true], [true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-17.tokens b/test/unsupported/spec-02-17.tokens deleted file mode 100644 index db655402..00000000 --- a/test/unsupported/spec-02-17.tokens +++ /dev/null @@ -1,8 +0,0 @@ -{{ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-18.structure b/test/unsupported/spec-02-18.structure deleted file mode 100644 index e328e442..00000000 --- a/test/unsupported/spec-02-18.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true]] diff --git a/test/unsupported/spec-02-18.tokens b/test/unsupported/spec-02-18.tokens deleted file mode 100644 index 83b31dc0..00000000 --- a/test/unsupported/spec-02-18.tokens +++ /dev/null @@ -1,4 +0,0 @@ -{{ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-19.structure b/test/unsupported/spec-02-19.structure deleted file mode 100644 index 1de65f81..00000000 --- a/test/unsupported/spec-02-19.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-19.tokens b/test/unsupported/spec-02-19.tokens deleted file mode 100644 index 5bda68f4..00000000 --- a/test/unsupported/spec-02-19.tokens +++ /dev/null @@ -1,7 +0,0 @@ -{{ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-20.structure b/test/unsupported/spec-02-20.structure deleted file mode 100644 index 951f95bb..00000000 --- a/test/unsupported/spec-02-20.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true], [true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-20.tokens b/test/unsupported/spec-02-20.tokens deleted file mode 100644 index db655402..00000000 --- a/test/unsupported/spec-02-20.tokens +++ /dev/null @@ -1,8 +0,0 @@ -{{ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-21.structure b/test/unsupported/spec-02-21.structure deleted file mode 100644 index 218b72e2..00000000 --- a/test/unsupported/spec-02-21.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-21.tokens b/test/unsupported/spec-02-21.tokens deleted file mode 100644 index aeccbaf6..00000000 --- a/test/unsupported/spec-02-21.tokens +++ /dev/null @@ -1,6 +0,0 @@ -{{ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-22.structure b/test/unsupported/spec-02-22.structure deleted file mode 100644 index 218b72e2..00000000 --- a/test/unsupported/spec-02-22.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-22.tokens b/test/unsupported/spec-02-22.tokens deleted file mode 100644 index aeccbaf6..00000000 --- a/test/unsupported/spec-02-22.tokens +++ /dev/null @@ -1,6 +0,0 @@ -{{ -? _ : _ -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-23.structure b/test/unsupported/spec-02-23.structure deleted file mode 100644 index 50892071..00000000 --- a/test/unsupported/spec-02-23.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, true], [true, true], [true, true]] diff --git a/test/unsupported/spec-02-23.tokens b/test/unsupported/spec-02-23.tokens deleted file mode 100644 index 9ac54aad..00000000 --- a/test/unsupported/spec-02-23.tokens +++ /dev/null @@ -1,6 +0,0 @@ ---- -{{ -? _ : ! _ -? _ : ! _ -? _ : ! _ -]} diff --git a/test/unsupported/spec-02-24.structure b/test/unsupported/spec-02-24.structure deleted file mode 100644 index 9bb935dd..00000000 --- a/test/unsupported/spec-02-24.structure +++ /dev/null @@ -1,5 +0,0 @@ -[ -[[true, [[true, true], [true, true]]], [true, true]], -[[true, "*"], [true, [[true, true], [true, true]]]], -[[true, "*"], [true, true], [true, true]] -] diff --git a/test/unsupported/spec-02-24.tokens b/test/unsupported/spec-02-24.tokens deleted file mode 100644 index 039c3857..00000000 --- a/test/unsupported/spec-02-24.tokens +++ /dev/null @@ -1,20 +0,0 @@ -% ---- ! -[[ -, ! - {{ - ? _ : & { ? _ : _ , ? _ : _ } - ? _ : _ - ]} -, ! - {{ - ? _ : * - ? _ : { ? _ : _ , ? _ : _ } - ]} -, ! - {{ - ? _ : * - ? _ : _ - ? _ : _ - ]} -]} diff --git a/test/unsupported/spec-02-25.structure b/test/unsupported/spec-02-25.structure deleted file mode 100644 index a8054a69..00000000 --- a/test/unsupported/spec-02-25.structure +++ /dev/null @@ -1 +0,0 @@ -[[true, false], [true, false], [true, false]] diff --git a/test/unsupported/spec-02-25.tokens b/test/unsupported/spec-02-25.tokens deleted file mode 100644 index b7002368..00000000 --- a/test/unsupported/spec-02-25.tokens +++ /dev/null @@ -1,6 +0,0 @@ ---- ! -{{ -? _ -? _ -? _ -]} diff --git a/test/unsupported/spec-02-26.structure b/test/unsupported/spec-02-26.structure deleted file mode 100644 index 98bb243f..00000000 --- a/test/unsupported/spec-02-26.structure +++ /dev/null @@ -1,5 +0,0 @@ -[ -[[true, true]], -[[true, true]], -[[true, true]] -] diff --git a/test/unsupported/spec-02-26.tokens b/test/unsupported/spec-02-26.tokens deleted file mode 100644 index 7bee4920..00000000 --- a/test/unsupported/spec-02-26.tokens +++ /dev/null @@ -1,6 +0,0 @@ ---- ! -[[ -, {{ ? _ : _ ]} -, {{ ? _ : _ ]} -, {{ ? _ : _ ]} -]} diff --git a/test/unsupported/spec-02-27.structure b/test/unsupported/spec-02-27.structure deleted file mode 100644 index 805f140a..00000000 --- a/test/unsupported/spec-02-27.structure +++ /dev/null @@ -1,17 +0,0 @@ -[ -[true, true], -[true, true], -[true, [ - [true, true], - [true, true], - [true, [[true, true], [true, true], [true, true], [true, true]]] - ]], -[true, "*"], -[true, [ - [[true, true], [true, true], [true, true], [true, true]], - [[true, true], [true, true], [true, true], [true, true]] - ]], -[true, true], -[true, true], -[true, true] -] diff --git a/test/unsupported/spec-02-27.tokens b/test/unsupported/spec-02-27.tokens deleted file mode 100644 index 2dc1c25d..00000000 --- a/test/unsupported/spec-02-27.tokens +++ /dev/null @@ -1,20 +0,0 @@ ---- ! -{{ -? _ : _ -? _ : _ -? _ : & - {{ - ? _ : _ - ? _ : _ - ? _ : {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} - ]} -? _ : * -? _ : - [[ - , {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} - , {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} - ]} -? _ : _ -? _ : _ -? _ : _ -]} diff --git a/test/unsupported/spec-02-28.structure b/test/unsupported/spec-02-28.structure deleted file mode 100644 index 21a1b7c8..00000000 --- a/test/unsupported/spec-02-28.structure +++ /dev/null @@ -1,10 +0,0 @@ -[ -[[true, true], [true, true], [true, true]], -[[true, true], [true, true], [true, true]], -[[true, true], [true, true], [true, true], -[true, [ - [[true, true], [true, true], [true, true]], - [[true, true], [true, true], [true, true]] - ]] -] -] diff --git a/test/unsupported/spec-02-28.tokens b/test/unsupported/spec-02-28.tokens deleted file mode 100644 index 8d5e1bc5..00000000 --- a/test/unsupported/spec-02-28.tokens +++ /dev/null @@ -1,23 +0,0 @@ ---- -{{ -? _ : _ -? _ : _ -? _ : _ -]} ---- -{{ -? _ : _ -? _ : _ -? _ : _ -]} ---- -{{ -? _ : _ -? _ : _ -? _ : _ -? _ : - [[ - , {{ ? _ : _ ? _ : _ ? _ : _ ]} - , {{ ? _ : _ ? _ : _ ? _ : _ ]} - ]} -]} diff --git a/test/unsupported/spec-05-01-utf16be.data b/test/unsupported/spec-05-01-utf16be.data deleted file mode 100644 index 35250629..00000000 Binary files a/test/unsupported/spec-05-01-utf16be.data and /dev/null differ diff --git a/test/unsupported/spec-05-01-utf16be.empty b/test/unsupported/spec-05-01-utf16be.empty deleted file mode 100644 index bfffa8b6..00000000 --- a/test/unsupported/spec-05-01-utf16be.empty +++ /dev/null @@ -1,2 +0,0 @@ -# This stream contains no -# documents, only comments. diff --git a/test/unsupported/spec-05-01-utf16le.data b/test/unsupported/spec-05-01-utf16le.data deleted file mode 100644 index 0823f749..00000000 Binary files a/test/unsupported/spec-05-01-utf16le.data and /dev/null differ diff --git a/test/unsupported/spec-05-01-utf16le.empty b/test/unsupported/spec-05-01-utf16le.empty deleted file mode 100644 index bfffa8b6..00000000 --- a/test/unsupported/spec-05-01-utf16le.empty +++ /dev/null @@ -1,2 +0,0 @@ -# This stream contains no -# documents, only comments. diff --git a/test/unsupported/spec-05-02-utf16be.data b/test/unsupported/spec-05-02-utf16be.data deleted file mode 100644 index 5ebbb04e..00000000 Binary files a/test/unsupported/spec-05-02-utf16be.data and /dev/null differ diff --git a/test/unsupported/spec-05-02-utf16be.error b/test/unsupported/spec-05-02-utf16be.error deleted file mode 100644 index 1df36161..00000000 --- a/test/unsupported/spec-05-02-utf16be.error +++ /dev/null @@ -1,3 +0,0 @@ -ERROR: - A BOM must not appear - inside a document. diff --git a/test/unsupported/spec-05-02-utf16le.data b/test/unsupported/spec-05-02-utf16le.data deleted file mode 100644 index 0cd90a2b..00000000 Binary files a/test/unsupported/spec-05-02-utf16le.data and /dev/null differ diff --git a/test/unsupported/spec-05-02-utf16le.error b/test/unsupported/spec-05-02-utf16le.error deleted file mode 100644 index 1df36161..00000000 --- a/test/unsupported/spec-05-02-utf16le.error +++ /dev/null @@ -1,3 +0,0 @@ -ERROR: - A BOM must not appear - inside a document. diff --git a/test/unsupported/str.detect b/test/unsupported/str.detect deleted file mode 100644 index 7d5026f4..00000000 --- a/test/unsupported/str.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:str diff --git a/test/unsupported/timestamp.detect b/test/unsupported/timestamp.detect deleted file mode 100644 index 2013936a..00000000 --- a/test/unsupported/timestamp.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:timestamp diff --git a/test/unsupported/undefined-constructor.loader-error b/test/unsupported/undefined-constructor.loader-error deleted file mode 100644 index 9a37ccc9..00000000 --- a/test/unsupported/undefined-constructor.loader-error +++ /dev/null @@ -1 +0,0 @@ ---- !foo bar diff --git a/test/unsupported/utf16be.code b/test/unsupported/utf16be.code deleted file mode 100644 index c45b3719..00000000 --- a/test/unsupported/utf16be.code +++ /dev/null @@ -1 +0,0 @@ -"UTF-16-BE" diff --git a/test/unsupported/utf16be.data b/test/unsupported/utf16be.data deleted file mode 100644 index 50dcfaef..00000000 Binary files a/test/unsupported/utf16be.data and /dev/null differ diff --git a/test/unsupported/utf16le.code b/test/unsupported/utf16le.code deleted file mode 100644 index 400530a0..00000000 --- a/test/unsupported/utf16le.code +++ /dev/null @@ -1 +0,0 @@ -"UTF-16-LE" diff --git a/test/unsupported/utf16le.data b/test/unsupported/utf16le.data deleted file mode 100644 index 76f5e734..00000000 Binary files a/test/unsupported/utf16le.data and /dev/null differ diff --git a/test/unsupported/value.data b/test/unsupported/value.data deleted file mode 100644 index c5b7680c..00000000 --- a/test/unsupported/value.data +++ /dev/null @@ -1 +0,0 @@ -- = diff --git a/test/unsupported/value.detect b/test/unsupported/value.detect deleted file mode 100644 index 7c37d028..00000000 --- a/test/unsupported/value.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:value diff --git a/test/unsupported/yaml.data b/test/unsupported/yaml.data deleted file mode 100644 index a4bb3f8e..00000000 --- a/test/unsupported/yaml.data +++ /dev/null @@ -1,3 +0,0 @@ -- !!yaml '!' -- !!yaml '&' -- !!yaml '*' diff --git a/test/unsupported/yaml.detect b/test/unsupported/yaml.detect deleted file mode 100644 index e2cf1891..00000000 --- a/test/unsupported/yaml.detect +++ /dev/null @@ -1 +0,0 @@ -tag:yaml.org,2002:yaml