Travis build: 238
This commit is contained in:
41
README.md
41
README.md
@ -174,6 +174,9 @@
|
||||
* [`UUIDGenerator`](#uuidgenerator)
|
||||
* [`validateNumber`](#validatenumber)
|
||||
|
||||
### _Uncategorized_
|
||||
* [`randomHexColorCode`](#randomhexcolorcode)
|
||||
|
||||
## Adapter
|
||||
|
||||
### call
|
||||
@ -2057,18 +2060,28 @@ const toCamelCase = str =>
|
||||
### 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.
|
||||
Breaks the string into words.
|
||||
A word is defined as following:-
|
||||
-> Beginning with two or more capital letters, e.g. XML or FM
|
||||
-> Begin with a capital letter followed by lower case letters with optional trailing numbers, e.g. Hello or Http2
|
||||
-> Contain nothing but lower case letters with optional trailing numbers, e.g. hello or http2
|
||||
-> Individual upper letters, e.g T.M.N.T
|
||||
-> Groups of numbers, e.g. 555-555-5555
|
||||
|
||||
For more detailed explanation of this Regex [Visit this Site](https://regex101.com/r/bMCgAB/1)
|
||||
|
||||
```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;
|
||||
let regex = rx = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
||||
return str.match(regex).map(x =>{
|
||||
return x.toLowerCase();
|
||||
}).join('-');
|
||||
}
|
||||
// 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"
|
||||
// toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') -> "i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-xml-and-html"
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
@ -2377,6 +2390,26 @@ const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) ==
|
||||
// validateNumber('10') -> true
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
## _Uncategorized_
|
||||
|
||||
### randomHexColorCode
|
||||
|
||||
Generates a random hexadecimal color code.
|
||||
|
||||
Use `Math.random` to generate a random number and limit that number to fall in between 0 and 16 using `Math.floor`. Use the generated random number as index to access a character from 0 to F. Append it to `color` till the length is not `7`.
|
||||
|
||||
```js
|
||||
const randomHexColorCode = () => {
|
||||
let color = '#';
|
||||
while(color.length < 7) color += '0123456789ABCDEF'[Math.floor(Math.random() * 16)];
|
||||
return color;
|
||||
}
|
||||
// randomHexColorCode() -> "#e34155"
|
||||
// randomHexColorCode() -> "#fd73a6"
|
||||
// randomHexColorCode() -> "#4144c6"
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
## Credits
|
||||
|
||||
@ -235,6 +235,9 @@
|
||||
<a class="sublink-1" href="#uuidgenerator">UUIDGenerator</a>
|
||||
<a class="sublink-1" href="#validatenumber">validateNumber</a>
|
||||
|
||||
<h3>Uncategorized
|
||||
</h3><a class="sublink-1" href="#randomhexcolorcode">randomHexColorCode</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>
|
||||
@ -1300,16 +1303,25 @@ Combine characters to get a string using <code>join('')</code>.</p>
|
||||
</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>
|
||||
Breaks the string into words.
|
||||
A word is defined as following:-
|
||||
-> Beginning with two or more capital letters, e.g. XML or FM
|
||||
-> Begin with a capital letter followed by lower case letters with optional trailing numbers, e.g. Hello or Http2
|
||||
-> Contain nothing but lower case letters with optional trailing numbers, e.g. hello or http2
|
||||
-> Individual upper letters, e.g T.M.N.T
|
||||
-> Groups of numbers, e.g. 555-555-5555</p>
|
||||
<p>For more detailed explanation of this Regex <a href="https://regex101.com/r/bMCgAB/1">Visit this Site</a></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;
|
||||
let regex = rx = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
||||
return str.match(regex).map(x =>{
|
||||
return x.toLowerCase();
|
||||
}).join('-');
|
||||
}
|
||||
// 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"
|
||||
// toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') -> "i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-xml-and-html"
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="tosnakecase">toSnakeCase</h3></div><div class="section double-padded">
|
||||
<p>Converts a string to snakecase.</p>
|
||||
@ -1479,6 +1491,19 @@ 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="randomhexcolorcode">randomHexColorCode</h3></div><div class="section double-padded">
|
||||
<p>Generates a random hexadecimal color code.</p>
|
||||
<p>Use <code>Math.random</code> to generate a random number and limit that number to fall in between 0 and 16 using <code>Math.floor</code>. Use the generated random number as index to access a character from 0 to F. Append it to <code>color</code> till the length is not <code>7</code>.</p>
|
||||
<pre><code class="language-js">const randomHexColorCode = () => {
|
||||
let color = '#';
|
||||
while(color.length < 7) color += '0123456789ABCDEF'[Math.floor(Math.random() * 16)];
|
||||
return color;
|
||||
}
|
||||
// randomHexColorCode() -> "#e34155"
|
||||
// randomHexColorCode() -> "#fd73a6"
|
||||
// randomHexColorCode() -> "#4144c6"
|
||||
</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>
|
||||
|
||||
@ -94,6 +94,7 @@ promisify:adapter
|
||||
pull:array
|
||||
pullAtIndex:array
|
||||
pullAtValue:array
|
||||
randomHexColorCode:uncategorized
|
||||
randomIntegerInRange:math
|
||||
randomNumberInRange:math
|
||||
readFileLines:node
|
||||
|
||||
Reference in New Issue
Block a user