https://github.com/sanketmaru/array-rotate
Rotate an array by n positions
https://github.com/sanketmaru/array-rotate
Last synced: about 2 months ago
JSON representation
Rotate an array by n positions
- Host: GitHub
- URL: https://github.com/sanketmaru/array-rotate
- Owner: sanketmaru
- License: mit
- Created: 2015-06-01T06:33:08.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-01T13:02:02.000Z (about 10 years ago)
- Last Synced: 2025-03-15T15:07:15.579Z (3 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# array-rotate [](https://travis-ci.org/sanketmaru/array-rotate)
> Rotates an array of numbers
## Install
```
$ npm install --save array-rotate
```## Usage
```js
var rotateArray = require('array-rotate');
var arr = rotateArray.createArray(1,2,3,4,5,6);
var positionToRotate = 2;var newArr = rotateArray.rotateByLast(arr, position);
//=> [5,6,1,2,3,4]
```## API
### rotateArray.createArray
Creates anarray.
### rotateArray.rotateByLast
Rotates an array by n positions from last.