Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tokenize-whitespace

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

tokenize-whitespace

Tokenize a string into words and whitespace tokens

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.2K
increased by41.57%
Maintainers
1
Weekly downloads
 
Created
Source

tokenize-whitespace Build Status

Tokenize a string into words and whitespace tokens

Installation

$ npm install --save tokenize-whitespace

Usage

var tokenizeWhiteSpace = require('tokenize-whitespace');

var str = '\tString \nwith \nwhitespace \rchars';

// Get an Array of tokens
tokenizeWhitespace(str);

Output:

[ { text: '\t',         type: 'HORIZONTALTAB',  length: 1  },
  { text: 'String',     type: 'WORD',           length: 6  },
  { text: ' ',          type: 'SPACE',          length: 1  },
  { text: '\n',         type: 'LINEFEED',       length: 1  },
  { text: 'with',       type: 'WORD',           length: 4  },
  { text: ' ',          type: 'SPACE',          length: 1  },
  { text: '\n',         type: 'LINEFEED',       length: 1  },
  { text: 'whitespace', type: 'WORD',           length: 10 },
  { text: ' ',          type: 'SPACE',          length: 1  },
  { text: '\r',         type: 'CARRIAGERETURN', length: 1  },
  { text: 'chars',      type: 'WORD',           length: 5  } 
]

Relevant Whitespace

Currently, this module only tokenizes the following whitespace characters:

  • HORIZONTALTAB => '\t'
  • LINEFEED => '\n'
  • VERTICALTAB => '\v'
  • FORMFEED => '\f'
  • CARRIAGERETURN => '\r'
  • SPACE => ' '

Please open an issue or submit a pull request if you would like to see more whitespace character support.

License

MIT @ Michael Wuergler

Keywords

FAQs

Package last updated on 05 Dec 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc