Make it clear that the firstTwoMax() function only cares about the first 2 arguments
This commit is contained in:
@ -13,5 +13,5 @@ const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
|
||||
|
||||
```js
|
||||
const firstTwoMax = ary(Math.max, 2);
|
||||
[[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
|
||||
```
|
||||
[[2, 6, 'a'], [6, 4, 8], [10]].map(x => firstTwoMax(...x)); // [6, 6, 10]
|
||||
```
|
||||
|
||||
@ -5,5 +5,5 @@ test('ary is a Function', () => {
|
||||
});
|
||||
const firstTwoMax = ary(Math.max, 2);
|
||||
test('Discards arguments with index >=n', () => {
|
||||
expect([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x))).toEqual([6, 8, 10]);
|
||||
expect([[2, 6, 'a'], [6, 4, 8], [10]].map(x => firstTwoMax(...x))).toEqual([6, 6, 10]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user