aboutsummaryrefslogtreecommitdiff
path: root/node_modules/js-string-escape/README.md
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/js-string-escape/README.md
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/js-string-escape/README.md')
-rw-r--r--node_modules/js-string-escape/README.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/js-string-escape/README.md b/node_modules/js-string-escape/README.md
new file mode 100644
index 000000000..3147c1b34
--- /dev/null
+++ b/node_modules/js-string-escape/README.md
@@ -0,0 +1,44 @@
+# js-string-escape
+
+[![Build Status](https://travis-ci.org/joliss/js-string-escape.png?branch=master)](https://travis-ci.org/joliss/js-string-escape)
+
+Escape any string to be a valid JavaScript string literal between double
+quotes or single quotes.
+
+## Installation
+
+```
+npm install js-string-escape
+```
+
+## Example
+
+If you need to generate JavaScript output, this library will help you safely
+put arbitrary data in JavaScript strings:
+
+```js
+jsStringEscape = require('js-string-escape')
+
+console.log('"' + jsStringEscape('Quotes (\", \'), newlines (\n), etc.') + '"')
+// => "Quotes (\", \'), newlines (\n), etc."
+```
+
+In other words, given any string `s`, the following invariants hold:
+
+```js
+eval('"' + jsStringEscape(s) + '"') === s
+eval("'" + jsStringEscape(s) + "'") === s
+```
+
+These `eval` expressions are safe with untrusted strings `s`.
+
+Non-strings will be cast to strings.
+
+## Compliance
+
+This library has been checked against [ECMAScript
+5.1](http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4) and tested
+against all Unicode code points.
+
+Note that the returned string is not necessarily valid JSON, since JSON
+disallows control characters, and `\'` is illegal in JSON.