Note: Using StandardJS rules.
function * range(start, end, step = 1) {
while (start <= end) {
yield start
start += step
}
}
Array.from(range(1, 10)) //=> [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
function rotate(array, n) {
while (n > array.length) { n = n - array.length }
while (n < 0) { n = array.length - (n * -1) }
array.push.apply(array, array.splice(0, n))
return array
}