@extra-array/rotate

Rotates values in array.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/rotate
1622.10.19a year ago3 years agoMinified + gzip package size for @extra-array/rotate in KB

Readme

Rotates values in array. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Alternatives: rotate, rotate$.
Similar: repeat, cycle, rotate, reverse.

This is part of package extra-array.



array.rotate(x, [n]);
// x: an array
// n: rotate amount (+ve: left, -ve: right)

const array = require("extra-array");

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

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

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



References