mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Refactor HLS API: Get rid of specialized Manifest* classes, use Input instead. Add unhydrated InputTracks, InputTrack compatibility, InputTrack queries
This commit is contained in:
+31
@@ -932,6 +932,21 @@ export const arrayArgmin = <T>(array: T[], getValue: (item: T) => number): numbe
|
||||
return minIndex;
|
||||
};
|
||||
|
||||
export const arrayArgmax = <T>(array: T[], getValue: (item: T) => number): number => {
|
||||
let maxIndex = -1;
|
||||
let maxValue = -Infinity;
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const value = getValue(array[i]!);
|
||||
if (value > maxValue) {
|
||||
maxValue = value;
|
||||
maxIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
return maxIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* A rational number; a ratio of two integers.
|
||||
* @group Miscellaneous
|
||||
@@ -997,3 +1012,19 @@ export const validateRectangle = (rect: Rectangle, propertyPath: string) => {
|
||||
throw new TypeError(`${propertyPath}.height must be a non-negative integer.`);
|
||||
}
|
||||
};
|
||||
|
||||
export const asc = (value: number | null) => {
|
||||
return value ?? Infinity; // nulls last
|
||||
};
|
||||
|
||||
export const desc = (value: number | null) => {
|
||||
return -(value ?? -Infinity); // nulls last
|
||||
};
|
||||
|
||||
export const prefer = (value: boolean) => {
|
||||
return -value;
|
||||
};
|
||||
|
||||
export type NonFunctionKeys<T> = {
|
||||
[K in keyof T]-?: T[K] extends ((...args: never[]) => unknown) ? never : K
|
||||
}[keyof T];
|
||||
|
||||
Reference in New Issue
Block a user