Given an array of items return the final item that wins the comparison condition. Useful for more complicated min/max.
import*as
import _
_from'radashi'
const
constgods: {
name:string;
power:number;
}[]
gods= [
{
name: string
name: 'Ra',
power: number
power: 100,
},
{
name: string
name: 'Zeus',
power: number
power: 98,
},
{
name: string
name: 'Loki',
power: number
power: 72,
},
]
const
constboilByPower: {
name:string;
power:number;
} |null
boilByPower=
import _
_.
boil<{
name:string;
power:number;
}>(array:readonly {
name:string;
power:number;
}[], compareFunc: (a: {
name:string;
power:number;
}, b: {
name:string;
power:number;
}) => {
name:string;
power:number;
}): {
name:string;
power:number;
} |null
export boil
Go through a list of items, starting with the first item, and
comparing with the second. Keep the one you want then compare that
to the next item in the list with the same.