A small utility function used to loop through an array and easily access the previous and next sibling of the current item
pnpm add sibs
npm install sibs
yarn add sibs
import sibs from 'sibs';
const array = [{}, {}, {}];
for (const [previous, current, next] of sibs(array)) {
}
import sibs from 'sibs';
const array = [{}, {}, {}];
for (const [previous, current, next, index] of sibs(array)) {
}
import sibs from 'sibs';
interface Item {
id: string;
}
const array: Item[] = [...];
for (const item of sibs(array)) {
const [
previous, // Item | undefined
current, // Item
next, // Item | undefined
index, // number
] = item;
}