Socket
Book a DemoInstallSign in
Socket

whitescape

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whitescape

Escape whitespace characters (CommonJS, AMD and browser global compatible)

latest
Source
npmnpm
Version
0.5.0
Version published
Maintainers
1
Created
Source

whitescape.js

Escape whitespace characters (CommonJS, AMD and browser global compatible)

It is useful when you need to display significant whitespace, for example when visualizing parser grammars. Code points were extracted from ECMAScript spec and Wikipedia list.

Usage

npm install whitescape

var whitescape = require('whitescape');

whitescape('\b\t\n\v\f\r');
  // => "\\b\\t\\n\\v\\f\\r"
  // supports js escape sequences

whitescape('\uFEFF\u00A0');
  // => "\\uFEFF\\u00A0"
  // and also various unicode whitespace

Usage without a module loader:

<script src="whitescape.js"></script>

<script type="text/javascript">
  whitescape('\b\t\n\v\f\r');
</script>

Advanced

Whitescape does not escape space character by default. You can customize this behavior with:

whitescape.characters[' '] = '\\u0020';

Tests

npm install
npm test

Keywords

escape

FAQs

Package last updated on 12 Mar 2015

Did you know?

Socket

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