UNPKG

@technobuddha/library

Version:
13 lines (12 loc) 346 B
export function randomShuffle(deck, random = Math.random) { const items = [...deck]; let index = items.length; while (index > 1) { const rnd = Math.floor(random() * index); const tmp = items[--index]; items[index] = items[rnd]; items[rnd] = tmp; } return items; } export default randomShuffle;