All files / apps/developer-portal/app/utils neighbours.ts

100% Statements 2/2
87.5% Branches 7/8
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6  20x        
/** The items either side of `index`, or neither when `index` is -1 because the item isn't listed. */
export const neighbours = <T>(items: readonly T[], index: number) => ({
    previous: index > 0 ? (items[index - 1] ?? null) : null,
    next: index === -1 ? null : (items[index + 1] ?? null),
});