# to-rotated

> Rotate an array by a given number of steps

Latest version **1.0.0** (published 2024-05-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-rotated
pnpm add to-rotated
yarn add to-rotated
bun add to-rotated
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-05-22 |
| First published | 2024-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 47 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | array, rotate, rotation, rotated, shift, immutable, steps, cycle, cycling, cycled, move |

## Links

- npm: https://www.npmjs.com/package/to-rotated
- Repository: https://github.com/sindresorhus/to-rotated
- Homepage: https://github.com/sindresorhus/to-rotated#readme
- Issues: https://github.com/sindresorhus/to-rotated/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/to-rotated

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2024-05-22

## README

# to-rotated

> Rotate an array by a given number of steps

Array rotation shifts the elements left or right by a certain number of steps. Elements that move past the end reappear at the beginning. For example, rotating `[1, 2, 3, 4, 5]` by 2 steps to the right results in `[4, 5, 1, 2, 3]`.

## Install

```sh
npm install to-rotated
```

## Usage

```js
import toRotated from 'to-rotated';

console.log(toRotated([1, 2, 3, 4, 5], 2));
//=> [4, 5, 1, 2, 3]

console.log(toRotated([1, 2, 3, 4, 5], -2));
//=> [3, 4, 5, 1, 2]
```

## API

### toRotated(array, steps)

Returns a new array that is rotated by the given number of steps.

---
_Source: https://npm.io/package/to-rotated · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
