@libshin/random-array
v1.1.2
Published
Shuffle and shorten an array.
Downloads
11
Readme
TL;DR
Shuffle and shorten an array.
// randomArray(originArray)
randomArray([1, 2, 3, 4, 5, 6]);
// [4, 5, 3, 2, 1]
// randomArray(originArray, maxLength)
randomArray([1, 2, 3, 4, 5, 6], 2);
// [5, 3]
// randomArray(originArray, [minLength, maxLength])
randomArray([1, 2, 3, 4, 5, 6], [3, 5]);
// [4, 6, 2, 3]
Install
Browser
<script src="https://unpkg.com/@libshin/random-array(@version)/build/random-array.umd.js"></script>
You don't have to specify the version of the module. By default it will redirect to the latest version.
NPM
npm i --save @libshin/random-array
Yarn
yarn add @libshin/random-array
Import
Browser
const randomArray = window["@libshin/random-array"];
Node
const randomArray = require("@libshin/random-array");
ES Module
import randomArray from "@libshin/random-array";