Skip to content

Commit b7d852e

Browse files
committed
Package got created
1 parent 12dda44 commit b7d852e

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

Readme.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Random array element without repetition
2+
3+
![npm](https://img.shields.io/npm/v/@smakss/random-array-element) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@smakss/random-array-element) ![NPM](https://img.shields.io/npm/l/@smakss/random-array-element) ![npm](https://img.shields.io/npm/dm/@smakss/random-array-element) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@smakss/random-array-element)
4+
5+
In order to select an element within an array, you can simply use `Math.random()` but what about when you don't want to select an element that selected before. Here this package will came to use.
6+
7+
## How it works?
8+
9+
To install it you can simply do the following command:
10+
11+
```
12+
npm i @smakss/random-array-element
13+
or
14+
yarn add @smakss/random-array-element
15+
```
16+
17+
to include with `ES5` or common js you can simply do this:
18+
19+
```
20+
var randomArrayElement = require('@smakss/random-array-element');
21+
```
22+
23+
or to include with `ES6` you simply do this one:
24+
25+
```
26+
import randomArrayElement from '@smakss/random-array-element'
27+
```
28+
29+
then to use it within your application you can do it just like this:
30+
```
31+
const chooser = randomArrayElement(['Foo', 'Bar', 'FU', 'FooBar' ]);
32+
33+
chooser() // Foo
34+
chooser() // Bar
35+
chooser() // FU
36+
chooser() // FooBar
37+
chooser() // Foo (only repeats once all items within the array are exhausted.)
38+
```

index.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@smakss/random-array-element",
3+
"version": "1.0.0",
4+
"description": "Select random array element without repetition.",
5+
"main": "index.min.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/SMAliKSS/random-array-element.git"
9+
},
10+
"keywords": [
11+
"npm",
12+
"yarn",
13+
"array",
14+
"SMAKSS",
15+
"random",
16+
"random-index",
17+
"random-array-element",
18+
"random-element-without-repeat",
19+
"random-array-element-without-repetition"
20+
],
21+
"author": "SMAKSS",
22+
"license": "MIT",
23+
"bugs": {
24+
"url": "https://github.com/SMAliKSS/random-array-element/issues"
25+
},
26+
"homepage": "https://github.com/SMAliKSS/random-array-element#readme"
27+
}

0 commit comments

Comments
 (0)