summaryrefslogtreecommitdiff
path: root/node_modules/yaml/dist/stringify
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/yaml/dist/stringify')
-rw-r--r--node_modules/yaml/dist/stringify/foldFlowLines.js29
-rw-r--r--node_modules/yaml/dist/stringify/stringifyCollection.js20
2 files changed, 25 insertions, 24 deletions
diff --git a/node_modules/yaml/dist/stringify/foldFlowLines.js b/node_modules/yaml/dist/stringify/foldFlowLines.js
index efe7a257..829a5601 100644
--- a/node_modules/yaml/dist/stringify/foldFlowLines.js
+++ b/node_modules/yaml/dist/stringify/foldFlowLines.js
@@ -30,7 +30,7 @@ function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth =
let escStart = -1;
let escEnd = -1;
if (mode === FOLD_BLOCK) {
- i = consumeMoreIndentedLines(text, i);
+ i = consumeMoreIndentedLines(text, i, indent.length);
if (i !== -1)
end = i + endStep;
}
@@ -54,8 +54,8 @@ function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth =
}
if (ch === '\n') {
if (mode === FOLD_BLOCK)
- i = consumeMoreIndentedLines(text, i);
- end = i + endStep;
+ i = consumeMoreIndentedLines(text, i, indent.length);
+ end = i + indent.length + endStep;
split = undefined;
}
else {
@@ -123,15 +123,24 @@ function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth =
* Presumes `i + 1` is at the start of a line
* @returns index of last newline in more-indented block
*/
-function consumeMoreIndentedLines(text, i) {
- let ch = text[i + 1];
+function consumeMoreIndentedLines(text, i, indent) {
+ let end = i;
+ let start = i + 1;
+ let ch = text[start];
while (ch === ' ' || ch === '\t') {
- do {
- ch = text[(i += 1)];
- } while (ch && ch !== '\n');
- ch = text[i + 1];
+ if (i < start + indent) {
+ ch = text[++i];
+ }
+ else {
+ do {
+ ch = text[++i];
+ } while (ch && ch !== '\n');
+ end = i;
+ start = i + 1;
+ ch = text[start];
+ }
}
- return i;
+ return end;
}
exports.FOLD_BLOCK = FOLD_BLOCK;
diff --git a/node_modules/yaml/dist/stringify/stringifyCollection.js b/node_modules/yaml/dist/stringify/stringifyCollection.js
index 750efc15..6efffc51 100644
--- a/node_modules/yaml/dist/stringify/stringifyCollection.js
+++ b/node_modules/yaml/dist/stringify/stringifyCollection.js
@@ -1,6 +1,5 @@
'use strict';
-var Collection = require('../nodes/Collection.js');
var identity = require('../nodes/identity.js');
var stringify = require('./stringify.js');
var stringifyComment = require('./stringifyComment.js');
@@ -61,7 +60,7 @@ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, fl
onChompKeep();
return str;
}
-function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemIndent, onComment }) {
+function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
itemIndent += indentStep;
const itemCtx = Object.assign({}, ctx, {
@@ -114,32 +113,25 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
lines.push(str);
linesAtValue = lines.length;
}
- let str;
const { start, end } = flowChars;
if (lines.length === 0) {
- str = start + end;
+ return start + end;
}
else {
if (!reqNewline) {
const len = lines.reduce((sum, line) => sum + line.length + 2, 2);
- reqNewline = len > Collection.Collection.maxFlowStringSingleLineLength;
+ reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
}
if (reqNewline) {
- str = start;
+ let str = start;
for (const line of lines)
str += line ? `\n${indentStep}${indent}${line}` : '\n';
- str += `\n${indent}${end}`;
+ return `${str}\n${indent}${end}`;
}
else {
- str = `${start}${fcPadding}${lines.join(' ')}${fcPadding}${end}`;
+ return `${start}${fcPadding}${lines.join(' ')}${fcPadding}${end}`;
}
}
- if (comment) {
- str += stringifyComment.lineComment(str, indent, commentString(comment));
- if (onComment)
- onComment();
- }
- return str;
}
function addCommentBefore({ indent, options: { commentString } }, lines, comment, chompKeep) {
if (comment && chompKeep)