summaryrefslogtreecommitdiff
path: root/node_modules/yaml/browser/dist/stringify/stringifyComment.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-11-28 17:14:38 +0100
committerMinteck <contact@minteck.org>2022-11-28 17:14:38 +0100
commit18efd30a263ec0d79a26a82cbd8c90c9f81056b7 (patch)
treeaea01bf3506dda706719fc68eb37b77ed9ef3fe8 /node_modules/yaml/browser/dist/stringify/stringifyComment.js
downloadautoreport-mane.tar.gz
autoreport-mane.tar.bz2
autoreport-mane.zip
Open sourceHEADmane
Diffstat (limited to 'node_modules/yaml/browser/dist/stringify/stringifyComment.js')
-rw-r--r--node_modules/yaml/browser/dist/stringify/stringifyComment.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/yaml/browser/dist/stringify/stringifyComment.js b/node_modules/yaml/browser/dist/stringify/stringifyComment.js
new file mode 100644
index 0000000..f16fc91
--- /dev/null
+++ b/node_modules/yaml/browser/dist/stringify/stringifyComment.js
@@ -0,0 +1,20 @@
+/**
+ * Stringifies a comment.
+ *
+ * Empty comment lines are left empty,
+ * lines consisting of a single space are replaced by `#`,
+ * and all other lines are prefixed with a `#`.
+ */
+const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, '#');
+function indentComment(comment, indent) {
+ if (/^\n+$/.test(comment))
+ return comment.substring(1);
+ return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
+}
+const lineComment = (str, indent, comment) => str.endsWith('\n')
+ ? indentComment(comment, indent)
+ : comment.includes('\n')
+ ? '\n' + indentComment(comment, indent)
+ : (str.endsWith(' ') ? '' : ' ') + comment;
+
+export { indentComment, lineComment, stringifyComment };