@naturalcycles/js-lib 14.209.0 → 14.210.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -186,8 +186,8 @@ export declare function _maxOrUndefined<T>(array: T[]): NonNullable<T> | undefin
|
|
|
186
186
|
* Filters out nullish values (undefined and null).
|
|
187
187
|
*/
|
|
188
188
|
export declare function _max<T>(array: T[]): NonNullable<T>;
|
|
189
|
-
export declare function _maxBy<T>(array: T[], mapper: Mapper<T, number | undefined>): T;
|
|
190
|
-
export declare function _minBy<T>(array: T[], mapper: Mapper<T, number | undefined>): T;
|
|
191
|
-
export declare function _maxByOrUndefined<T>(array: T[], mapper: Mapper<T, number | undefined>): T | undefined;
|
|
192
|
-
export declare function _minByOrUndefined<T>(array: T[], mapper: Mapper<T, number | undefined>): T | undefined;
|
|
189
|
+
export declare function _maxBy<T>(array: T[], mapper: Mapper<T, number | string | undefined>): T;
|
|
190
|
+
export declare function _minBy<T>(array: T[], mapper: Mapper<T, number | string | undefined>): T;
|
|
191
|
+
export declare function _maxByOrUndefined<T>(array: T[], mapper: Mapper<T, number | string | undefined>): T | undefined;
|
|
192
|
+
export declare function _minByOrUndefined<T>(array: T[], mapper: Mapper<T, number | string | undefined>): T | undefined;
|
|
193
193
|
export declare function _zip<T1, T2>(array1: T1[], array2: T2[]): [T1, T2][];
|
package/package.json
CHANGED
package/src/array/array.util.ts
CHANGED
|
@@ -395,13 +395,13 @@ export function _max<T>(array: T[]): NonNullable<T> {
|
|
|
395
395
|
return a.reduce((max, item) => (max >= item ? max : item))
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
export function _maxBy<T>(array: T[], mapper: Mapper<T, number | undefined>): T {
|
|
398
|
+
export function _maxBy<T>(array: T[], mapper: Mapper<T, number | string | undefined>): T {
|
|
399
399
|
const max = _maxByOrUndefined(array, mapper)
|
|
400
400
|
if (max === undefined) throw new Error(`_maxBy returned undefined`)
|
|
401
401
|
return max
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
export function _minBy<T>(array: T[], mapper: Mapper<T, number | undefined>): T {
|
|
404
|
+
export function _minBy<T>(array: T[], mapper: Mapper<T, number | string | undefined>): T {
|
|
405
405
|
const min = _minByOrUndefined(array, mapper)
|
|
406
406
|
if (min === undefined) throw new Error(`_minBy returned undefined`)
|
|
407
407
|
return min
|
|
@@ -411,11 +411,11 @@ export function _minBy<T>(array: T[], mapper: Mapper<T, number | undefined>): T
|
|
|
411
411
|
|
|
412
412
|
export function _maxByOrUndefined<T>(
|
|
413
413
|
array: T[],
|
|
414
|
-
mapper: Mapper<T, number | undefined>,
|
|
414
|
+
mapper: Mapper<T, number | string | undefined>,
|
|
415
415
|
): T | undefined {
|
|
416
416
|
if (!array.length) return
|
|
417
417
|
let maxItem: T | undefined
|
|
418
|
-
let max: number | undefined
|
|
418
|
+
let max: number | string | undefined
|
|
419
419
|
array.forEach((item, i) => {
|
|
420
420
|
const v = mapper(item, i)
|
|
421
421
|
if (v !== undefined && (max === undefined || v > max)) {
|
|
@@ -429,11 +429,11 @@ export function _maxByOrUndefined<T>(
|
|
|
429
429
|
|
|
430
430
|
export function _minByOrUndefined<T>(
|
|
431
431
|
array: T[],
|
|
432
|
-
mapper: Mapper<T, number | undefined>,
|
|
432
|
+
mapper: Mapper<T, number | string | undefined>,
|
|
433
433
|
): T | undefined {
|
|
434
434
|
if (!array.length) return
|
|
435
435
|
let minItem: T | undefined
|
|
436
|
-
let min: number | undefined
|
|
436
|
+
let min: number | string | undefined
|
|
437
437
|
array.forEach((item, i) => {
|
|
438
438
|
const v = mapper(item, i)
|
|
439
439
|
if (v !== undefined && (min === undefined || v < min)) {
|