UNPKG

@extra-array/rotate

Version:
15 lines (14 loc) 296 B
'use strict'; function mod(x, y) { return x - y * Math.floor(x / y); } function concat$(x, ...ys) { for (var y of ys) x.push(...y); return x; } function rotate(x, n = 0) { var n = mod(n, x.length); return concat$(x.slice(n), x.slice(0, n)); } module.exports = rotate;