Skip to content
Subhajit Sahu edited this page May 12, 2020 · 19 revisions

Rotates values in iterable. 🏃 📼 📦 🌔 📒

iterable.rotate(x, [n]);
// x: an iterable
// n: rotate amount (-ve: left, +ve: right) (0)
const iterable = require('extra-iterable');

var x = [1, 2, 3, 4];
[...iterable.rotate(x, 1)];
// [ 2, 3, 4, 1 ]

[...iterable.rotate(x, 2)];
// [ 3, 4, 1, 2 ]

[...iterable.rotate(x, -1)];
// [ 4, 1, 2, 3 ]

references

Clone this wiki locally