Skip to content

pbakondy/normalize-space

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published