arr-rotate
Rotate all items in an array
Last updated 7 years ago by kevva .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install arr-rotate 
SYNC missed versions from official npm registry.

arr-rotate Build Status

Rotate all items in an array

Install

$ npm install arr-rotate

Usage

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']

API

arrRotate(input, num)

input

Type: Array

Array to rotate.

num

Type: number
Default: 0

Number of steps to rotate.

License

MIT © Kevin Martensson

Current Tags

  • 1.0.0                                ...           latest (7 years ago)

1 Versions

  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE