https://github.com/hugoalh-studio/shuffle-array-js
A JavaScript module to shuffle the array's indexes.
https://github.com/hugoalh-studio/shuffle-array-js
array javascript js shuffle
Last synced: 3 months ago
JSON representation
A JavaScript module to shuffle the array's indexes.
- Host: GitHub
- URL: https://github.com/hugoalh-studio/shuffle-array-js
- Owner: hugoalh-studio
- License: other
- Created: 2023-06-16T08:02:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-31T00:26:51.000Z (over 1 year ago)
- Last Synced: 2024-04-01T13:01:43.532Z (over 1 year ago)
- Topics: array, javascript, js, shuffle
- Language: TypeScript
- Homepage:
- Size: 401 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Shuffle Array (JavaScript)
[**âī¸** MIT](./LICENSE.md)
**đī¸**
[](https://github.com/hugoalh-studio/shuffle-array-js)
[](https://www.npmjs.com/package/@hugoalh/shuffle-array)**đ**  ()
A JavaScript module to shuffle the array's indexes.
## đ¯ Target
- Bun ^ v1.0.0
- Cloudflare Workers
- Deno >= v1.34.0
> **đĄī¸ Require Permission**
>
> *N/A*
- NodeJS >= v16.13.0### đ Other Edition
- [TypeScript](https://github.com/hugoalh-studio/shuffle-array-ts)
## đ° Usage
### Via Installation
> **đ¯ Supported Target**
>
> - Cloudflare Workers
> - NodeJS1. Install via console/shell/terminal:
- Via NPM
```sh
npm install @hugoalh/shuffle-array[@]
```
- Via PNPM
```sh
pnpm add @hugoalh/shuffle-array[@]
```
- Via Yarn
```sh
yarn add @hugoalh/shuffle-array[@]
```
2. Import at the script (`.js`):
```js
import ... from "@hugoalh/shuffle-array";
```
> **âšī¸ Note**
>
> Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.### Via NPM Specifier
> **đ¯ Supported Target**
>
> - Bun
> - Deno1. Import at the script (`.js`):
```js
import ... from "npm:@hugoalh/shuffle-array[@]";
```
> **âšī¸ Note**
>
> Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.## đ§Š API
- ```ts
function shuffleArray(item: T[]): T[];
```## âī¸ Example
- ```js
const chain = [3, 7, 25, 26, 42, 62, 71, 76, 92, 93];shuffleArray(chain);
//=> [62, 93, 26, 42, 25, 7, 76, 71, 3, 92]shuffleArray(chain);
//=> [42, 3, 26, 62, 93, 7, 76, 25, 92, 71]
```