$ npm install arr-rotate
Rotate all items in an array
$ npm install arr-rotate
const arrRotate = require('arr-rotate');
arrRotate(['foo', 'bar', 'unicorn'], 2);
//=> ['bar', 'unicorn', 'foo']
arrRotate(['foo', 'bar', 'unicorn'], 1);
//=> ['unicorn', 'foo', 'bar']
arrRotate(['foo', 'bar', 'unicorn'], -1);
//=> ['bar', 'unicorn', 'foo']
Type: Array
Array to rotate.
Type: number
Default: 0
Number of steps to rotate.
MIT © Kevin Martensson
© 2010 - cnpmjs.org x YWFE | Home | YWFE