https://github.com/vitalets/random-select
Select random items from list without repeats
https://github.com/vitalets/random-select
Last synced: 6 months ago
JSON representation
Select random items from list without repeats
- Host: GitHub
- URL: https://github.com/vitalets/random-select
- Owner: vitalets
- Created: 2021-10-14T18:28:33.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-16T09:56:10.000Z (over 3 years ago)
- Last Synced: 2025-03-11T13:11:10.114Z (7 months ago)
- Language: TypeScript
- Size: 232 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# random-select
Select random items from list without repeats.## Installation
```
npm i @vitalets/random-select
```## Usage
```ts
import { RandomSelect } from '@vitalets/random-select';const rs = new RandomSelect();
function selectItem() {
return rs.select([ 1, 2, 3 ]);
}const item1 = selectItem(); // any value from array
const item2 = selectItem(); // any value from array, except item1
const item3 = selectItem(); // any value from array, except item1 and item2
const item4 = selectItem(); // any value from array, except item3 (new round)
```## License
MIT @ [Vitaliy Potapov](https://github.com/vitalets)