Nitrogenous Polymorphic Molecule
    Have ideas to improve npm?Join in the discussion! »

    whitescape

    0.5.0 • Public • Published

    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
    

    Install

    npm i whitescape

    DownloadsWeekly Downloads

    13

    Version

    0.5.0

    License

    Unlicense

    Last publish

    Collaborators

    • avatar