Comparing version 1.10.0 to 1.10.2
@@ -1,6 +0,6 @@ | ||
import { d as defaultTagPrefix, _ as _createForOfIteratorHelper, a as _typeof, b as _createClass, c as _classCallCheck, e as _defineProperty, Y as YAMLSyntaxError, T as Type, f as YAMLWarning, g as YAMLSemanticError, h as _slicedToArray, i as YAMLError, j as _inherits, k as _createSuper } from './PlainValue-ff5147c6.js'; | ||
import { d as defaultTagPrefix, _ as _createForOfIteratorHelper, a as _typeof, b as _createClass, c as _classCallCheck, e as _defineProperty, Y as YAMLSyntaxError, T as Type, f as YAMLWarning, g as YAMLSemanticError, h as _slicedToArray, i as YAMLError, j as _inherits, k as _createSuper } from './PlainValue-b8036b75.js'; | ||
import { parse as parse$1 } from './parse-cst.js'; | ||
import { b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions, N as Node, P as Pair, S as Scalar, c as stringifyString, A as Alias, Y as YAMLSeq, d as YAMLMap, M as Merge, C as Collection, r as resolveNode, e as isEmptyPath, t as toJSON, f as addComment } from './resolveSeq-04825f30.js'; | ||
import { S as Schema } from './Schema-2bf2c74e.js'; | ||
import { w as warn } from './warnings-0e4b70d3.js'; | ||
import { b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions, N as Node, P as Pair, S as Scalar, c as stringifyString, A as Alias, Y as YAMLSeq, d as YAMLMap, M as Merge, C as Collection, r as resolveNode, e as isEmptyPath, t as toJSON, f as addComment } from './resolveSeq-492ab440.js'; | ||
import { S as Schema } from './Schema-e94716c8.js'; | ||
import { w as warn } from './warnings-df54cb69.js'; | ||
@@ -76,3 +76,3 @@ var defaultOptions = { | ||
}, | ||
'1.1': { | ||
1.1: { | ||
schema: 'yaml-1.1', | ||
@@ -88,3 +88,3 @@ merge: true, | ||
}, | ||
'1.2': { | ||
1.2: { | ||
schema: 'core', | ||
@@ -197,3 +197,3 @@ merge: false, | ||
function stringify(item, ctx, onComment, onChompKeep) { | ||
function stringify$1(item, ctx, onComment, onChompKeep) { | ||
var _ctx$doc = ctx.doc, | ||
@@ -245,13 +245,6 @@ anchors = _ctx$doc.anchors, | ||
var Anchors = /*#__PURE__*/function () { | ||
_createClass(Anchors, null, [{ | ||
key: "validAnchorNode", | ||
value: function validAnchorNode(node) { | ||
return node instanceof Scalar || node instanceof YAMLSeq || node instanceof YAMLMap; | ||
} | ||
}]); | ||
function Anchors(prefix) { | ||
_classCallCheck(this, Anchors); | ||
_defineProperty(this, "map", {}); | ||
_defineProperty(this, "map", Object.create(null)); | ||
@@ -368,2 +361,7 @@ this.prefix = prefix; | ||
} | ||
}], [{ | ||
key: "validAnchorNode", | ||
value: function validAnchorNode(node) { | ||
return node instanceof Scalar || node instanceof YAMLSeq || node instanceof YAMLMap; | ||
} | ||
}]); | ||
@@ -589,3 +587,3 @@ | ||
var Document = /*#__PURE__*/function () { | ||
var Document$1 = /*#__PURE__*/function () { | ||
function Document(options) { | ||
@@ -795,3 +793,3 @@ _classCallCheck(this, Document); | ||
maxAliasCount: maxAliasCount, | ||
stringify: stringify // Requiring directly in Pair would create circular dependencies | ||
stringify: stringify$1 // Requiring directly in Pair would create circular dependencies | ||
@@ -876,7 +874,7 @@ }; | ||
var ctx = { | ||
anchors: {}, | ||
anchors: Object.create(null), | ||
doc: this, | ||
indent: '', | ||
indentStep: ' '.repeat(indentSize), | ||
stringify: stringify // Requiring directly in nodes would create circular dependencies | ||
stringify: stringify$1 // Requiring directly in nodes would create circular dependencies | ||
@@ -899,3 +897,3 @@ }; | ||
}; | ||
var body = stringify(this.contents, ctx, function () { | ||
var body = stringify$1(this.contents, ctx, function () { | ||
return contentComment = null; | ||
@@ -905,3 +903,3 @@ }, onChompKeep); | ||
} else if (this.contents !== undefined) { | ||
lines.push(stringify(this.contents, ctx)); | ||
lines.push(stringify$1(this.contents, ctx)); | ||
} | ||
@@ -921,3 +919,3 @@ | ||
_defineProperty(Document, "defaults", documentOptions); | ||
_defineProperty(Document$1, "defaults", documentOptions); | ||
@@ -933,3 +931,3 @@ function createNode(value) { | ||
var options = Object.assign({}, Document.defaults[defaultOptions.version], defaultOptions); | ||
var options = Object.assign({}, Document$1.defaults[defaultOptions.version], defaultOptions); | ||
var schema = new Schema(options); | ||
@@ -939,3 +937,3 @@ return schema.createNode(value, wrapScalars, tag); | ||
var Document$1 = /*#__PURE__*/function (_YAMLDocument) { | ||
var Document = /*#__PURE__*/function (_YAMLDocument) { | ||
_inherits(Document, _YAMLDocument); | ||
@@ -952,3 +950,3 @@ | ||
return Document; | ||
}(Document); | ||
}(Document$1); | ||
@@ -965,3 +963,3 @@ function parseAllDocuments(src, options) { | ||
var cstDoc = _step.value; | ||
var doc = new Document$1(options); | ||
var doc = new Document(options); | ||
doc.parse(cstDoc, prev); | ||
@@ -982,3 +980,3 @@ stream.push(doc); | ||
var cst = parse$1(src); | ||
var doc = new Document$1(options).parse(cst[0]); | ||
var doc = new Document(options).parse(cst[0]); | ||
@@ -1002,4 +1000,4 @@ if (cst.length > 1) { | ||
function stringify$1(value, options) { | ||
var doc = new Document$1(options); | ||
function stringify(value, options) { | ||
var doc = new Document(options); | ||
doc.contents = value; | ||
@@ -1012,3 +1010,3 @@ return String(doc); | ||
defaultOptions: defaultOptions, | ||
Document: Document$1, | ||
Document: Document, | ||
parse: parse, | ||
@@ -1019,5 +1017,5 @@ parseAllDocuments: parseAllDocuments, | ||
scalarOptions: scalarOptions, | ||
stringify: stringify$1 | ||
stringify: stringify | ||
}; | ||
export { YAML }; |
@@ -1,3 +0,3 @@ | ||
import './PlainValue-ff5147c6.js'; | ||
import './resolveSeq-04825f30.js'; | ||
export { b as binary, f as floatTime, i as intTime, o as omap, p as pairs, s as set, t as timestamp, c as warnFileDeprecation } from './warnings-0e4b70d3.js'; | ||
export { b as binary, f as floatTime, i as intTime, o as omap, p as pairs, s as set, t as timestamp, c as warnFileDeprecation } from './warnings-df54cb69.js'; | ||
import './PlainValue-b8036b75.js'; | ||
import './resolveSeq-492ab440.js'; |
@@ -1,2 +0,2 @@ | ||
import { j as _inherits, k as _createSuper, c as _classCallCheck, T as Type, b as _createClass, R as Range, N as Node, g as YAMLSemanticError, l as _get, m as _getPrototypeOf, Y as YAMLSyntaxError, C as Char, e as _defineProperty, P as PlainValue } from './PlainValue-ff5147c6.js'; | ||
import { j as _inherits, k as _createSuper, c as _classCallCheck, T as Type, b as _createClass, R as Range, N as Node, g as YAMLSemanticError, l as _get, m as _getPrototypeOf, Y as YAMLSyntaxError, C as Char, e as _defineProperty, P as PlainValue } from './PlainValue-b8036b75.js'; | ||
@@ -17,4 +17,8 @@ var BlankLine = /*#__PURE__*/function (_Node) { | ||
_createClass(BlankLine, [{ | ||
key: "parse", | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
// This is never called from anywhere, but if it were, | ||
// this is the value it should return. | ||
return true; | ||
} | ||
/** | ||
@@ -27,2 +31,5 @@ * Parses a blank line from the source | ||
*/ | ||
}, { | ||
key: "parse", | ||
value: function parse(context, start) { | ||
@@ -33,9 +40,2 @@ this.context = context; | ||
} | ||
}, { | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
// This is never called from anywhere, but if it were, | ||
// this is the value it should return. | ||
return true; | ||
} | ||
}]); | ||
@@ -62,4 +62,6 @@ | ||
_createClass(CollectionItem, [{ | ||
key: "parse", | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
return !!this.node && this.node.includesTrailingLines; | ||
} | ||
/** | ||
@@ -70,2 +72,5 @@ * @param {ParseContext} context | ||
*/ | ||
}, { | ||
key: "parse", | ||
value: function parse(context, start) { | ||
@@ -163,7 +168,2 @@ this.context = context; | ||
} | ||
}, { | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
return !!this.node && this.node.includesTrailingLines; | ||
} | ||
}]); | ||
@@ -248,15 +248,2 @@ | ||
_createClass(Collection, null, [{ | ||
key: "nextContentHasIndent", | ||
value: function nextContentHasIndent(src, offset, indent) { | ||
var lineStart = Node.endOfLine(src, offset) + 1; | ||
offset = Node.endOfWhiteSpace(src, lineStart); | ||
var ch = src[offset]; | ||
if (!ch) return false; | ||
if (offset >= lineStart + indent) return true; | ||
if (ch !== '#' && ch !== '\n') return false; | ||
return Collection.nextContentHasIndent(src, offset, indent); | ||
} | ||
}]); | ||
function Collection(firstItem) { | ||
@@ -287,4 +274,6 @@ var _this; | ||
_createClass(Collection, [{ | ||
key: "parse", | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
return this.items.length > 0; | ||
} | ||
/** | ||
@@ -295,2 +284,5 @@ * @param {ParseContext} context | ||
*/ | ||
}, { | ||
key: "parse", | ||
value: function parse(context, start) { | ||
@@ -466,6 +458,12 @@ this.context = context; | ||
} | ||
}, { | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
return this.items.length > 0; | ||
}], [{ | ||
key: "nextContentHasIndent", | ||
value: function nextContentHasIndent(src, offset, indent) { | ||
var lineStart = Node.endOfLine(src, offset) + 1; | ||
offset = Node.endOfWhiteSpace(src, lineStart); | ||
var ch = src[offset]; | ||
if (!ch) return false; | ||
if (offset >= lineStart + indent) return true; | ||
if (ch !== '#' && ch !== '\n') return false; | ||
return Collection.nextContentHasIndent(src, offset, indent); | ||
} | ||
@@ -493,2 +491,8 @@ }]); | ||
_createClass(Directive, [{ | ||
key: "parameters", | ||
get: function get() { | ||
var raw = this.rawValue; | ||
return raw ? raw.trim().split(/[ \t]+/) : []; | ||
} | ||
}, { | ||
key: "parseName", | ||
@@ -531,8 +535,2 @@ value: function parseName(start) { | ||
} | ||
}, { | ||
key: "parameters", | ||
get: function get() { | ||
var raw = this.rawValue; | ||
return raw ? raw.trim().split(/[ \t]+/) : []; | ||
} | ||
}]); | ||
@@ -548,11 +546,2 @@ | ||
_createClass(Document, null, [{ | ||
key: "startCommentOrEndBlankLine", | ||
value: function startCommentOrEndBlankLine(src, start) { | ||
var offset = Node.endOfWhiteSpace(src, start); | ||
var ch = src[offset]; | ||
return ch === '#' || ch === '\n' ? offset : start; | ||
} | ||
}]); | ||
function Document() { | ||
@@ -807,2 +796,9 @@ var _this; | ||
} | ||
}], [{ | ||
key: "startCommentOrEndBlankLine", | ||
value: function startCommentOrEndBlankLine(src, start) { | ||
var offset = Node.endOfWhiteSpace(src, start); | ||
var ch = src[offset]; | ||
return ch === '#' || ch === '\n' ? offset : start; | ||
} | ||
}]); | ||
@@ -826,3 +822,3 @@ | ||
key: "parse", | ||
value: | ||
/** | ||
@@ -835,3 +831,3 @@ * Parses an *alias from the source | ||
*/ | ||
value: function parse(context, start) { | ||
function parse(context, start) { | ||
this.context = context; | ||
@@ -873,2 +869,83 @@ var src = context.src; | ||
_createClass(BlockValue, [{ | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
return this.chomping === Chomp.KEEP; | ||
} | ||
}, { | ||
key: "strValue", | ||
get: function get() { | ||
if (!this.valueRange || !this.context) return null; | ||
var _this$valueRange = this.valueRange, | ||
start = _this$valueRange.start, | ||
end = _this$valueRange.end; | ||
var _this$context = this.context, | ||
indent = _this$context.indent, | ||
src = _this$context.src; | ||
if (this.valueRange.isEmpty()) return ''; | ||
var lastNewLine = null; | ||
var ch = src[end - 1]; | ||
while (ch === '\n' || ch === '\t' || ch === ' ') { | ||
end -= 1; | ||
if (end <= start) { | ||
if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens | ||
} | ||
if (ch === '\n') lastNewLine = end; | ||
ch = src[end - 1]; | ||
} | ||
var keepStart = end + 1; | ||
if (lastNewLine) { | ||
if (this.chomping === Chomp.KEEP) { | ||
keepStart = lastNewLine; | ||
end = this.valueRange.end; | ||
} else { | ||
end = lastNewLine; | ||
} | ||
} | ||
var bi = indent + this.blockIndent; | ||
var folded = this.type === Type.BLOCK_FOLDED; | ||
var atStart = true; | ||
var str = ''; | ||
var sep = ''; | ||
var prevMoreIndented = false; | ||
for (var i = start; i < end; ++i) { | ||
for (var j = 0; j < bi; ++j) { | ||
if (src[i] !== ' ') break; | ||
i += 1; | ||
} | ||
var _ch = src[i]; | ||
if (_ch === '\n') { | ||
if (sep === '\n') str += '\n';else sep = '\n'; | ||
} else { | ||
var lineEnd = Node.endOfLine(src, i); | ||
var line = src.slice(i, lineEnd); | ||
i = lineEnd; | ||
if (folded && (_ch === ' ' || _ch === '\t') && i < keepStart) { | ||
if (sep === ' ') sep = '\n';else if (!prevMoreIndented && !atStart && sep === '\n') sep = '\n\n'; | ||
str += sep + line; //+ ((lineEnd < end && src[lineEnd]) || '') | ||
sep = lineEnd < end && src[lineEnd] || ''; | ||
prevMoreIndented = true; | ||
} else { | ||
str += sep + line; | ||
sep = folded && i < keepStart ? ' ' : '\n'; | ||
prevMoreIndented = false; | ||
} | ||
if (atStart && line !== '') atStart = false; | ||
} | ||
} | ||
return this.chomping === Chomp.STRIP ? str : str + '\n'; | ||
} | ||
}, { | ||
key: "parseBlockHeader", | ||
@@ -917,5 +994,5 @@ value: function parseBlockHeader(start) { | ||
value: function parseBlockValue(start) { | ||
var _this$context = this.context, | ||
indent = _this$context.indent, | ||
src = _this$context.src; | ||
var _this$context2 = this.context, | ||
indent = _this$context2.indent, | ||
src = _this$context2.src; | ||
var explicit = !!this.blockIndent; | ||
@@ -932,3 +1009,3 @@ var offset = start; | ||
if (end === null) break; | ||
var _ch = src[end]; | ||
var _ch2 = src[end]; | ||
var lineIndent = end - (offset + indent); | ||
@@ -950,3 +1027,3 @@ | ||
} | ||
} else if (_ch && _ch !== '\n' && lineIndent < this.blockIndent) { | ||
} else if (_ch2 && _ch2 !== '\n' && lineIndent < this.blockIndent) { | ||
if (src[end] === '#') break; | ||
@@ -1015,83 +1092,2 @@ | ||
} | ||
}, { | ||
key: "includesTrailingLines", | ||
get: function get() { | ||
return this.chomping === Chomp.KEEP; | ||
} | ||
}, { | ||
key: "strValue", | ||
get: function get() { | ||
if (!this.valueRange || !this.context) return null; | ||
var _this$valueRange = this.valueRange, | ||
start = _this$valueRange.start, | ||
end = _this$valueRange.end; | ||
var _this$context2 = this.context, | ||
indent = _this$context2.indent, | ||
src = _this$context2.src; | ||
if (this.valueRange.isEmpty()) return ''; | ||
var lastNewLine = null; | ||
var ch = src[end - 1]; | ||
while (ch === '\n' || ch === '\t' || ch === ' ') { | ||
end -= 1; | ||
if (end <= start) { | ||
if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens | ||
} | ||
if (ch === '\n') lastNewLine = end; | ||
ch = src[end - 1]; | ||
} | ||
var keepStart = end + 1; | ||
if (lastNewLine) { | ||
if (this.chomping === Chomp.KEEP) { | ||
keepStart = lastNewLine; | ||
end = this.valueRange.end; | ||
} else { | ||
end = lastNewLine; | ||
} | ||
} | ||
var bi = indent + this.blockIndent; | ||
var folded = this.type === Type.BLOCK_FOLDED; | ||
var atStart = true; | ||
var str = ''; | ||
var sep = ''; | ||
var prevMoreIndented = false; | ||
for (var i = start; i < end; ++i) { | ||
for (var j = 0; j < bi; ++j) { | ||
if (src[i] !== ' ') break; | ||
i += 1; | ||
} | ||
var _ch2 = src[i]; | ||
if (_ch2 === '\n') { | ||
if (sep === '\n') str += '\n';else sep = '\n'; | ||
} else { | ||
var lineEnd = Node.endOfLine(src, i); | ||
var line = src.slice(i, lineEnd); | ||
i = lineEnd; | ||
if (folded && (_ch2 === ' ' || _ch2 === '\t') && i < keepStart) { | ||
if (sep === ' ') sep = '\n';else if (!prevMoreIndented && !atStart && sep === '\n') sep = '\n\n'; | ||
str += sep + line; //+ ((lineEnd < end && src[lineEnd]) || '') | ||
sep = lineEnd < end && src[lineEnd] || ''; | ||
prevMoreIndented = true; | ||
} else { | ||
str += sep + line; | ||
sep = folded && i < keepStart ? ' ' : '\n'; | ||
prevMoreIndented = false; | ||
} | ||
if (atStart && line !== '') atStart = false; | ||
} | ||
} | ||
return this.chomping === Chomp.STRIP ? str : str + '\n'; | ||
} | ||
}]); | ||
@@ -1318,42 +1314,8 @@ | ||
_createClass(QuoteDouble, [{ | ||
key: "parseCharCode", | ||
value: function parseCharCode(offset, length, errors) { | ||
var src = this.context.src; | ||
var cc = src.substr(offset, length); | ||
var ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc); | ||
var code = ok ? parseInt(cc, 16) : NaN; | ||
if (isNaN(code)) { | ||
errors.push(new YAMLSyntaxError(this, "Invalid escape sequence ".concat(src.substr(offset - 2, length + 2)))); | ||
return src.substr(offset - 2, length + 2); | ||
} | ||
return String.fromCodePoint(code); | ||
} | ||
/** | ||
* Parses a "double quoted" value from the source | ||
* | ||
* @param {ParseContext} context | ||
* @param {number} start - Index of first character | ||
* @returns {number} - Index of the character after this scalar | ||
*/ | ||
}, { | ||
key: "parse", | ||
value: function parse(context, start) { | ||
this.context = context; | ||
var src = context.src; | ||
var offset = QuoteDouble.endOfQuote(src, start + 1); | ||
this.valueRange = new Range(start, offset); | ||
offset = Node.endOfWhiteSpace(src, offset); | ||
offset = this.parseComment(offset); | ||
return offset; | ||
} | ||
}, { | ||
key: "strValue", | ||
get: | ||
/** | ||
* @returns {string | { str: string, errors: YAMLSyntaxError[] }} | ||
*/ | ||
get: function get() { | ||
function get() { | ||
if (!this.valueRange || !this.context) return null; | ||
@@ -1523,2 +1485,36 @@ var errors = []; | ||
} | ||
}, { | ||
key: "parseCharCode", | ||
value: function parseCharCode(offset, length, errors) { | ||
var src = this.context.src; | ||
var cc = src.substr(offset, length); | ||
var ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc); | ||
var code = ok ? parseInt(cc, 16) : NaN; | ||
if (isNaN(code)) { | ||
errors.push(new YAMLSyntaxError(this, "Invalid escape sequence ".concat(src.substr(offset - 2, length + 2)))); | ||
return src.substr(offset - 2, length + 2); | ||
} | ||
return String.fromCodePoint(code); | ||
} | ||
/** | ||
* Parses a "double quoted" value from the source | ||
* | ||
* @param {ParseContext} context | ||
* @param {number} start - Index of first character | ||
* @returns {number} - Index of the character after this scalar | ||
*/ | ||
}, { | ||
key: "parse", | ||
value: function parse(context, start) { | ||
this.context = context; | ||
var src = context.src; | ||
var offset = QuoteDouble.endOfQuote(src, start + 1); | ||
this.valueRange = new Range(start, offset); | ||
offset = Node.endOfWhiteSpace(src, offset); | ||
offset = this.parseComment(offset); | ||
return offset; | ||
} | ||
}], [{ | ||
@@ -1553,27 +1549,8 @@ key: "endOfQuote", | ||
_createClass(QuoteSingle, [{ | ||
key: "parse", | ||
/** | ||
* Parses a 'single quoted' value from the source | ||
* | ||
* @param {ParseContext} context | ||
* @param {number} start - Index of first character | ||
* @returns {number} - Index of the character after this scalar | ||
*/ | ||
value: function parse(context, start) { | ||
this.context = context; | ||
var src = context.src; | ||
var offset = QuoteSingle.endOfQuote(src, start + 1); | ||
this.valueRange = new Range(start, offset); | ||
offset = Node.endOfWhiteSpace(src, offset); | ||
offset = this.parseComment(offset); | ||
return offset; | ||
} | ||
}, { | ||
key: "strValue", | ||
get: | ||
/** | ||
* @returns {string | { str: string, errors: YAMLSyntaxError[] }} | ||
*/ | ||
get: function get() { | ||
function get() { | ||
if (!this.valueRange || !this.context) return null; | ||
@@ -1629,2 +1606,21 @@ var errors = []; | ||
} | ||
/** | ||
* Parses a 'single quoted' value from the source | ||
* | ||
* @param {ParseContext} context | ||
* @param {number} start - Index of first character | ||
* @returns {number} - Index of the character after this scalar | ||
*/ | ||
}, { | ||
key: "parse", | ||
value: function parse(context, start) { | ||
this.context = context; | ||
var src = context.src; | ||
var offset = QuoteSingle.endOfQuote(src, start + 1); | ||
this.valueRange = new Range(start, offset); | ||
offset = Node.endOfWhiteSpace(src, offset); | ||
offset = this.parseComment(offset); | ||
return offset; | ||
} | ||
}], [{ | ||
@@ -1698,42 +1694,2 @@ key: "endOfQuote", | ||
var ParseContext = /*#__PURE__*/function () { | ||
_createClass(ParseContext, null, [{ | ||
key: "parseType", | ||
value: function parseType(src, offset, inFlow) { | ||
switch (src[offset]) { | ||
case '*': | ||
return Type.ALIAS; | ||
case '>': | ||
return Type.BLOCK_FOLDED; | ||
case '|': | ||
return Type.BLOCK_LITERAL; | ||
case '{': | ||
return Type.FLOW_MAP; | ||
case '[': | ||
return Type.FLOW_SEQ; | ||
case '?': | ||
return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_KEY : Type.PLAIN; | ||
case ':': | ||
return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_VALUE : Type.PLAIN; | ||
case '-': | ||
return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.SEQ_ITEM : Type.PLAIN; | ||
case '"': | ||
return Type.QUOTE_DOUBLE; | ||
case "'": | ||
return Type.QUOTE_SINGLE; | ||
default: | ||
return Type.PLAIN; | ||
} | ||
} | ||
}]); | ||
function ParseContext() { | ||
@@ -1830,7 +1786,13 @@ var _this = this; | ||
if (ch === '\n') { | ||
var lineStart = offset + 1; | ||
var inEnd = Node.endOfIndent(src, lineStart); | ||
var inEnd = offset; | ||
var lineStart = void 0; | ||
do { | ||
lineStart = inEnd + 1; | ||
inEnd = Node.endOfIndent(src, lineStart); | ||
} while (src[inEnd] === '\n'); | ||
var indentDiff = inEnd - (lineStart + this.indent); | ||
var noIndicatorAsIndent = parent.type === Type.SEQ_ITEM && parent.context.atLineStart; | ||
if (!Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break; | ||
if (src[inEnd] !== '#' && !Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break; | ||
this.atLineStart = true; | ||
@@ -1879,2 +1841,40 @@ this.lineStart = lineStart; | ||
}], [{ | ||
key: "parseType", | ||
value: function parseType(src, offset, inFlow) { | ||
switch (src[offset]) { | ||
case '*': | ||
return Type.ALIAS; | ||
case '>': | ||
return Type.BLOCK_FOLDED; | ||
case '|': | ||
return Type.BLOCK_LITERAL; | ||
case '{': | ||
return Type.FLOW_MAP; | ||
case '[': | ||
return Type.FLOW_SEQ; | ||
case '?': | ||
return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_KEY : Type.PLAIN; | ||
case ':': | ||
return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_VALUE : Type.PLAIN; | ||
case '-': | ||
return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.SEQ_ITEM : Type.PLAIN; | ||
case '"': | ||
return Type.QUOTE_DOUBLE; | ||
case "'": | ||
return Type.QUOTE_SINGLE; | ||
default: | ||
return Type.PLAIN; | ||
} | ||
} | ||
}]); | ||
@@ -1881,0 +1881,0 @@ |
@@ -1,4 +0,4 @@ | ||
import './PlainValue-ff5147c6.js'; | ||
export { A as Alias, C as Collection, M as Merge, N as Node, P as Pair, S as Scalar, d as YAMLMap, Y as YAMLSeq, b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions } from './resolveSeq-04825f30.js'; | ||
export { S as Schema } from './Schema-2bf2c74e.js'; | ||
import './warnings-0e4b70d3.js'; | ||
export { A as Alias, C as Collection, M as Merge, N as Node, P as Pair, S as Scalar, d as YAMLMap, Y as YAMLSeq, b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions } from './resolveSeq-492ab440.js'; | ||
export { S as Schema } from './Schema-e94716c8.js'; | ||
import './PlainValue-b8036b75.js'; | ||
import './warnings-df54cb69.js'; |
@@ -1,2 +0,2 @@ | ||
export { T as Type, i as YAMLError, o as YAMLReferenceError, g as YAMLSemanticError, Y as YAMLSyntaxError, f as YAMLWarning } from './PlainValue-ff5147c6.js'; | ||
export { l as findPair, g as parseMap, h as parseSeq, k as stringifyNumber, c as stringifyString, t as toJSON } from './resolveSeq-04825f30.js'; | ||
export { l as findPair, g as parseMap, h as parseSeq, k as stringifyNumber, c as stringifyString, t as toJSON } from './resolveSeq-492ab440.js'; | ||
export { T as Type, i as YAMLError, o as YAMLReferenceError, g as YAMLSemanticError, Y as YAMLSyntaxError, f as YAMLWarning } from './PlainValue-b8036b75.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './dist/types.js' | ||
module.exports = require('./dist/types') |
@@ -1,1 +0,1 @@ | ||
export * from './dist/util.js' | ||
module.exports = require('./dist/util') |
'use strict'; | ||
var parseCst = require('./parse-cst.js'); | ||
var Document$1 = require('./Document-9b4560a1.js'); | ||
var Schema = require('./Schema-88e323a7.js'); | ||
var PlainValue = require('./PlainValue-ec8e588e.js'); | ||
var parseCst = require('./parse-cst.js'); | ||
require('./resolveSeq-4a68b39b.js'); | ||
var Document$1 = require('./Document-2cf6b08c.js'); | ||
var Schema = require('./Schema-42e9705c.js'); | ||
var warnings = require('./warnings-39684f17.js'); | ||
var warnings = require('./warnings-1000a372.js'); | ||
require('./resolveSeq-d03cb037.js'); | ||
@@ -10,0 +10,0 @@ function createNode(value, wrapScalars = true, tag) { |
'use strict'; | ||
var warnings = require('./warnings-1000a372.js'); | ||
require('./PlainValue-ec8e588e.js'); | ||
require('./resolveSeq-4a68b39b.js'); | ||
var warnings = require('./warnings-39684f17.js'); | ||
require('./resolveSeq-d03cb037.js'); | ||
@@ -7,0 +7,0 @@ |
@@ -1653,7 +1653,13 @@ 'use strict'; | ||
if (ch === '\n') { | ||
const lineStart = offset + 1; | ||
const inEnd = PlainValue.Node.endOfIndent(src, lineStart); | ||
let inEnd = offset; | ||
let lineStart; | ||
do { | ||
lineStart = inEnd + 1; | ||
inEnd = PlainValue.Node.endOfIndent(src, lineStart); | ||
} while (src[inEnd] === '\n'); | ||
const indentDiff = inEnd - (lineStart + this.indent); | ||
const noIndicatorAsIndent = parent.type === PlainValue.Type.SEQ_ITEM && parent.context.atLineStart; | ||
if (!PlainValue.Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break; | ||
if (src[inEnd] !== '#' && !PlainValue.Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break; | ||
this.atLineStart = true; | ||
@@ -1660,0 +1666,0 @@ this.lineStart = lineStart; |
'use strict'; | ||
var parseCst = require('./parse-cst.js'); | ||
var Document = require('./Document-9b4560a1.js'); | ||
require('./PlainValue-ec8e588e.js'); | ||
var parseCst = require('./parse-cst.js'); | ||
require('./resolveSeq-4a68b39b.js'); | ||
var Document$1 = require('./Document-2cf6b08c.js'); | ||
require('./Schema-42e9705c.js'); | ||
require('./warnings-39684f17.js'); | ||
require('./resolveSeq-d03cb037.js'); | ||
require('./Schema-88e323a7.js'); | ||
require('./warnings-1000a372.js'); | ||
@@ -16,3 +16,3 @@ function testEvents(src, options) { | ||
}, options); | ||
const docs = parseCst.parse(src).map(cstDoc => new Document$1.Document(opt).parse(cstDoc)); | ||
const docs = parseCst.parse(src).map(cstDoc => new Document.Document(opt).parse(cstDoc)); | ||
const errDoc = docs.find(doc => doc.errors.length > 0); | ||
@@ -19,0 +19,0 @@ const error = errDoc ? errDoc.errors[0].message : null; |
'use strict'; | ||
var resolveSeq = require('./resolveSeq-d03cb037.js'); | ||
var Schema = require('./Schema-88e323a7.js'); | ||
require('./PlainValue-ec8e588e.js'); | ||
var resolveSeq = require('./resolveSeq-4a68b39b.js'); | ||
var Schema = require('./Schema-42e9705c.js'); | ||
require('./warnings-39684f17.js'); | ||
require('./warnings-1000a372.js'); | ||
@@ -8,0 +8,0 @@ |
'use strict'; | ||
var resolveSeq = require('./resolveSeq-d03cb037.js'); | ||
var PlainValue = require('./PlainValue-ec8e588e.js'); | ||
var resolveSeq = require('./resolveSeq-4a68b39b.js'); | ||
exports.findPair = resolveSeq.findPair; | ||
exports.parseMap = resolveSeq.resolveMap; | ||
exports.parseSeq = resolveSeq.resolveSeq; | ||
exports.stringifyNumber = resolveSeq.stringifyNumber; | ||
exports.stringifyString = resolveSeq.stringifyString; | ||
exports.toJSON = resolveSeq.toJSON; | ||
exports.Type = PlainValue.Type; | ||
@@ -14,7 +20,1 @@ exports.YAMLError = PlainValue.YAMLError; | ||
exports.YAMLWarning = PlainValue.YAMLWarning; | ||
exports.findPair = resolveSeq.findPair; | ||
exports.parseMap = resolveSeq.resolveMap; | ||
exports.parseSeq = resolveSeq.resolveSeq; | ||
exports.stringifyNumber = resolveSeq.stringifyNumber; | ||
exports.stringifyString = resolveSeq.stringifyString; | ||
exports.toJSON = resolveSeq.toJSON; |
@@ -146,3 +146,3 @@ import { CST } from './parse-cst' | ||
*/ | ||
asBigInt: false | ||
asBigInt: boolean | ||
} | ||
@@ -264,3 +264,3 @@ | ||
interface Parsed extends Document { | ||
contents: Node | null | ||
contents: Scalar | YAMLMap | YAMLSeq | null | ||
/** The schema used with the document. */ | ||
@@ -267,0 +267,0 @@ schema: Schema |
{ | ||
"name": "yaml", | ||
"version": "1.10.0", | ||
"version": "1.10.2", | ||
"license": "ISC", | ||
@@ -13,3 +13,3 @@ "author": "Eemeli Aro <eemeli@gmail.com>", | ||
], | ||
"homepage": "https://eemeli.org/yaml/", | ||
"homepage": "https://eemeli.org/yaml/v1/", | ||
"files": [ | ||
@@ -70,2 +70,3 @@ "browser/", | ||
"test": "jest", | ||
"test:browsers": "cd playground && npm test", | ||
"test:dist": "npm run build:node && jest", | ||
@@ -87,19 +88,18 @@ "test:types": "tsc --lib ES2017 --noEmit tests/typings.ts", | ||
"devDependencies": { | ||
"@babel/core": "^7.9.6", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/preset-env": "^7.9.6", | ||
"@rollup/plugin-babel": "^5.0.0", | ||
"@babel/core": "^7.12.10", | ||
"@babel/plugin-proposal-class-properties": "^7.12.1", | ||
"@babel/preset-env": "^7.12.11", | ||
"@rollup/plugin-babel": "^5.2.3", | ||
"babel-eslint": "^10.1.0", | ||
"babel-jest": "^26.0.1", | ||
"babel-jest": "^26.6.3", | ||
"babel-plugin-trace": "^1.1.0", | ||
"common-tags": "^1.8.0", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^7.0.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"fast-check": "^1.24.2", | ||
"jest": "^26.0.1", | ||
"prettier": "^2.0.5", | ||
"rollup": "^2.10.2", | ||
"typescript": "^3.9.2" | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"fast-check": "^2.12.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.38.2", | ||
"typescript": "^4.1.3" | ||
}, | ||
@@ -106,0 +106,0 @@ "engines": { |
@@ -54,2 +54,6 @@ import { Type, YAMLSyntaxError } from './util' | ||
readonly jsonLike: boolean | ||
readonly rangeAsLinePos: null | { | ||
start: { line: number; col: number } | ||
end?: { line: number; col: number } | ||
} | ||
readonly rawValue: string | null | ||
@@ -56,0 +60,0 @@ readonly tag: |
@@ -1,2 +0,2 @@ | ||
# YAML <a href="https://www.npmjs.com/package/yaml"><img align="right" src="https://badge.fury.io/js/yaml.svg" title="npm package" /></a><a href="https://travis-ci.org/eemeli/yaml"><img align="right" src="https://travis-ci.org/eemeli/yaml.svg?branch=master" title="Build status" /></a> | ||
# YAML <a href="https://www.npmjs.com/package/yaml"><img align="right" src="https://badge.fury.io/js/yaml.svg" title="npm package" /></a> | ||
@@ -9,3 +9,3 @@ `yaml` is a JavaScript parser and stringifier for [YAML](http://yaml.org/), a human friendly data serialization standard. It supports both parsing and stringifying data using all versions of YAML, along with all common data schemas. As a particularly distinguishing feature, `yaml` fully supports reading and writing comments and blank lines in YAML documents. | ||
For more information, see the project's documentation site: [**eemeli.org/yaml**](https://eemeli.org/yaml/) | ||
For more information, see the project's documentation site: [**eemeli.org/yaml/v1**](https://eemeli.org/yaml/v1/) | ||
@@ -18,7 +18,7 @@ To install: | ||
Note: `yaml` 0.x and 1.x are rather different implementations. For the earlier `yaml`, see [tj/js-yaml](https://github.com/tj/js-yaml). | ||
**Note:** This is `yaml@1`. You may also be interested in the next version, currently available as [`yaml@next`](https://www.npmjs.com/package/yaml/v/next). | ||
## API Overview | ||
The API provided by `yaml` has three layers, depending on how deep you need to go: [Parse & Stringify](https://eemeli.org/yaml/#parse-amp-stringify), [Documents](https://eemeli.org/yaml/#documents), and the [CST Parser](https://eemeli.org/yaml/#cst-parser). The first has the simplest API and "just works", the second gets you all the bells and whistles supported by the library along with a decent [AST](https://eemeli.org/yaml/#content-nodes), and the third is the closest to YAML source, making it fast, raw, and crude. | ||
The API provided by `yaml` has three layers, depending on how deep you need to go: [Parse & Stringify](https://eemeli.org/yaml/v1/#parse-amp-stringify), [Documents](https://eemeli.org/yaml/#documents), and the [CST Parser](https://eemeli.org/yaml/#cst-parser). The first has the simplest API and "just works", the second gets you all the bells and whistles supported by the library along with a decent [AST](https://eemeli.org/yaml/#content-nodes), and the third is the closest to YAML source, making it fast, raw, and crude. | ||
@@ -33,17 +33,17 @@ ```js | ||
- [`YAML.parse(str, options): value`](https://eemeli.org/yaml/#yaml-parse) | ||
- [`YAML.stringify(value, options): string`](https://eemeli.org/yaml/#yaml-stringify) | ||
- [`YAML.parse(str, options): value`](https://eemeli.org/yaml/v1/#yaml-parse) | ||
- [`YAML.stringify(value, options): string`](https://eemeli.org/yaml/v1/#yaml-stringify) | ||
### YAML Documents | ||
- [`YAML.createNode(value, wrapScalars, tag): Node`](https://eemeli.org/yaml/#creating-nodes) | ||
- [`YAML.defaultOptions`](https://eemeli.org/yaml/#options) | ||
- [`YAML.Document`](https://eemeli.org/yaml/#yaml-documents) | ||
- [`constructor(options)`](https://eemeli.org/yaml/#creating-documents) | ||
- [`defaults`](https://eemeli.org/yaml/#options) | ||
- [`#anchors`](https://eemeli.org/yaml/#working-with-anchors) | ||
- [`#contents`](https://eemeli.org/yaml/#content-nodes) | ||
- [`#errors`](https://eemeli.org/yaml/#errors) | ||
- [`YAML.parseAllDocuments(str, options): YAML.Document[]`](https://eemeli.org/yaml/#parsing-documents) | ||
- [`YAML.parseDocument(str, options): YAML.Document`](https://eemeli.org/yaml/#parsing-documents) | ||
- [`YAML.createNode(value, wrapScalars, tag): Node`](https://eemeli.org/yaml/v1/#creating-nodes) | ||
- [`YAML.defaultOptions`](https://eemeli.org/yaml/v1/#options) | ||
- [`YAML.Document`](https://eemeli.org/yaml/v1/#yaml-documents) | ||
- [`constructor(options)`](https://eemeli.org/yaml/v1/#creating-documents) | ||
- [`defaults`](https://eemeli.org/yaml/v1/#options) | ||
- [`#anchors`](https://eemeli.org/yaml/v1/#working-with-anchors) | ||
- [`#contents`](https://eemeli.org/yaml/v1/#content-nodes) | ||
- [`#errors`](https://eemeli.org/yaml/v1/#errors) | ||
- [`YAML.parseAllDocuments(str, options): YAML.Document[]`](https://eemeli.org/yaml/v1/#parsing-documents) | ||
- [`YAML.parseDocument(str, options): YAML.Document`](https://eemeli.org/yaml/v1/#parsing-documents) | ||
@@ -54,5 +54,5 @@ ```js | ||
- [`new Pair(key, value)`](https://eemeli.org/yaml/#creating-nodes) | ||
- [`new YAMLMap()`](https://eemeli.org/yaml/#creating-nodes) | ||
- [`new YAMLSeq()`](https://eemeli.org/yaml/#creating-nodes) | ||
- [`new Pair(key, value)`](https://eemeli.org/yaml/v1/#creating-nodes) | ||
- [`new YAMLMap()`](https://eemeli.org/yaml/v1/#creating-nodes) | ||
- [`new YAMLSeq()`](https://eemeli.org/yaml/v1/#creating-nodes) | ||
@@ -65,4 +65,4 @@ ### CST Parser | ||
- [`parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/#parsecst) | ||
- [`YAML.parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/#parsecst) | ||
- [`parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/v1/#parsecst) | ||
- [`YAML.parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/v1/#parsecst) | ||
@@ -69,0 +69,0 @@ ## YAML.parse |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
448149
16
58
13349
0