Travis build: 1085
This commit is contained in:
59
README.md
59
README.md
@ -111,6 +111,7 @@ average(1, 2, 3);
|
||||
* [`isSorted`](#issorted)
|
||||
* [`join`](#join)
|
||||
* [`last`](#last)
|
||||
* [`longestItem`](#longestitem)
|
||||
* [`mapObject`](#mapobject)
|
||||
* [`maxN`](#maxn)
|
||||
* [`minN`](#minn)
|
||||
@ -339,15 +340,6 @@ average(1, 2, 3);
|
||||
|
||||
</details>
|
||||
|
||||
### _Uncategorized_
|
||||
|
||||
<details>
|
||||
<summary>View contents</summary>
|
||||
|
||||
* [`longestItem`](#longestitem)
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
## 🔌 Adapter
|
||||
|
||||
@ -1107,6 +1099,32 @@ last([1, 2, 3]); // 3
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### longestItem
|
||||
|
||||
Takes any number of iterable objects or objects with a `length` property and returns the longest one.
|
||||
|
||||
Use `Array.sort()` to sort all arguments by `length`, return the first (longest) one.
|
||||
|
||||
```js
|
||||
const longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0];
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
longestItem('this', 'is', 'a', 'testcase'); // 'testcase'
|
||||
longestItem(...['a', 'ab', 'abc']); // 'abc'
|
||||
longestItem(...['a', 'ab', 'abc'], 'abcd'); // 'abcd'
|
||||
longestItem([1, 2, 3], [1, 2], [1, 2, 3, 4, 5]); // [1, 2, 3, 4, 5]
|
||||
longestItem([1, 2, 3], 'foobar'); // 'foobar'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### mapObject
|
||||
|
||||
Maps the values of an array to an object using a function, where the key-value pairs consist of the original value as the key and the mapped value.
|
||||
@ -5266,29 +5284,6 @@ yesNo('Foo', true); // true
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
---
|
||||
## _Uncategorized_
|
||||
|
||||
### longestItem
|
||||
|
||||
Takes any number of iterable objects or objects with a `length` property and returns the longest one.
|
||||
|
||||
Use `Array.sort()` to sort all arguments by `length`, return the first (longest) one.
|
||||
|
||||
```js
|
||||
const longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0];
|
||||
```
|
||||
|
||||
```js
|
||||
longestItem('this', 'is', 'a', 'testcase'); // 'testcase'
|
||||
longestItem(...['a', 'ab', 'abc']); // 'abc'
|
||||
longestItem(...['a', 'ab', 'abc'], 'abcd'); // 'abcd'
|
||||
longestItem([1, 2, 3], [1, 2], [1, 2, 3, 4, 5]); // [1, 2, 3, 4, 5]
|
||||
longestItem([1, 2, 3], 'foobar'); // 'foobar'
|
||||
```
|
||||
|
||||
<br>[⬆ back to top](#table-of-contents)
|
||||
|
||||
|
||||
## Collaborators
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user