10 lines
177 B
JavaScript
10 lines
177 B
JavaScript
|
'use strict';
|
||
|
|
||
|
module.exports = string => {
|
||
|
if (typeof string !== 'string') {
|
||
|
throw new TypeError('Expected a string');
|
||
|
}
|
||
|
|
||
|
return string.trim().replace(/\s{2,}/g, ' ');
|
||
|
};
|