array-shuffle-fp
Randomize the order of items in an array using FP style.
Uses the modern version of the Fisher–Yates algorithm:
-- To shuffle an array a of n elements (indices 0..n-1):
for i from n−1 downto 1 do
j ← random integer such that 0 ≤ j ≤ i
exchange a[j] and a[i]
Install
$ npm install --save array-shuffle-fp
Usage
const arrayShuffle = require( 'array-shuffle-fp' );
const result = arrayShuffle( [ 'a', 'b', 'c', 'd', 'e' ] );
console.log( result );
Test
$ npm test
Support
Node.js 6+.
License
array-shuffle-fp is licensed under GNU General Public License v2 (or later).