Socket
Socket
Sign inDemoInstall

jsesc

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jsesc

A JavaScript library for escaping JavaScript strings while generating the shortest possible valid output.


Version published
Weekly downloads
57M
increased by0.25%
Maintainers
1
Install size
17.3 kB
Created
Weekly downloads
 

Package description

What is jsesc?

The jsesc npm package is a library for escaping JavaScript strings while generating the shortest possible valid ASCII-only output. It's useful for avoiding syntax errors when embedding data in JavaScript code or for preparing data to be JSON-encoded.

What are jsesc's main functionalities?

String escaping

Escapes any occurrences of U+2028 (line separator) and U+2029 (paragraph separator) among other potentially problematic characters in JavaScript strings, making the output safe for inclusion in HTML/JavaScript templates.

"jsesc('foo \u2028 bar \u2029 baz')"

JSON escaping

Converts an object to a JSON string, ensuring that the output is safe to use in JavaScript by escaping any characters that could cause syntax errors or security issues.

"jsesc({ 'foo': 'bar' }, { 'json': true })"

ASCII-only output

Escapes non-ASCII symbols into their Unicode escape sequences to produce an ASCII-only output. This is particularly useful for minimizing encoding issues or for environments that do not fully support Unicode.

"jsesc('foo © bar ≠ baz 𝌆 qux', { 'es6': false })"

Other packages similar to jsesc

Keywords

FAQs

Last updated on 07 Jun 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc