Travis build: 887
This commit is contained in:
51
README.md
51
README.md
@ -286,6 +286,16 @@
|
||||
|
||||
</details>
|
||||
|
||||
### _Uncategorized_
|
||||
|
||||
<details>
|
||||
<summary>View contents</summary>
|
||||
|
||||
* [`maxN`](#maxn)
|
||||
* [`minN`](#minn)
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
## 🔌 Adapter
|
||||
|
||||
@ -5130,6 +5140,47 @@ yesNo('Foo', true); // true
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
---
|
||||
## _Uncategorized_
|
||||
|
||||
### maxN
|
||||
|
||||
Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in descending order).
|
||||
|
||||
Sort's the array's shallow copy in descending order and returns the first n elements
|
||||
|
||||
Skip the second argument to get a single element(in the form of a array)
|
||||
```js
|
||||
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||
```
|
||||
|
||||
```js
|
||||
maxN([1, 2, 3]); // [3]
|
||||
maxN([1, 2, 3], 2); // [3,2]
|
||||
maxN([1, 2, 3], 4); // [3,2,1]
|
||||
```
|
||||
|
||||
<br>[⬆ back to top](#table-of-contents)
|
||||
|
||||
|
||||
### minN
|
||||
|
||||
Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in ascending order).
|
||||
|
||||
Sort's the array's shallow copy in ascending order and returns the first n elements
|
||||
|
||||
Skip the second argument to get a single element(in the form of a array)
|
||||
```js
|
||||
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||
```
|
||||
```js
|
||||
minN([1, 2, 3]); // [1]
|
||||
minN([1, 2, 3], 2); // [1,2]
|
||||
minN([1, 2, 3], 4); // [1,2,3]
|
||||
```
|
||||
|
||||
<br>[⬆ back to top](#table-of-contents)
|
||||
|
||||
|
||||
## Collaborators
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -5,12 +5,12 @@ Returns the `n` maximum elements from the provided array. If `n` is greater than
|
||||
Sort's the array's shallow copy in descending order and returns the first n elements
|
||||
|
||||
Skip the second argument to get a single element(in the form of a array)
|
||||
``` js
|
||||
```js
|
||||
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||
```
|
||||
|
||||
``` js
|
||||
maxN([1,2,3]); // [3]
|
||||
maxN([1,2,3],2); // [3,2]
|
||||
maxN([1,2,3],4); // [3,2,1]
|
||||
```js
|
||||
maxN([1, 2, 3]); // [3]
|
||||
maxN([1, 2, 3], 2); // [3,2]
|
||||
maxN([1, 2, 3], 4); // [3,2,1]
|
||||
```
|
||||
|
||||
@ -5,12 +5,11 @@ Returns the `n` minimum elements from the provided array. If `n` is greater than
|
||||
Sort's the array's shallow copy in ascending order and returns the first n elements
|
||||
|
||||
Skip the second argument to get a single element(in the form of a array)
|
||||
``` js
|
||||
```js
|
||||
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||
|
||||
```
|
||||
``` js
|
||||
minN([1,2,3]); // [1]
|
||||
minN([1,2,3],2); // [1,2]
|
||||
minN([1,2,3],4); // [1,2,3]
|
||||
```js
|
||||
minN([1, 2, 3]); // [1]
|
||||
minN([1, 2, 3], 2); // [1,2]
|
||||
minN([1, 2, 3], 4); // [1,2,3]
|
||||
```
|
||||
|
||||
@ -96,9 +96,11 @@ lowercaseKeys:object
|
||||
mapObject:array
|
||||
mask:string
|
||||
max:math
|
||||
maxN:uncategorized
|
||||
median:math
|
||||
memoize:function
|
||||
min:math
|
||||
minN:uncategorized
|
||||
negate:logic
|
||||
nthElement:array
|
||||
objectFromPairs:object
|
||||
|
||||
Reference in New Issue
Block a user