Travis build: 211
This commit is contained in:
77
README.md
77
README.md
@ -142,9 +142,11 @@
|
||||
* [`countVowels`](#countvowels)
|
||||
* [`escapeRegExp`](#escaperegexp)
|
||||
* [`fromCamelCase`](#fromcamelcase)
|
||||
* [`repeatString`](#repeatstring)
|
||||
* [`reverseString`](#reversestring)
|
||||
* [`sortCharactersInString`](#sortcharactersinstring)
|
||||
* [`toCamelCase`](#tocamelcase)
|
||||
* [`toKebabCase`](#tokebabcase)
|
||||
* [`truncateString`](#truncatestring)
|
||||
* [`words`](#words)
|
||||
|
||||
@ -167,10 +169,6 @@
|
||||
* [`UUIDGenerator`](#uuidgenerator)
|
||||
* [`validateNumber`](#validatenumber)
|
||||
|
||||
### _Uncategorized_
|
||||
* [`repeatString`](#repeatstring)
|
||||
* [`toKebabCase`](#tokebabcase)
|
||||
|
||||
## Adapter
|
||||
|
||||
### call
|
||||
@ -1961,6 +1959,22 @@ const fromCamelCase = (str, separator = '_') =>
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### 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)
|
||||
|
||||
### reverseString
|
||||
|
||||
Reverses a string.
|
||||
@ -2006,6 +2020,25 @@ const toCamelCase = str =>
|
||||
|
||||
[⬆ 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)
|
||||
|
||||
### truncateString
|
||||
|
||||
Truncates a string up to a specified length.
|
||||
@ -2293,42 +2326,6 @@ 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
|
||||
|
||||
@ -181,9 +181,11 @@
|
||||
<a class="sublink-1" href="#countvowels">countVowels</a>
|
||||
<a class="sublink-1" href="#escaperegexp">escapeRegExp</a>
|
||||
<a class="sublink-1" href="#fromcamelcase">fromCamelCase</a>
|
||||
<a class="sublink-1" href="#repeatstring">repeatString</a>
|
||||
<a class="sublink-1" href="#reversestring">reverseString</a>
|
||||
<a class="sublink-1" href="#sortcharactersinstring">sortCharactersInString</a>
|
||||
<a class="sublink-1" href="#tocamelcase">toCamelCase</a>
|
||||
<a class="sublink-1" href="#tokebabcase">toKebabCase</a>
|
||||
<a class="sublink-1" href="#truncatestring">truncateString</a>
|
||||
<a class="sublink-1" href="#words">words</a>
|
||||
|
||||
@ -206,10 +208,6 @@
|
||||
<a class="sublink-1" href="#uuidgenerator">UUIDGenerator</a>
|
||||
<a class="sublink-1" href="#validatenumber">validateNumber</a>
|
||||
|
||||
<h3>Uncategorized
|
||||
</h3><a class="sublink-1" href="#repeatstring">repeatString</a>
|
||||
<a class="sublink-1" href="#tokebabcase">toKebabCase</a>
|
||||
|
||||
</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height:100%;overflow-y:auto;background:#eceef2;padding:0"><a id="top"> </a><h2 style="text-align:center">Adapter</h2>
|
||||
<div class="card fluid"><div class="section double-padded"><h3 id="call">call</h3></div><div class="section double-padded">
|
||||
<p>Given a key and a set of arguments, call them when given a context. Primarily useful in composition.</p>
|
||||
@ -1225,6 +1223,15 @@ Omit the second argument to use a default separator of <code>_</code>.</p>
|
||||
// fromCamelCase('someLabelThatNeedsToBeCamelized', '-') -> 'some-label-that-needs-to-be-camelized'
|
||||
// fromCamelCase('someJavascriptProperty', '_') -> 'some_javascript_property'
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="repeatstring">repeatString</h3></div><div class="section double-padded">
|
||||
<p>Repeats a string n times using <code>String.repeat()</code></p>
|
||||
<p>If no string is provided the default is <code>""</code> and the default number of times is 2.</p>
|
||||
<pre><code class="language-js">const repeatString = (str="",num=2) => {
|
||||
return num >= 0 ? str.repeat(num) : str;
|
||||
}
|
||||
// repeatString("abc",3) -> 'abcabcabc'
|
||||
// repeatString("abc") -> 'abcabc'
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="reversestring">reverseString</h3></div><div class="section double-padded">
|
||||
<p>Reverses a string.</p>
|
||||
<p>Use <code>split('')</code> and <code>Array.reverse()</code> to reverse the order of the characters in the string.
|
||||
@ -1249,6 +1256,19 @@ Combine characters to get a string using <code>join('')</code>.</p>
|
||||
// toCamelCase("some-javascript-property") -> 'someJavascriptProperty'
|
||||
// toCamelCase("some-mixed_string with spaces_underscores-and-hyphens") -> 'someMixedStringWithSpacesUnderscoresAndHyphens'
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="tokebabcase">toKebabCase</h3></div><div class="section double-padded">
|
||||
<p>Converts a string to <a href="https://en.wikipedia.org/wiki/Letter_case#Special_case_styles">kebab case</a>.
|
||||
Use <code>replace()</code> to add spaces before capital letters, convert <code>toLowerCase()</code>, then <code>replace()</code> underscores and spaces with hyphens.
|
||||
Also check if a string starts with a hyphen and remove it if yes.</p>
|
||||
<pre><code class="language-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"
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="truncatestring">truncateString</h3></div><div class="section double-padded">
|
||||
<p>Truncates a string up to a specified length.</p>
|
||||
<p>Determine if the string's <code>length</code> is greater than <code>num</code>.
|
||||
@ -1407,29 +1427,6 @@ Use <code>Number()</code> to check if the coercion holds.</p>
|
||||
<pre><code class="language-js">const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
||||
// validateNumber('10') -> true
|
||||
</code></pre>
|
||||
</div></div><br/><h2 style="text-align:center">Uncategorized</h2>
|
||||
<div class="card fluid"><div class="section double-padded"><h3 id="repeatstring">repeatString</h3></div><div class="section double-padded">
|
||||
<p>Repeats a string n times using <code>String.repeat()</code></p>
|
||||
<p>If no string is provided the default is <code>""</code> and the default number of times is 2.</p>
|
||||
<pre><code class="language-js">const repeatString = (str="",num=2) => {
|
||||
return num >= 0 ? str.repeat(num) : str;
|
||||
}
|
||||
// repeatString("abc",3) -> 'abcabcabc'
|
||||
// repeatString("abc") -> 'abcabc'
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="tokebabcase">toKebabCase</h3></div><div class="section double-padded">
|
||||
<p>Converts a string to <a href="https://en.wikipedia.org/wiki/Letter_case#Special_case_styles">kebab case</a>.
|
||||
Use <code>replace()</code> to add spaces before capital letters, convert <code>toLowerCase()</code>, then <code>replace()</code> underscores and spaces with hyphens.
|
||||
Also check if a string starts with a hyphen and remove it if yes.</p>
|
||||
<pre><code class="language-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"
|
||||
</code></pre>
|
||||
</div></div><br/>
|
||||
<footer>
|
||||
<p style="display:inline-block"><strong>30 seconds of code</strong> is licensed under the <a href="https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE">CC0-1.0</a> license.<br/>Icons made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="https://www.flaticon.com/">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/">CC 3.0 BY</a>.<br/>Ribbon made by <a href="https://github.com/tholman/github-corners">Tim Holman</a> is licensed by <a href="https://opensource.org/licenses/MIT">The MIT License</a><br/>Built with the <a href="https://minicss.org">mini.css framework</a>.</p>
|
||||
|
||||
Reference in New Issue
Block a user