⚝
One Hat Cyber Team
⚝
Your IP:
172.22.0.1
Server IP:
151.80.20.34
Server:
Linux 794f04d97d5e 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
Server Software:
Apache/2.4.62 (Debian)
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
nodejs
/
yaml
/
dist
/
stringify
/
View File Name :
stringifyDocument.js
'use strict'; var Node = require('../nodes/Node.js'); var stringify = require('./stringify.js'); var stringifyComment = require('./stringifyComment.js'); function stringifyDocument(doc, options) { const lines = []; let hasDirectives = options.directives === true; if (options.directives !== false && doc.directives) { const dir = doc.directives.toString(doc); if (dir) { lines.push(dir); hasDirectives = true; } else if (doc.directives.docStart) hasDirectives = true; } if (hasDirectives) lines.push('---'); const ctx = stringify.createStringifyContext(doc, options); const { commentString } = ctx.options; if (doc.commentBefore) { if (lines.length !== 1) lines.unshift(''); const cs = commentString(doc.commentBefore); lines.unshift(stringifyComment.indentComment(cs, '')); } let chompKeep = false; let contentComment = null; if (doc.contents) { if (Node.isNode(doc.contents)) { if (doc.contents.spaceBefore && hasDirectives) lines.push(''); if (doc.contents.commentBefore) { const cs = commentString(doc.contents.commentBefore); lines.push(stringifyComment.indentComment(cs, '')); } // top-level block scalars need to be indented if followed by a comment ctx.forceBlockIndent = !!doc.comment; contentComment = doc.contents.comment; } const onChompKeep = contentComment ? undefined : () => (chompKeep = true); let body = stringify.stringify(doc.contents, ctx, () => (contentComment = null), onChompKeep); if (contentComment) body += stringifyComment.lineComment(body, '', commentString(contentComment)); if ((body[0] === '|' || body[0] === '>') && lines[lines.length - 1] === '---') { // Top-level block scalars with a preceding doc marker ought to use the // same line for their header. lines[lines.length - 1] = `--- ${body}`; } else lines.push(body); } else { lines.push(stringify.stringify(doc.contents, ctx)); } if (doc.directives?.docEnd) { if (doc.comment) { const cs = commentString(doc.comment); if (cs.includes('\n')) { lines.push('...'); lines.push(stringifyComment.indentComment(cs, '')); } else { lines.push(`... ${cs}`); } } else { lines.push('...'); } } else { let dc = doc.comment; if (dc && chompKeep) dc = dc.replace(/^\n+/, ''); if (dc) { if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push(''); lines.push(stringifyComment.indentComment(commentString(dc), '')); } } return lines.join('\n') + '\n'; } exports.stringifyDocument = stringifyDocument;