getPrev()function

getPrev(items: PossibleArray<T>, value: T): T | undefined
ParamType
itemsPossibleArray<T>
The array or iterable to search. required
valueT
The item to find the predecessor of. required
Return
T | undefined
The item preceding value, or undefined if value is missing or first.

Get the previous item in an array or iterable.

Examples

getPrev([1, 2, 3], 2) // 1