hugoalh-studio / shuffle-array-js

[MIGRATED TO https://github.com/hugoalh-studio/shuffle-array-es] A JavaScript module to shuffle the array's indexes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shuffle Array (JavaScript)

βš–οΈ MIT

πŸ—‚οΈ GitHub: hugoalh-studio/shuffle-array-js NPM: @hugoalh/shuffle-array

πŸ†™ Latest Release Version (Latest Release Date)

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

πŸ”° Usage

Via Installation

🎯 Supported Target

  • Cloudflare Workers
  • NodeJS
  1. Install via console/shell/terminal:
    • Via NPM
      npm install @hugoalh/shuffle-array[@<Tag>]
    • Via PNPM
      pnpm add @hugoalh/shuffle-array[@<Tag>]
    • Via Yarn
      yarn add @hugoalh/shuffle-array[@<Tag>]
  2. Import at the script (<ScriptName>.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 property exports for available sub paths.

Via NPM Specifier

🎯 Supported Target

  • Bun
  • Deno
  1. Import at the script (<ScriptName>.js):
    import ... from "npm:@hugoalh/shuffle-array[@<Tag>]";

    ℹ️ 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 property exports for available sub paths.

🧩 API

  • function shuffleArray<T>(item: T[]): T[];

✍️ Example

  • 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]

About

[MIGRATED TO https://github.com/hugoalh-studio/shuffle-array-es] A JavaScript module to shuffle the array's indexes.

License:Other


Languages

Language:TypeScript 100.0%