@kimmel/array-shuffle

Fisher-Yates shuffle of an array of items.

Usage no npm install needed!

<script type="module">
  import kimmelArrayShuffle from 'https://cdn.skypack.dev/@kimmel/array-shuffle';
</script>

README

array-shuffle Build Status codecov

Fisher-Yates shuffle of an array of items producing an unbiased permutation.

Install

$ npm install @kimmel/array-shuffle

Usage

import shuffle from '@kimmel/array-shuffle';

const shuffledArray = shuffle([1, 2, 3, 4, 5, 6]);
//=> [3, 1, 2, 5, 6, 4]

shuffle does not mutate the original array.

API

shuffle(items)

items

Type: array

['hello', 2, 5, { foo: 'bar' }]

License

MIT © Ryan Castner