# random-array-iterator

> An iterator to iterate an array in random order with controls to requeue or dequeue elements during the iteration

Latest version **1.0.0** (published 2020-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install random-array-iterator
pnpm add random-array-iterator
yarn add random-array-iterator
bun add random-array-iterator
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-11-30 |
| First published | 2020-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/random-array-iterator
- Repository: https://github.com/mafintosh/random-array-iterator
- Issues: https://github.com/mafintosh/random-array-iterator/issues
- npm.io page: https://npm.io/package/random-array-iterator

## Recent versions

- 1.0.0 (latest) — 2020-11-30
- 0.0.0 — 2020-11-30

## README

# random-array-iterator

An iterator to iterate an array in random order with controls to requeue or dequeue
elements during the iteration.

```
npm install random-array-iterator
```

## Usage

``` js
const RandomArrayIterator = require('random-array-iterator')

const ite = new RandomArrayIterator([1, 2, 3, 4, 5])

for (const val of ite) {
  console.log(val) // random value

  // call requeue if you want to revisit this value is the same iteration
  if (someCondition) ite.requeue()

  // call dequeue if you want to remove the value from the iteration and array entirely
  if (someOtherCondition) ite.dequeue()
}
```

## API

#### `ite = new RandomArrayIterator(array)`

Make a new iterator. Implements the JavaScript iterator interface.

#### `ite.requeue()`

Requeue the current value. Only valid to call during an iteration.

#### `ite.dequeue()`

Remove the current value from the array and iteration. Only valid to vall during an iteration.

#### `ite.restart()`

Restarts the iterator.

## License

MIT

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