@kottetall/random 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +15 -2
- package/readme.md +56 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kottetall/random",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -14,7 +14,20 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/kottetall/random.git"
|
|
16
16
|
},
|
|
17
|
-
"keywords": [
|
|
17
|
+
"keywords": [
|
|
18
|
+
"random",
|
|
19
|
+
"random-utils",
|
|
20
|
+
"utility",
|
|
21
|
+
"utils",
|
|
22
|
+
"helpers",
|
|
23
|
+
"javascript",
|
|
24
|
+
"node",
|
|
25
|
+
"array",
|
|
26
|
+
"object",
|
|
27
|
+
"picker",
|
|
28
|
+
"random-picker",
|
|
29
|
+
"random-value"
|
|
30
|
+
],
|
|
18
31
|
"author": "",
|
|
19
32
|
"license": "ISC",
|
|
20
33
|
"type": "commonjs",
|
package/readme.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Random
|
|
2
|
+
|
|
3
|
+
A lightweight utility library for generating pseudo-random values in JavaScript based of `Math.random()`.
|
|
4
|
+
|
|
5
|
+
This package was originally created for personal use in my own projects, but it is published as an open tool that anyone can use. It focuses on simple, practical helpers for working with randomness, such as picking random values from arrays or objects.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Get a random value from an array
|
|
10
|
+
- Get a random value from an object
|
|
11
|
+
- Get a random letter
|
|
12
|
+
- Get a random truthy/falsy value
|
|
13
|
+
- And more...
|
|
14
|
+
- Simple and minimal API
|
|
15
|
+
- Zero dependencies
|
|
16
|
+
- Designed for everyday use in JavaScript and Node.js projects
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @kottetall/random
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Random value from an array
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { Random } from "@kottetall/random";
|
|
30
|
+
|
|
31
|
+
const items = ["apple", "banana", "orange"];
|
|
32
|
+
const result = Random.fromArray(items);
|
|
33
|
+
|
|
34
|
+
console.log(result);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Random value from an object
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import { Random } from "@kottetall/random";
|
|
41
|
+
|
|
42
|
+
const obj = {
|
|
43
|
+
a: 1,
|
|
44
|
+
b: 2,
|
|
45
|
+
c: 3,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const result = Random.fromObject(obj);
|
|
49
|
+
|
|
50
|
+
console.log(result);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Why this package?
|
|
54
|
+
|
|
55
|
+
Sometimes you just need small, reusable helpers instead of rewriting the same logic in every project.
|
|
56
|
+
This package aims to provide clean and simple functions for common random-related tasks.
|