UNPKG

rambda

Version:

Lightweight and faster alternative to Ramda with included TS definitions

16 lines (13 loc) 355 B
import { cloneList } from './_internals/cloneList.js' export function shuffle(listInput) { const list = cloneList(listInput) let counter = list.length while (counter > 0) { const index = Math.floor(Math.random() * counter) counter-- const temp = list[counter] list[counter] = list[index] list[index] = temp } return list }