Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 7, 2024 via pnpm

js-string-escape 1.0.1

Escape strings for use as JavaScript string literals
Package summary
Share
0
issues
1
license
1
MIT
Package created
12 May 2013
Version published
11 Mar 2016
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
js-string-escape@1.0.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of js-string-escape 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does js-string-escape do?

The npm package, js-string-escape, serves as an effective tool for escaping any string to become a valid JavaScript string literal enclosed in either double or single quotes.

How do you use js-string-escape?

To utilize the js-string-escape package in your JavaScript code, you will first need to install it with the npm command npm install js-string-escape. Following its successful installation, you can implement it within your JavaScript files as shown in the examples below.

In your JavaScript code, you can require the package and then use it to escape characters in strings:

var jsStringEscape = require('js-string-escape');

var escapedString = jsStringEscape('Quotes (\", \'), newlines (\n), etc.');
console.log('"' + escapedString + '"');
// This will output: "Quotes (\", \'), newlines (\n), etc."

A unique feature of js-string-escape is that it maintains the integrity of the original string, s, even when evaluated. This implies that the formatted string returned from jsStringEscape, when evaluated, gives the original string. Here is an illustration of this:

var s = 'Original String';
console.log(eval('"' + jsStringEscape(s) + '"') === s);  // This will log: true

Note that the package can safely handle and cast non-string data types to string.

Where are the js-string-escape docs?

The comprehensive documentation for the js-string-escape package can be found directly on its GitHub page: https://github.com/joliss/js-string-escape. The information provided here includes an overview of the package, its installation process, and examples of how to use it. Moreover, the page also provides details regarding the package's compliance with ECMAScript 5.1 specifications, and its Universally Unique Identifier (UUID) code point testing results.

All Versions