@bugbearr/escapejsstring

Escape JavaScript string

Usage no npm install needed!

<script type="module">
  import bugbearrEscapejsstring from 'https://cdn.skypack.dev/@bugbearr/escapejsstring';
</script>

README

escapeJsString

CI Gitpod Ready-to-Code

import escapeJsString from "@bugbearr/escapejsstring";
// var escapeJsString = require("@bugbearr/escapejsstring").default;

// Escape C0 chars and HTML, XML, JavaScript special chars for JavaScript string.
console.log(escapeJsString("\"<Hello,\r\n world!>\"\r\n"));
// Console.out
// \u0022\u003cHello,\r\n world!\u003e\u0022\r\n