summaryrefslogtreecommitdiff
path: root/node_modules/yaml/browser/dist/stringify
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
commit06823fbf1c2e763a5bf76c3990ca98fbbcd98691 (patch)
tree4280bece3888d12a022093bf1a9cd1b049393602 /node_modules/yaml/browser/dist/stringify
parent1368909b3cd552dbb0d12d5863c597f5be46177d (diff)
updated node_modules
Diffstat (limited to 'node_modules/yaml/browser/dist/stringify')
-rw-r--r--node_modules/yaml/browser/dist/stringify/foldFlowLines.js29
-rw-r--r--node_modules/yaml/browser/dist/stringify/stringifyCollection.js20
2 files changed, 25 insertions, 24 deletions
diff --git a/node_modules/yaml/browser/dist/stringify/foldFlowLines.js b/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
index 01fe7876..2a554266 100644
--- a/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
+++ b/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
@@ -28,7 +28,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;
}
@@ -52,8 +52,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 {
@@ -121,15 +121,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;
}
export { FOLD_BLOCK, FOLD_FLOW, FOLD_QUOTED, foldFlowLines };
diff --git a/node_modules/yaml/browser/dist/stringify/stringifyCollection.js b/node_modules/yaml/browser/dist/stringify/stringifyCollection.js
index 4817a9d5..9019400f 100644
--- a/node_modules/yaml/browser/dist/stringify/stringifyCollection.js
+++ b/node_modules/yaml/browser/dist/stringify/stringifyCollection.js
@@ -1,4 +1,3 @@
-import { Collection } from '../nodes/Collection.js';
import { isNode, isPair } from '../nodes/identity.js';
import { stringify } from './stringify.js';
import { lineComment, indentComment } from './stringifyComment.js';
@@ -59,7 +58,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, {
@@ -112,32 +111,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.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 += lineComment(str, indent, commentString(comment));
- if (onComment)
- onComment();
- }
- return str;
}
function addCommentBefore({ indent, options: { commentString } }, lines, comment, chompKeep) {
if (comment && chompKeep)