From 457c93328f5b51b3fc0aa1600ce8eb8b45a5c2a9 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 9 Apr 2022 18:38:29 +0200 Subject: Snowjail v0.1 --- .../yaml/browser/dist/stringify/stringifyComment.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 node_modules/yaml/browser/dist/stringify/stringifyComment.js (limited to 'node_modules/yaml/browser/dist/stringify/stringifyComment.js') 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 }; -- cgit