diff options
Diffstat (limited to 'node_modules/yaml/browser/dist/stringify/stringifyCollection.js')
| -rw-r--r-- | node_modules/yaml/browser/dist/stringify/stringifyCollection.js | 20 |
1 files changed, 6 insertions, 14 deletions
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) |
