Travis build: 209

This commit is contained in:
Travis CI
2017-12-23 19:13:32 +00:00
parent bb2e544011
commit f59259db0d
3 changed files with 69 additions and 0 deletions

View File

@@ -167,6 +167,10 @@
* [`UUIDGenerator`](#uuidgenerator)
* [`validateNumber`](#validatenumber)
### _Uncategorized_
* [`repeatString`](#repeatstring)
* [`toKebabCase`](#tokebabcase)
## Adapter
### call
@@ -2289,6 +2293,42 @@ const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) ==
// validateNumber('10') -> true
```
[⬆ back to top](#table-of-contents)
## _Uncategorized_
### repeatString
Repeats a string n times using `String.repeat()`
If no string is provided the default is `""` and the default number of times is 2.
```js
const repeatString = (str="",num=2) => {
return num >= 0 ? str.repeat(num) : str;
}
// repeatString("abc",3) -> 'abcabcabc'
// repeatString("abc") -> 'abcabc'
```
[⬆ back to top](#table-of-contents)
### toKebabCase
Converts a string to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
Use `replace()` to add spaces before capital letters, convert `toLowerCase()`, then `replace()` underscores and spaces with hyphens.
Also check if a string starts with a hyphen and remove it if yes.
```js
const toKebabCase = str => {
str = str.replace(/([A-Z])/g," $1").toLowerCase().replace(/_/g,' ').replace(/-/g,' ').replace(/\s\s+/g, ' ').replace(/\s/g,'-');
return str.startsWith('-') ? str.slice(1,str.length) : str;
}
// toKebabCase("camelCase") -> 'camel-case'
// toKebabCase("some text") -> 'some-text'
// toKebabCase("some-mixed_string With spaces_underscores-and-hyphens") -> 'some-mixed-string-with-spaces-underscores-and-hyphens'
// toKebabCase("AllThe-small Things") -> "all-the-small-things"
```
[⬆ back to top](#table-of-contents)
## Credits