Skip to content

Commit 1131d10

Browse files
committed
Readme.md got modified
Snippets got modified
1 parent 3bb9767 commit 1131d10

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Readme.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,31 @@ import randomArrayElement from '@smakss/random-array-element';
2828

2929
then to use it within your application you can do it just like this:
3030

31+
```js
32+
const chooser = randomArrayElement();
33+
34+
// Result: -1
35+
// If the input was not array or was empty the chooser will be equal to -1, so chooser() will throw an error.
3136
```
37+
38+
```js
3239
const chooser = randomArrayElement(['Foo', 'Bar', 'FU', 'FooBar']);
33-
// If the input was not array or was empty the chooser will be equal to -1, so chooser() will throw an error.
34-
chooser(); // Foo
35-
chooser(); // Bar
36-
chooser(); // FU
37-
chooser(); // FooBar
38-
chooser(); // Foo (only repeats once all items within the array are exhausted.)
40+
41+
chooser();
42+
// Result: Foo
43+
44+
chooser();
45+
// Result: Bar
46+
47+
chooser();
48+
// Result: FU
49+
50+
chooser();
51+
// Result: FooBar
52+
53+
chooser();
54+
// Result: Foo
55+
// Only repeats, once all items within the array are exhausted.
3956
```
4057

4158
## Demo

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smakss/random-array-element",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Selects a random unique array element without repetition from provided array.",
55
"type": "module",
66
"main": "./index.cjs",

0 commit comments

Comments
 (0)