# @snickbit/cycle

> Helper function and class to cycle through an array of values

Latest version **1.0.27** (published 2023-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @snickbit/cycle
pnpm add @snickbit/cycle
yarn add @snickbit/cycle
bun add @snickbit/cycle
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.27 |
| Published | 2023-08-04 |
| First published | 2022-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 14.17 |
| Dependencies | 1 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | snickbit |

## Links

- npm: https://www.npmjs.com/package/@snickbit/cycle
- npm.io page: https://npm.io/package/@snickbit/cycle

## Dependencies (1)

- [@snickbit/utilities](https://npm.io/package/@snickbit/utilities.md) 3.12.0

## Recent versions

- 1.0.27 (latest) — 2023-08-04
- 1.0.1 (next) — 2022-08-26
- 1.0.26 — 2023-08-04
- 1.0.25 — 2023-07-25
- 1.0.24 — 2023-07-20
- 1.0.23 — 2023-07-20
- 1.0.22 — 2023-07-19
- 1.0.21 — 2023-06-29
- 1.0.20 — 2023-05-23
- 1.0.19 — 2023-05-23
- 1.0.18 — 2023-05-16
- 1.0.17 — 2023-03-27
- 1.0.16 — 2023-03-23
- 1.0.15 — 2023-03-03
- 1.0.14 — 2023-03-03
- … 46 more at https://npm.io/package/@snickbit/cycle/versions

## README

# @snickbit/cycle

<!--START_SECTION:readmes-description-->

Helper function and class to cycle through an array of values

<!--END_SECTION:readmes-description-->

## Installation

```bash
yarn add @snickbit/cycle
```

```bash
npm add @snickbit/cycle
```

## Basic Usage

```js
import {Cycle} from '@snickbit/cycle'

const cycle = new Cycle([1, 2, 3])

console.log(cycle.next()) // 1
console.log(cycle.next()) // 2
console.log(cycle.next()) // 3
console.log(cycle.next()) // 1
console.log(cycle.current()) // 1
console.log(cycle.prev()) // 3
```

## Presets

Cycle comes with few presets for common uses. More to come as needed.

### Usage

```js
const hexColorCycle = new Cycle('hex')
```

### ansi

```json
[
	"red",
	"green",
	"yellow",
	"magenta",
	"cyan",
	"redBright",
	"greenBright",
	"yellowBright",
	"blueBright",
	"magentaBright",
	"cyanBright"
]
```

### ansiBackgrounds

```json
[
	"bgBlack",
	"bgRed",
	"bgGreen",
	"bgYellow",
	"bgBlue",
	"bgMagenta",
	"bgCyan",
	"bgWhite",
	"bgBlackBright",
	"bgRedBright",
	"bgGreenBright",
	"bgYellowBright",
	"bgBlueBright",
	"bgMagentaBright",
	"bgCyanBright",
	"bgWhiteBright"
]
```

### ansiForegrounds

```json
[
	"red",
	"green",
	"yellow",
	"blue",
	"magenta",
	"cyan",
	"white",
	"gray",
	"redBright",
	"greenBright",
	"yellowBright",
	"blueBright",
	"magentaBright",
	"cyanBright",
	"whiteBright"
]
```

### ansiAll

```json
[
	"red",
	"green",
	"yellow",
	"blue",
	"magenta",
	"cyan",
	"white",
	"gray",
	"redBright",
	"greenBright",
	"yellowBright",
	"blueBright",
	"magentaBright",
	"cyanBright",
	"whiteBright",
	"bgBlack",
	"bgRed",
	"bgGreen",
	"bgYellow",
	"bgBlue",
	"bgMagenta",
	"bgCyan",
	"bgWhite",
	"bgBlackBright",
	"bgRedBright",
	"bgGreenBright",
	"bgYellowBright",
	"bgBlueBright",
	"bgMagentaBright",
	"bgCyanBright",
	"bgWhiteBright"
]
```

### hex

```json
[
	"#FFC400",
	"#F9F1A5",
	"#15B40C",
	"#61D6D6",
	"#3A96DD",
	"#3B78FF",
	"#7B1689",
	"#B4009E",
	"#E74856",
	"#C50F1F"
]
```

### rgb

```json
[
	"rgb(255,196,0)",
	"rgb(249,241,165)",
	"rgb(21,180,12)",
	"rgb(97,214,214)",
	"rgb(58,150,221)",
	"rgb(59,120,255)",
	"rgb(123,22,137)",
	"rgb(180,0,158)",
	"rgb(231,72,86)",
	"rgb(197,15,31)"
]
```

### quasar

```json
[
	"pink",
	"purple",
	"deep-purple",
	"indigo",
	"blue",
	"light-blue",
	"cyan",
	"teal",
	"green",
	"light-green",
	"orange",
	"deep-orange",
	"brown",
	"grey",
	"blue-grey"
]
```

## Documentation

### [API Docs](../../README.md)

### [CHANGELOG](CHANGELOG.md)

## License

Copyright (c) 2022 - **Nicholas Lowe** aka **Snickbit**

[MIT License](../../LICENSE)

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