Created
October 18, 2021 15:30
-
-
Save stefanocudini/80e92e4235f607ceb3418367dfe121ab to your computer and use it in GitHub Desktop.
Strip Yaml Comments in nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stripComments(ymltext) { | |
const lines = ymltext.split(/\r?\n/).map(line => { | |
const trim = line.trim(); | |
return trim[0]!=='#' ? line : ''; | |
}).filter(line => { | |
return line; | |
}); | |
return lines.join('\n')+'\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment