From 4bbc74779177a92e70f82ce6fb41aecee3ba1b82 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 21 Dec 2017 07:50:57 -0500 Subject: [PATCH 1/4] renamed stringToArray... -> words.md --- snippets/stringToArrayOfWords.md | 12 ------------ snippets/words.md | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 snippets/stringToArrayOfWords.md create mode 100644 snippets/words.md diff --git a/snippets/stringToArrayOfWords.md b/snippets/stringToArrayOfWords.md deleted file mode 100644 index 0630fe08a..000000000 --- a/snippets/stringToArrayOfWords.md +++ /dev/null @@ -1,12 +0,0 @@ -### stringToArrayOfWords - -Converts a given string into an array of words. - -Use `String.split()` with a supplied pattern (defaults to non alpha as a regex) to convert to an array of strings. Use `Array.filter()` to remove any empty strings. -Omit the second argument to use the default regex. - -```js -const stringToArrayOfWords = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); -// stringToArrayOfWords("I love javaScript!!") -> ["I", "love", "javaScript"] -// stringToArrayOfWords("python, javaScript & coffee") -> ["python", "javaScript", "coffee"] -``` diff --git a/snippets/words.md b/snippets/words.md new file mode 100644 index 000000000..38a363a40 --- /dev/null +++ b/snippets/words.md @@ -0,0 +1,12 @@ +### words + +Converts a given string into an array of words. + +Use `String.split()` with a supplied pattern (defaults to non alpha as a regex) to convert to an array of strings. Use `Array.filter()` to remove any empty strings. +Omit the second argument to use the default regex. + +```js +const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); +// words("I love javaScript!!") -> ["I", "love", "javaScript"] +// words("python, javaScript & coffee") -> ["python", "javaScript", "coffee"] +``` From a9eb45170516add6f33af01ee315ec3c9d5ccc20 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 21 Dec 2017 07:51:58 -0500 Subject: [PATCH 2/4] ran npm run builder --- README.md | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/README.md b/README.md index d48327a92..17fa7f335 100644 --- a/README.md +++ b/README.md @@ -1812,19 +1812,7 @@ const sortCharactersInString = str => [⬆ back to top](#table-of-contents) -### stringToArrayOfWords - -Converts a given string into an array of words. - -Use `String.split()` with a supplied pattern (defaults to non alpha as a regex) to convert to an array of strings. Use `Array.filter()` to remove any empty strings. -Omit the second argument to use the default regex. - -```js -const stringToArrayOfWords = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); -// stringToArrayOfWords("I love javaScript!!") -> ["I", "love", "javaScript"] -// stringToArrayOfWords("python, javaScript & coffee") -> ["python", "javaScript", "coffee"] -``` - +undefined [⬆ back to top](#table-of-contents) ### toCamelCase From 32c88b116333bcaafacb4361fc3327ef04abc0de Mon Sep 17 00:00:00 2001 From: King Date: Thu, 21 Dec 2017 07:53:11 -0500 Subject: [PATCH 3/4] ran npm run tagger & tagged words:string --- tag_database | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tag_database b/tag_database index 84063917c..dc978b435 100644 --- a/tag_database +++ b/tag_database @@ -103,7 +103,6 @@ sleep:function sortCharactersInString:string speechSynthesis:media standardDeviation:math -stringToArrayOfWords:string symmetricDifference:array tail:array take:array @@ -119,5 +118,6 @@ UUIDGenerator:utility validateEmail:utility validateNumber:utility without:array +words:string zip:array zipObject:array From 29b2f118173fdaf99e78daeb5a28e6a14874ba8a Mon Sep 17 00:00:00 2001 From: King Date: Thu, 21 Dec 2017 08:09:40 -0500 Subject: [PATCH 4/4] ran npm run builder --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 17fa7f335..963d7ef61 100644 --- a/README.md +++ b/README.md @@ -130,9 +130,9 @@ * [`fromCamelCase`](#fromcamelcase) * [`reverseString`](#reversestring) * [`sortCharactersInString`](#sortcharactersinstring) -* [`stringToArrayOfWords`](#stringtoarrayofwords) * [`toCamelCase`](#tocamelcase) * [`truncateString`](#truncatestring) +* [`words`](#words) ### Utility * [`coalesce`](#coalesce) @@ -1812,9 +1812,6 @@ const sortCharactersInString = str => [⬆ back to top](#table-of-contents) -undefined -[⬆ back to top](#table-of-contents) - ### toCamelCase Converts a string to camelcase. @@ -1845,6 +1842,21 @@ const truncateString = (str, num) => // truncateString('boomerang', 7) -> 'boom...' ``` +[⬆ back to top](#table-of-contents) + +### words + +Converts a given string into an array of words. + +Use `String.split()` with a supplied pattern (defaults to non alpha as a regex) to convert to an array of strings. Use `Array.filter()` to remove any empty strings. +Omit the second argument to use the default regex. + +```js +const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); +// words("I love javaScript!!") -> ["I", "love", "javaScript"] +// words("python, javaScript & coffee") -> ["python", "javaScript", "coffee"] +``` + [⬆ back to top](#table-of-contents) ## Utility