Trims and replaces sequences of whitespace characters by a single space.
npm install normalize-space-x href="https://travis-ci.org/Xotic750/normalize-space-x"
title="Travis status"> src="https://travis-ci.org/Xotic750/normalize-space-x.svg?branch=master"
alt="Travis status" height="18">
href="https://david-dm.org/Xotic750/normalize-space-x"
title="Dependency status"> alt="Dependency status" height="18"/>
href="https://david-dm.org/Xotic750/normalize-space-x?type=dev"
title="devDependency status"> alt="devDependency status" height="18"/>
href="https://badge.fury.io/js/normalize-space-x"
title="npm version"> alt="npm version" height="18">
href="https://www.jsdelivr.com/package/npm/normalize-space-x"
title="jsDelivr hits"> alt="jsDelivr hits" height="18">
href="https://bettercodehub.com/results/Xotic750/normalize-space-x"
title="bettercodehub score"> alt="bettercodehub score" height="18">
href="https://coveralls.io/github/Xotic750/normalize-space-x?branch=master"
title="Coverage Status"> alt="Coverage Status" height="18">
href="https://coveralls.io/github/Xotic750/normalize-space-x?branch=master"
title="Coverage Status"> alt="Coverage Status" height="18">
Trims and replaces sequences of whitespace characters by a single space.
This method strips leading and trailing white-space from a string,
replaces sequences of whitespace characters by a single space,
and returns the resulting string. (ES2019)
Kind: static property of normalize-space-x
Returns: string - The normalized string.
Throws:
- TypeError If string is null or undefined or not coercible.
| Param | Type | Description |
| ------ | ------------------- | ---------------------------- |
| string | string | The string to be normalized. |
Example
``js
import normalizeSpace from 'normalize-space-x';
console.log(normalizeSpace(' \t\na \t\nb \t\n') === 'a b'); // true
``