UNPKG

422 BJavaScriptView Raw
1/** @internal */
2export function createCmp(cmp) {
3 return (...items) => {
4 const count = items.length;
5 if (count === 0) {
6 throw new Error('Must provide one or more arguments');
7 }
8 let result = items[0];
9 for (let i = 1; i < count; i++) {
10 if (cmp(items[i], result)) {
11 result = items[i];
12 }
13 }
14 return result;
15 };
16}