Travis build: 1211 [custom]

This commit is contained in:
30secondsofcode
2019-06-05 09:55:25 +00:00
parent e0e657d171
commit 7c128fdb5b
7 changed files with 45 additions and 42 deletions

View File

@ -4744,6 +4744,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length'); const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true lengthIs4([1,2,3,4]); // true

View File

@ -162,6 +162,7 @@ console<span class="token punctuation">.</span><span class="token function">log<
<span class="token keyword">const</span> lengthIs4 <span class="token operator">=</span> <span class="token function">checkProp</span><span class="token punctuation">(</span>l <span class="token operator">=></span> l <span class="token operator">===</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token string">'length'</span><span class="token punctuation">);</span> <span class="token keyword">const</span> lengthIs4 <span class="token operator">=</span> <span class="token function">checkProp</span><span class="token punctuation">(</span>l <span class="token operator">=></span> l <span class="token operator">===</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token string">'length'</span><span class="token punctuation">);</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([]);</span> <span class="token comment">// false</span> <span class="token function">lengthIs4</span><span class="token punctuation">([]);</span> <span class="token comment">// false</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">]);</span> <span class="token comment">// true</span> <span class="token function">lengthIs4</span><span class="token punctuation">([</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">]);</span> <span class="token comment">// true</span>

File diff suppressed because one or more lines are too long

View File

@ -386,7 +386,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "d0eace2a9fcd0b8e056083e8c3e92574d7da0eee62c6897f7d6c5a94e64a3841" "hash": "e2fe0ff4736e09c616dda81905f39b89a213f4ea1d9d8fec7fb4c393a656ad72"
} }
}, },
{ {

View File

@ -568,7 +568,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "d0eace2a9fcd0b8e056083e8c3e92574d7da0eee62c6897f7d6c5a94e64a3841" "hash": "e2fe0ff4736e09c616dda81905f39b89a213f4ea1d9d8fec7fb4c393a656ad72"
} }
}, },
{ {

View File

@ -27,6 +27,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length'); const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true lengthIs4([1,2,3,4]); // true

View File

@ -3,6 +3,7 @@
These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are. These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are.
## Table of Contents ## Table of Contents
* [`JSONToDate`](#jsontodate) * [`JSONToDate`](#jsontodate)
* [`squareSum`](#squaresum)
* [`binarySearch`](#binarysearch) * [`binarySearch`](#binarysearch)
* [`celsiusToFahrenheit`](#celsiustofahrenheit) * [`celsiusToFahrenheit`](#celsiustofahrenheit)
* [`cleanObj`](#cleanobj) * [`cleanObj`](#cleanobj)
@ -14,7 +15,6 @@ These snippets, while useful and interesting, didn't quite make it into the repo
* [`fibonacciUntilNum`](#fibonacciuntilnum) * [`fibonacciUntilNum`](#fibonacciuntilnum)
* [`heronArea`](#heronarea) * [`heronArea`](#heronarea)
* [`howManyTimes`](#howmanytimes) * [`howManyTimes`](#howmanytimes)
* [`httpDelete`](#httpdelete)
* [`httpPut`](#httpput) * [`httpPut`](#httpput)
* [`isArmstrongNumber`](#isarmstrongnumber) * [`isArmstrongNumber`](#isarmstrongnumber)
* [`isSimilar`](#issimilar) * [`isSimilar`](#issimilar)
@ -26,7 +26,7 @@ These snippets, while useful and interesting, didn't quite make it into the repo
* [`removeVowels`](#removevowels) * [`removeVowels`](#removevowels)
* [`solveRPN`](#solverpn) * [`solveRPN`](#solverpn)
* [`speechSynthesis`](#speechsynthesis) * [`speechSynthesis`](#speechsynthesis)
* [`squareSum`](#squaresum) * [`httpDelete`](#httpdelete)
--- ---
### JSONToDate ### JSONToDate
@ -53,6 +53,27 @@ JSONToDate(/Date(1489525200000)/); // "14/3/2017"
<br>[⬆ Back to top](#contents) <br>[⬆ Back to top](#contents)
### squareSum
Squares each number in an array and then sums the results together.
Use `Array.prototype.reduce()` in combination with `Math.pow()` to iterate over numbers and sum their squares into an accumulator.
```js
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
```
<details>
<summary>Examples</summary>
```js
squareSum(1, 2, 2); // 9
```
</details>
<br>[⬆ Back to top](#contents)
### binarySearch ### binarySearch
Use recursion. Similar to `Array.prototype.indexOf()` that finds the index of a value within an array. Use recursion. Similar to `Array.prototype.indexOf()` that finds the index of a value within an array.
@ -367,38 +388,6 @@ howManyTimes(100, -1); // Infinity
<br>[⬆ Back to top](#contents) <br>[⬆ Back to top](#contents)
### httpDelete
Makes a `DELETE` request to the passed URL.
Use `XMLHttpRequest` web api to make a `delete` request to the given `url`.
Handle the `onload` event, by running the provided `callback` function.
Handle the `onerror` event, by running the provided `err` function.
Omit the third argument, `err` to log the request to the console's error stream by default.
```js
const httpDelete = (url, callback, err = console.error) => {
const request = new XMLHttpRequest();
request.open('DELETE', url, true);
request.onload = () => callback(request);
request.onerror = () => err(request);
request.send();
};
```
<details>
<summary>Examples</summary>
```js
httpDelete('https://website.com/users/123', request => {
console.log(request.responseText);
}); // 'Deletes a user from the database'
```
</details>
<br>[⬆ Back to top](#contents)
### httpPut ### httpPut
Makes a `PUT` request to the passed URL. Makes a `PUT` request to the passed URL.
@ -739,21 +728,32 @@ speechSynthesis('Hello, World'); // // plays the message
<br>[⬆ Back to top](#contents) <br>[⬆ Back to top](#contents)
### squareSum ### httpDelete
Squares each number in an array and then sums the results together. Makes a `DELETE` request to the passed URL.
Use `Array.prototype.reduce()` in combination with `Math.pow()` to iterate over numbers and sum their squares into an accumulator. Use `XMLHttpRequest` web api to make a `delete` request to the given `url`.
Handle the `onload` event, by running the provided `callback` function.
Handle the `onerror` event, by running the provided `err` function.
Omit the third argument, `err` to log the request to the console's error stream by default.
```js ```js
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0); const httpDelete = (url, callback, err = console.error) => {
const request = new XMLHttpRequest();
request.open('DELETE', url, true);
request.onload = () => callback(request);
request.onerror = () => err(request);
request.send();
};
``` ```
<details> <details>
<summary>Examples</summary> <summary>Examples</summary>
```js ```js
squareSum(1, 2, 2); // 9 httpDelete('https://website.com/users/123', request => {
console.log(request.responseText);
}); // 'Deletes a user from the database'
``` ```
</details> </details>