Imagine you're writing a code snippet in a template string.
const code = `fmt.Printf("%06d\n",1)`;
If you then did a
console.log (or any other outputting), you'd get
Hey, that's not what you wanted! 😭
Obviously, you could escape the backslash (
\\n) but that's not how you'd actually write the code.
Enter string-escape-spacing! It works by looking for unescaped spacing characters (i.e.
\v ) enclosed in string characters (
"The\tdog\twas\tlazy") whilst ignoring the string if it had no quotes around it (
yarn add string-escape-spacing npm install string-escape-spacing
;const string = `"The\tdog\twas\tlazy"`;console;// output:`"The\\tdog\\twas\\tlazy"`
const escaped = ;
options =quotes: "single" | "double";