-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
1 addition
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,8 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @module collapse-white-space | ||
* @fileoverview Replace multiple white-space characters | ||
* with a single space. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* Expose. */ | ||
module.exports = collapse; | ||
|
||
/** | ||
* Replace multiple white-space characters with a single space. | ||
* | ||
* @example | ||
* collapse(' \t\nbar \nbaz\t'); // ' bar baz ' | ||
* | ||
* @param {string} value - Value with uncollapsed white-space, | ||
* coerced to string. | ||
* @return {string} - Value with collapsed white-space. | ||
*/ | ||
/* collapse(' \t\nbar \nbaz\t'); // ' bar baz ' */ | ||
function collapse(value) { | ||
return String(value).replace(/\s+/g, ' '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters