Package Exports
- whitescape
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (whitescape) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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