Travis build: 1179

This commit is contained in:
30secondsofcode
2018-01-11 10:28:20 +00:00
parent 66a78ee7b5
commit 84fcddd42c
7 changed files with 109 additions and 6 deletions

View File

@ -206,6 +206,7 @@ average(1, 2, 3);
<summary>View contents</summary> <summary>View contents</summary>
* [`average`](#average) * [`average`](#average)
* [`averageBy`](#averageby)
* [`clampNumber`](#clampnumber) * [`clampNumber`](#clampnumber)
* [`digitize`](#digitize) * [`digitize`](#digitize)
* [`distance`](#distance) * [`distance`](#distance)
@ -221,7 +222,9 @@ average(1, 2, 3);
* [`isPrime`](#isprime) * [`isPrime`](#isprime)
* [`lcm`](#lcm) * [`lcm`](#lcm)
* [`luhnCheck`](#luhncheck) * [`luhnCheck`](#luhncheck)
* [`maxBy`](#maxby)
* [`median`](#median) * [`median`](#median)
* [`minBy`](#minby)
* [`percentile`](#percentile) * [`percentile`](#percentile)
* [`powerset`](#powerset) * [`powerset`](#powerset)
* [`primes`](#primes) * [`primes`](#primes)
@ -231,6 +234,7 @@ average(1, 2, 3);
* [`sdbm`](#sdbm) * [`sdbm`](#sdbm)
* [`standardDeviation`](#standarddeviation) * [`standardDeviation`](#standarddeviation)
* [`sum`](#sum) * [`sum`](#sum)
* [`sumBy`](#sumby)
* [`sumPower`](#sumpower) * [`sumPower`](#sumpower)
* [`toSafeInteger`](#tosafeinteger) * [`toSafeInteger`](#tosafeinteger)
@ -2871,6 +2875,28 @@ average(1, 2, 3); // 2
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### averageBy
Returns the average of an array, after mapping each element to a value using the provided function.
Use `Array.map()` to map each element to the value returned by `fn`, `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
```js
const averageBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0) / arr.length;
```
<details>
<summary>Examples</summary>
```js
averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 5
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### clampNumber ### clampNumber
Clamps `num` within the inclusive range specified by the boundary values `a` and `b`. Clamps `num` within the inclusive range specified by the boundary values `a` and `b`.
@ -3297,6 +3323,28 @@ luhnCheck(123456789); // false
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### maxBy
Returns the maximum value of an array, after mapping each element to a value using the provided function.
Use `Array.map()` to map each element to the value returned by `fn`, `Math.max()` to get the maximum value.
```js
const maxBy = (arr, fn) => Math.max(...arr.map(fn));
```
<details>
<summary>Examples</summary>
```js
maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### median ### median
Returns the median of an array of numbers. Returns the median of an array of numbers.
@ -3324,6 +3372,28 @@ median([5, 6, 50, 1, -5]); // 5
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### minBy
Returns the minimum value of an array, after mapping each element to a value using the provided function.
Use `Array.map()` to map each element to the value returned by `fn`, `Math.min()` to get the maximum value.
```js
const minBy = (arr, fn) => Math.min(...arr.map(fn));
```
<details>
<summary>Examples</summary>
```js
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### percentile ### percentile
Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.
@ -3546,6 +3616,28 @@ sum(...[1, 2, 3, 4]); // 10
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### sumBy
Returns the sum of an array, after mapping each element to a value using the provided function.
Use `Array.map()` to map each element to the value returned by `fn`, `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`.
```js
const sumBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0);
```
<details>
<summary>Examples</summary>
```js
sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 20
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### sumPower ### sumPower
Returns the sum of the powers of all the numbers from `start` to `end` (both inclusive). Returns the sum of the powers of all the numbers from `start` to `end` (both inclusive).
@ -5207,6 +5299,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
const newPost = { const newPost = {
"userId": 1, "userId": 1,
"id": 1337, "id": 1337,

File diff suppressed because one or more lines are too long

View File

@ -5,9 +5,9 @@ Returns the average of an array, after mapping each element to a value using the
Use `Array.map()` to map each element to the value returned by `fn`, `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array. Use `Array.map()` to map each element to the value returned by `fn`, `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
```js ```js
const averageBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0)/arr.length; const averageBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0) / arr.length;
``` ```
```js ```js
averageBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 5 averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 5
``` ```

View File

@ -28,6 +28,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
const newPost = { const newPost = {
"userId": 1, "userId": 1,
"id": 1337, "id": 1337,

View File

@ -9,5 +9,5 @@ const maxBy = (arr, fn) => Math.max(...arr.map(fn));
``` ```
```js ```js
maxBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 8 maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
``` ```

View File

@ -9,5 +9,5 @@ const minBy = (arr, fn) => Math.min(...arr.map(fn));
``` ```
```js ```js
minBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 8 minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
``` ```

View File

@ -9,5 +9,5 @@ const sumBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0);
``` ```
```js ```js
sumBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 20 sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 20
``` ```