-
-
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
6 changed files
with
27 additions
and
40 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,8 +1,5 @@ | ||
.DS_Store | ||
*.log | ||
.nyc_output/ | ||
coverage/ | ||
node_modules/ | ||
collapse-white-space.js | ||
collapse-white-space.min.js | ||
yarn.lock |
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,5 +1,2 @@ | ||
coverage/ | ||
collapse-white-space.js | ||
collapse-white-space.min.js | ||
*.json | ||
*.md |
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,8 +1,4 @@ | ||
'use strict' | ||
|
||
module.exports = collapse | ||
|
||
// `collapse(' \t\nbar \nbaz\t') // ' bar baz '` | ||
function collapse(value) { | ||
export function collapseWhiteSpace(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
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
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,14 +1,13 @@ | ||
'use strict' | ||
|
||
var test = require('tape') | ||
var collapse = require('.') | ||
import test from 'tape' | ||
import {collapseWhiteSpace} from './index.js' | ||
|
||
test('collapseWhiteSpace(value)', function (t) { | ||
t.equal(collapse(true), 'true', 'should coerce to string') | ||
// @ts-ignore runtime | ||
t.equal(collapseWhiteSpace(true), 'true', 'should coerce to string') | ||
|
||
t.equal(collapse(' \t\nbar \nbaz\t'), ' bar baz ') | ||
t.equal(collapse(' bar\t\t\tbaz\n\n\n'), ' bar baz ') | ||
t.equal(collapse(' \n bar\t\n\tbaz\r\n'), ' bar baz ') | ||
t.equal(collapseWhiteSpace(' \t\nbar \nbaz\t'), ' bar baz ') | ||
t.equal(collapseWhiteSpace(' bar\t\t\tbaz\n\n\n'), ' bar baz ') | ||
t.equal(collapseWhiteSpace(' \n bar\t\n\tbaz\r\n'), ' bar baz ') | ||
|
||
t.end() | ||
}) |