condense-whitespace
Advanced tools
Comparing version
'use strict'; | ||
module.exports = function (str, opts) { | ||
if (typeof str !== 'string') { | ||
module.exports = string => { | ||
if (typeof string !== 'string') { | ||
throw new TypeError('Expected a string'); | ||
} | ||
return str.trim().replace(/\s{2,}/g, ' '); | ||
return string.trim().replace(/\s{2,}/g, ' '); | ||
}; |
{ | ||
"name": "condense-whitespace", | ||
"version": "1.0.0", | ||
"description": "Remove leading, trailing and repeated whitespace from a string", | ||
"license": "MIT", | ||
"repository": "sindresorhus/condense-whitespace", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"whitespace", | ||
"space", | ||
"condense", | ||
"collapse", | ||
"compact", | ||
"repeated", | ||
"string", | ||
"str", | ||
"trim", | ||
"remove", | ||
"strip" | ||
], | ||
"devDependencies": { | ||
"ava": "0.0.4" | ||
} | ||
"name": "condense-whitespace", | ||
"version": "2.0.0", | ||
"description": "Remove leading, trailing, and repeated whitespace from a string", | ||
"license": "MIT", | ||
"repository": "sindresorhus/condense-whitespace", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"whitespace", | ||
"space", | ||
"condense", | ||
"collapse", | ||
"compact", | ||
"repeated", | ||
"string", | ||
"trim", | ||
"remove", | ||
"strip" | ||
], | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
# condense-whitespace [](https://travis-ci.org/sindresorhus/condense-whitespace) | ||
> Remove leading, trailing and repeated whitespace from a string | ||
> Remove leading, trailing, and repeated whitespace from a string | ||
@@ -9,3 +9,3 @@ | ||
``` | ||
$ npm install --save condense-whitespace | ||
$ npm install condense-whitespace | ||
``` | ||
@@ -17,3 +17,3 @@ | ||
```js | ||
var condenseWhitespace = require('condense-whitespace'); | ||
const condenseWhitespace = require('condense-whitespace'); | ||
@@ -25,4 +25,9 @@ condenseWhitespace(' foo bar baz '); | ||
## Related | ||
- [`trim-repeated`](https://github.com/sindresorhus/trim-repeated) - Trim a consecutively repeated substring: `foo--bar---baz` → `foo-bar-baz` | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2918
17.66%5
25%18
157.14%31
19.23%0
-100%3
200%