ran npm run builder
This commit is contained in:
20
README.md
20
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user