From b933d486c6f9a33fdfbbd2673adb7647c191ae98 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Mon, 17 Dec 2018 09:43:27 +0000 Subject: [PATCH] Travis build: 909 --- README.md | 25 +- docs/about.html | 1 + docs/adapter.html | 5 +- docs/archive.html | 2 +- docs/browser.html | 2 +- docs/contributing.html | 1 + docs/date.html | 2 +- docs/function.html | 2 +- docs/glossary.html | 2 +- docs/index.html | 5 +- docs/math.html | 2 +- docs/node.html | 2 +- docs/object.html | 2 +- docs/string.html | 5 +- docs/type.html | 2 +- docs/utility.html | 2 +- snippets/compactWhitespace.md | 2 +- snippets/pipeAsyncFunctions.md | 1 - snippets/remove.md | 1 - test/_30s.js | 3383 ++++++++++++++------------------ 20 files changed, 1555 insertions(+), 1894 deletions(-) diff --git a/README.md b/README.md index e1fe52de4..d3d13e68e 100644 --- a/README.md +++ b/README.md @@ -406,6 +406,7 @@ _30s.average(1, 2, 3); * [`byteSize`](#bytesize) * [`capitalize`](#capitalize) * [`capitalizeEveryWord`](#capitalizeeveryword) +* [`compactWhitespace`](#compactwhitespace) * [`CSVToArray`](#csvtoarray) * [`CSVToJSON`](#csvtojson-) * [`decapitalize`](#decapitalize) @@ -664,7 +665,6 @@ const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Pr Examples ```js - const sum = pipeAsyncFunctions( x => x + 1, x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)), @@ -2313,7 +2313,6 @@ Use `Array.prototype.filter()` to find array elements that return truthy values The `func` is invoked with three arguments (`value, index, array`). ```js - const remove = (arr, func) => Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { @@ -7728,6 +7727,28 @@ capitalizeEveryWord('hello world!'); // 'Hello World!'
[⬆ Back to top](#contents) +### compactWhitespace + +Returns a string with whitespaces compacted. + +Use `String.prototype.replace()` with a regular expression to replace all occurences of 2 or more whitespace characters with a single space. + +```js +const compactWhitespace = str => str.replace(/\s{2,}/g, ' '); +``` + +
+Examples + +```js +compactWhitespace('Lorem Ipsum'); // 'Lorem Ipsum' +compactWhitespace('Lorem \n Ipsum'); // 'Lorem Ipsum' +``` + +
+ +
[⬆ Back to top](#contents) + ### CSVToArray Converts a comma-separated values (CSV) string to a 2D array. diff --git a/docs/about.html b/docs/about.html index e7506e1bf..4cd8c918e 100644 --- a/docs/about.html +++ b/docs/about.html @@ -415,6 +415,7 @@