# @hugoalh/shuffle-array

> A module to shuffle the array's indexes.

Latest version **2.1.3** (published 2026-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hugoalh/shuffle-array
pnpm add @hugoalh/shuffle-array
yarn add @hugoalh/shuffle-array
bun add @hugoalh/shuffle-array
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.3 |
| Published | 2026-10-12 |
| First published | 2023-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | hugoalh |
| Maintainers | hugoalh |
| Keywords | array, shuffle |

## Links

- npm: https://www.npmjs.com/package/@hugoalh/shuffle-array
- Repository: https://github.com/hugoalh/shuffle-array-es
- Homepage: https://github.com/hugoalh/shuffle-array-es#readme
- Issues: https://github.com/hugoalh/shuffle-array-es/issues
- npm.io page: https://npm.io/package/@hugoalh/shuffle-array

## Recent versions

- 2.1.3 (latest) — 2026-10-12
- 2.1.2 — 2026-07-13
- 2.1.1 — 2025-05-15
- 2.1.0 — 2024-12-03
- 2.0.5 — 2024-10-24
- 2.0.4 — 2024-10-22
- 2.0.3 — 2024-05-07
- 2.0.2 — 2024-04-16
- 2.0.1 — 2024-01-15
- 2.0.0 — 2024-01-11
- 1.0.4 — 2023-09-26
- 1.0.3 — 2023-09-08
- 1.0.2 — 2023-08-09
- 1.0.1 — 2023-07-29
- 1.0.0 — 2023-06-16

## README

# Shuffle Array (ES)

[**⚖️** MIT](./LICENSE.md)

🔗
[DistBoard @hugoalh](https://hugoalh.github.io/distboard/shuffle_array_ecmascript)
● [GitHub](https://github.com/hugoalh/shuffle-array-es)
● [JSR](https://jsr.io/@hugoalh/shuffle-array)
● [NPM](https://www.npmjs.com/package/@hugoalh/shuffle-array)

An ECMAScript module to shuffle the array's indexes.

## 🎯 Runtime Targets

Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:

- **[Bun](https://bun.sh/)** >= v1.1.0
- **[Deno](https://deno.land/)** >= v2.1.0
- **[NodeJS](https://nodejs.org/)** >= v20.9.0

## 🛡️ Runtime Permissions

This does not request any runtime permission.

## #️⃣ Entrypoints

| **Name** | **Path** | **Description** |
|:--|:--|:--|
| `.` | `./mod.ts` | Default. |

> [!NOTE]
> - Different runtimes have vary support for the entrypoints, visit the runtime documentation for more information.
> - These are not part of the public APIs hence should not be used:
>   - Benchmark/Test file (e.g.: `example.bench.ts`, `example.test.ts`).
>   - Entrypoint name or path include any underscore prefix (e.g.: `_example.ts`, `foo/_example.ts`).
>   - Identifier/Namespace/Symbol include any underscore prefix (e.g.: `_example`, `Foo._example`).

## 🧩 APIs

- ```ts
  function shuffleArray<T>(item: readonly T[], prng?: PseudoRandomNumberGenerator): T[];
  ```
- ```ts
  type PseudoRandomNumberGenerator = () => number;
  ```

> [!NOTE]
> - For the full or prettier documentation, can visit via:
>   - [Deno CLI `deno doc`](https://docs.deno.com/runtime/reference/cli/doc)
>   - [JSR](https://jsr.io/@hugoalh/shuffle-array)

## ✍️ Examples

- ```ts
  const item = [3, 7, 25, 26, 42, 62, 71, 76, 92, 93];

  shuffleArray(item);
  //=> [62, 93, 26, 42, 25, 7, 76, 71, 3, 92]

  shuffleArray(item);
  //=> [42, 3, 26, 62, 93, 7, 76, 25, 92, 71]
  ```

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