rotate
Problem
You need to shift items in a circular buffer — moving the first item to the end, or rotating a carousel.
Solution
Use rotate(array, positions, options?) to rotate left (positive) or right (negative).
ts
import { rotate } from '@vielzeug/arsenal';
rotate([1, 2, 3, 4, 5], 2); // [3, 4, 5, 1, 2]
rotate([1, 2, 3, 4, 5], -1); // [5, 1, 2, 3, 4]Pitfalls
positionsis taken modulo the array length, so rotating byn * lengthis a no-op.