Travis build: 229
This commit is contained in:
72
README.md
72
README.md
@ -69,6 +69,7 @@
|
||||
* [`arrayToHtmlList`](#arraytohtmllist)
|
||||
* [`bottomVisible`](#bottomvisible)
|
||||
* [`currentURL`](#currenturl)
|
||||
* [`detectDeviceType`](#detectdevicetype)
|
||||
* [`elementIsVisibleInViewport`](#elementisvisibleinviewport)
|
||||
* [`getScrollPosition`](#getscrollposition)
|
||||
* [`getURLParameters`](#geturlparameters)
|
||||
@ -90,6 +91,9 @@
|
||||
* [`runPromisesInSeries`](#runpromisesinseries)
|
||||
* [`sleep`](#sleep)
|
||||
|
||||
### Logic
|
||||
* [`negate`](#negate)
|
||||
|
||||
### Math
|
||||
* [`arrayAverage`](#arrayaverage)
|
||||
* [`arraySum`](#arraysum)
|
||||
@ -170,10 +174,6 @@
|
||||
* [`UUIDGenerator`](#uuidgenerator)
|
||||
* [`validateNumber`](#validatenumber)
|
||||
|
||||
### _Uncategorized_
|
||||
* [`detectDeviceType`](#detectdevicetype)
|
||||
* [`negate`](#negate)
|
||||
|
||||
## Adapter
|
||||
|
||||
### call
|
||||
@ -449,12 +449,12 @@ const dropElements = (arr, func) => {
|
||||
|
||||
### dropRight
|
||||
|
||||
Returns a new array with `n` elements removed from the right
|
||||
Returns a new array with `n` elements removed from the right.
|
||||
|
||||
Check if `n` is shorter than the given array and use `Array.slice()` to slice it accordingly or return an empty array.
|
||||
Use `Array.slice()` to slice the remove the specified number of elements from the right.
|
||||
|
||||
```js
|
||||
const dropRight = (arr, n = 1) => n < arr.length ? arr.slice(0, arr.length - n) : []
|
||||
const dropRight = (arr, n = 1) => arr.slice(0, -n);
|
||||
//dropRight([1,2,3]) -> [1,2]
|
||||
//dropRight([1,2,3], 2) -> [1]
|
||||
//dropRight([1,2,3], 42) -> []
|
||||
@ -980,6 +980,20 @@ const currentURL = () => window.location.href;
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### detectDeviceType
|
||||
|
||||
Detects wether the website is being opened in a mobile device or a desktop/laptop.
|
||||
|
||||
Use a regular expression to test the `navigator.userAgent` property to figure out if the device is a mobile device or a desktop/laptop.
|
||||
|
||||
```js
|
||||
const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? "Mobile" : "Desktop";
|
||||
// detectDeviceType() -> "Mobile"
|
||||
// detectDeviceType() -> "Desktop"
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### elementIsVisibleInViewport
|
||||
|
||||
Returns `true` if the element specified is visible in the viewport, `false` otherwise.
|
||||
@ -1254,6 +1268,21 @@ async function sleepyWork() {
|
||||
*/
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
## Logic
|
||||
|
||||
### negate
|
||||
|
||||
Negates a predicate function.
|
||||
|
||||
Take a predicate function and apply `not` to it with its arguments.
|
||||
|
||||
```js
|
||||
const negate = func => (...args) => !fun(...args);
|
||||
// filter([1, 2, 3, 4, 5, 6], negate(isEven)) -> [1, 3, 5]
|
||||
// negate(isOdd)(1) -> false
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
## Math
|
||||
|
||||
@ -2348,35 +2377,6 @@ const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) ==
|
||||
// validateNumber('10') -> true
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
## _Uncategorized_
|
||||
|
||||
### detectDeviceType
|
||||
|
||||
Detects wether the website is being opened in a mobile device or a desktop/laptop.
|
||||
|
||||
Use a regular expression to test the `navigator.userAgent` property to figure out if the device is a mobile device or a desktop/laptop.
|
||||
|
||||
```js
|
||||
const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? "Mobile" : "Desktop";
|
||||
// detectDeviceType() -> "Mobile"
|
||||
// detectDeviceType() -> "Desktop"
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### negate
|
||||
|
||||
Negates a predicate function.
|
||||
|
||||
Take a predicate function and apply `not` to it with its arguments.
|
||||
|
||||
```js
|
||||
const negate = func => (...args) => !fun(...args);
|
||||
// filter([1, 2, 3, 4, 5, 6], negate(isEven)) -> [1, 3, 5]
|
||||
// negate(isOdd)(1) -> false
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
## Credits
|
||||
|
||||
@ -130,6 +130,7 @@
|
||||
</h3><a class="sublink-1" href="#arraytohtmllist">arrayToHtmlList</a>
|
||||
<a class="sublink-1" href="#bottomvisible">bottomVisible</a>
|
||||
<a class="sublink-1" href="#currenturl">currentURL</a>
|
||||
<a class="sublink-1" href="#detectdevicetype">detectDeviceType</a>
|
||||
<a class="sublink-1" href="#elementisvisibleinviewport">elementIsVisibleInViewport</a>
|
||||
<a class="sublink-1" href="#getscrollposition">getScrollPosition</a>
|
||||
<a class="sublink-1" href="#geturlparameters">getURLParameters</a>
|
||||
@ -151,6 +152,9 @@
|
||||
<a class="sublink-1" href="#runpromisesinseries">runPromisesInSeries</a>
|
||||
<a class="sublink-1" href="#sleep">sleep</a>
|
||||
|
||||
<h3>Logic
|
||||
</h3><a class="sublink-1" href="#negate">negate</a>
|
||||
|
||||
<h3>Math
|
||||
</h3><a class="sublink-1" href="#arrayaverage">arrayAverage</a>
|
||||
<a class="sublink-1" href="#arraysum">arraySum</a>
|
||||
@ -231,10 +235,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="#detectdevicetype">detectDeviceType</a>
|
||||
<a class="sublink-1" href="#negate">negate</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>
|
||||
@ -388,9 +388,9 @@ Returns the remaining elements.</p>
|
||||
// dropElements([1, 2, 3, 4], n => n >= 3) -> [3,4]
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="dropright">dropRight</h3></div><div class="section double-padded">
|
||||
<p>Returns a new array with <code>n</code> elements removed from the right</p>
|
||||
<p>Check if <code>n</code> is shorter than the given array and use <code>Array.slice()</code> to slice it accordingly or return an empty array.</p>
|
||||
<pre><code class="language-js">const dropRight = (arr, n = 1) => n < arr.length ? arr.slice(0, arr.length - n) : []
|
||||
<p>Returns a new array with <code>n</code> elements removed from the right.</p>
|
||||
<p>Use <code>Array.slice()</code> to slice the remove the specified number of elements from the right.</p>
|
||||
<pre><code class="language-js">const dropRight = (arr, n = 1) => arr.slice(0, -n);
|
||||
//dropRight([1,2,3]) -> [1,2]
|
||||
//dropRight([1,2,3], 2) -> [1]
|
||||
//dropRight([1,2,3], 42) -> []
|
||||
@ -680,6 +680,13 @@ If lengths of the argument-arrays vary, <code>undefined</code> is used where no
|
||||
<pre><code class="language-js">const currentURL = () => window.location.href;
|
||||
// currentUrl() -> 'https://google.com'
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="detectdevicetype">detectDeviceType</h3></div><div class="section double-padded">
|
||||
<p>Detects wether the website is being opened in a mobile device or a desktop/laptop.</p>
|
||||
<p>Use a regular expression to test the <code>navigator.userAgent</code> property to figure out if the device is a mobile device or a desktop/laptop.</p>
|
||||
<pre><code class="language-js">const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? "Mobile" : "Desktop";
|
||||
// detectDeviceType() -> "Mobile"
|
||||
// detectDeviceType() -> "Desktop"
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="elementisvisibleinviewport">elementIsVisibleInViewport</h3></div><div class="section double-padded">
|
||||
<p>Returns <code>true</code> if the element specified is visible in the viewport, <code>false</code> otherwise.</p>
|
||||
<p>Use <code>Element.getBoundingClientRect()</code> and the <code>window.inner(Width|Height)</code> values
|
||||
@ -844,6 +851,14 @@ async function sleepyWork() {
|
||||
}
|
||||
*/
|
||||
</code></pre>
|
||||
</div></div><br/><h2 style="text-align:center">Logic</h2>
|
||||
<div class="card fluid"><div class="section double-padded"><h3 id="negate">negate</h3></div><div class="section double-padded">
|
||||
<p>Negates a predicate function.</p>
|
||||
<p>Take a predicate function and apply <code>not</code> to it with its arguments.</p>
|
||||
<pre><code class="language-js">const negate = func => (...args) => !fun(...args);
|
||||
// filter([1, 2, 3, 4, 5, 6], negate(isEven)) -> [1, 3, 5]
|
||||
// negate(isOdd)(1) -> false
|
||||
</code></pre>
|
||||
</div></div><br/><h2 style="text-align:center">Math</h2>
|
||||
<div class="card fluid"><div class="section double-padded"><h3 id="arrayaverage">arrayAverage</h3></div><div class="section double-padded">
|
||||
<p>Returns the average of an array of numbers.</p>
|
||||
@ -1464,21 +1479,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="detectdevicetype">detectDeviceType</h3></div><div class="section double-padded">
|
||||
<p>Detects wether the website is being opened in a mobile device or a desktop/laptop.</p>
|
||||
<p>Use a regular expression to test the <code>navigator.userAgent</code> property to figure out if the device is a mobile device or a desktop/laptop.</p>
|
||||
<pre><code class="language-js">const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? "Mobile" : "Desktop";
|
||||
// detectDeviceType() -> "Mobile"
|
||||
// detectDeviceType() -> "Desktop"
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="negate">negate</h3></div><div class="section double-padded">
|
||||
<p>Negates a predicate function.</p>
|
||||
<p>Take a predicate function and apply <code>not</code> to it with its arguments.</p>
|
||||
<pre><code class="language-js">const negate = func => (...args) => !fun(...args);
|
||||
// filter([1, 2, 3, 4, 5, 6], negate(isEven)) -> [1, 3, 5]
|
||||
// negate(isOdd)(1) -> false
|
||||
</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