/** Same as `array.slice(start, end)`, but wraps around the end of the array. */ export function sliceWrap(array: T[], start: number, end: number) { if (array.length === 0) return [] const result: typeof array = [] for (let i = start; i < end; i++) { result.push(array[i % array.length]!) } return result }