Spaces:
Running
Running
Download shared/shuffle.ts from Felladrin/MiniSearch: direct link, hf CLI and curl.
- Browser
- Download file 370 Bytes
-
https://huggingface.co/spaces/Felladrin/MiniSearch/resolve/main/shared/shuffle.ts
- Command line
-
hf download hf://spaces/Felladrin/MiniSearch/shared/shuffle.ts
-
curl -L -o shuffle.ts https://huggingface.co/spaces/Felladrin/MiniSearch/resolve/main/shared/shuffle.ts
370 Bytes
| /** Shuffles `items` in place with Fisher-Yates and returns it; every order is equally likely. */ | |
| export function shuffle<Item>(items: Item[]): Item[] { | |
| for (let index = items.length - 1; index > 0; index--) { | |
| const swapIndex = Math.floor(Math.random() * (index + 1)); | |
| [items[index], items[swapIndex]] = [items[swapIndex], items[index]]; | |
| } | |
| return items; | |
| } | |