1.0.2 • Published 8 years ago

normalize-space v1.0.2

Weekly downloads
15
License
MIT
Repository
github
Last release
8 years ago

normalize-space Build Status

Converts anything to string with normalized form. JavaScript equivalent of XSLT normalize-space()

Install

$ npm install --save normalize-space

Usage

The function first converts any incoming value to string then converts all the whitespace characters to a single space.

It works the same way as XSLT normalize-space().

If the incoming parameter is a Node ( result of Document.querySelector() ) or a NodeList ( result of Document.querySelectorAll() ) the module also converts it to string and normalizes its content.

Usage with Node.js

var normalize = require('normalize-space');

normalize('  a   \n\n\n    a  ');
//=> 'a a'

Usage with browser

Use the browser-specific file:

<script src="normalize-space/browser/index.js" type="text/javascript"></script>

<script>
  console.log(window.normalize('  a   \n\n\n    a  ')); //=> 'a a'
</script>

License

normalize-space is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.