bias-random 1.0.0 → 1.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # bias-random
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c3d3e31: Clarified documentation for the function, with clearer parameter explanations and a return as well as throws documentation
8
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 4f0b4cc: Fixed bugs in README with incorrect function name
14
+
3
15
  ## 1.0.0
4
16
 
5
17
  ### Major Changes
package/README.md CHANGED
@@ -9,13 +9,13 @@ Generates biased random numbers with a customizable bias level, direction, and r
9
9
  ## 📦 Installation
10
10
 
11
11
  ```bash
12
- npm install bias-random
12
+ npm i bias-random
13
13
 
14
14
  # or
15
15
  yarn add install bias-random
16
16
 
17
17
  # or
18
- pnpm install bias-random
18
+ pnpm i bias-random
19
19
  ```
20
20
 
21
21
  ## 🚀 Usage
@@ -28,8 +28,8 @@ import biasedRandom from "bias-random";
28
28
  // -Bias level of 2
29
29
  // -Range 0 to 1
30
30
  // Average resulting value will be 1/3
31
- const defaultResult = biasRandom();
31
+ const defaultResult = biasedRandom();
32
32
 
33
33
  // Cutomize the parmeters (all parameters are optional, defaulting to the values above)
34
- const customResult = biasRandom({ upperBias: true, biasLevel: 4, min: 10, max: 1000 });
34
+ const customResult = biasedRandom({ upperBias: true, biasLevel: 4, min: 10, max: 1000 });
35
35
  ```
package/dist/index.d.cts CHANGED
@@ -5,15 +5,19 @@ interface BiasedRandomOptions {
5
5
  max?: number;
6
6
  }
7
7
  /**
8
- * Generates a random number, biased towards lower or higher numbers with the level of your choice
8
+ * Generates a random number between `min` and `max`, with an optional bias towards the lower or upper bound.
9
9
  *
10
- * @param upperBias Set to true to bias this towards higher numbers instead of lower numbers. E.g. with a range of 0
11
- * to 1, a biasLevel of 2, the average value would be 2/3 (1 - (1 / 3))
12
- * @param biasLevel How strongly the bias is, default 2. The resulting values have an average value of 1 / (biasLevel
13
- * + 1) (given upperBias = false and a range of 0 to 1). Can be a decimal number, but must be at least 1 (for less than
14
- * 1, this is equivalent to using an upperBias, e.g. a bias of 0.5 is the same as an upper bias of 2)
15
- * @param min Minimum value of the result, default 0. This scales the result, but keeps the relative bias
16
- * @param max Maximum value of the result, default 1. This scales the result, but keeps the relative bias
10
+ * @param {Object} [options] - Optional configuration object to adjust the behavior of the random number generation.
11
+ * @param {boolean} [options.upperBias=false] - If true, biases the result towards the higher bound (`max`), otherwise biases towards the lower bound (`min`). Default is `false`.
12
+ * @param {number} [options.biasLevel=2] - Determines the strength of the bias. Must be 1 or greater, where `1` means no bias and higher values increase the bias. Default is `2`.
13
+ * @param {number} [options.min=0] - The minimum value for the random number range. Default is `0`.
14
+ * @param {number} [options.max=1] - The maximum value for the random number range. Default is `1`.
15
+ *
16
+ * @returns {number} A random number between `min` and `max`, optionally biased based on the provided options.
17
+ *
18
+ * @throws {TypeError} If `biasLevel` is not a number or is less than 1.
19
+ * @throws {TypeError} If `min` is not less than `max`, or if either `min` or `max` is not a number.
20
+ * @throws {TypeError} If `upperBias` is not a boolean.
17
21
  */
18
22
  declare const biasedRandom: ({ upperBias, biasLevel, min, max }?: BiasedRandomOptions) => number;
19
23
 
package/dist/index.d.ts CHANGED
@@ -5,15 +5,19 @@ interface BiasedRandomOptions {
5
5
  max?: number;
6
6
  }
7
7
  /**
8
- * Generates a random number, biased towards lower or higher numbers with the level of your choice
8
+ * Generates a random number between `min` and `max`, with an optional bias towards the lower or upper bound.
9
9
  *
10
- * @param upperBias Set to true to bias this towards higher numbers instead of lower numbers. E.g. with a range of 0
11
- * to 1, a biasLevel of 2, the average value would be 2/3 (1 - (1 / 3))
12
- * @param biasLevel How strongly the bias is, default 2. The resulting values have an average value of 1 / (biasLevel
13
- * + 1) (given upperBias = false and a range of 0 to 1). Can be a decimal number, but must be at least 1 (for less than
14
- * 1, this is equivalent to using an upperBias, e.g. a bias of 0.5 is the same as an upper bias of 2)
15
- * @param min Minimum value of the result, default 0. This scales the result, but keeps the relative bias
16
- * @param max Maximum value of the result, default 1. This scales the result, but keeps the relative bias
10
+ * @param {Object} [options] - Optional configuration object to adjust the behavior of the random number generation.
11
+ * @param {boolean} [options.upperBias=false] - If true, biases the result towards the higher bound (`max`), otherwise biases towards the lower bound (`min`). Default is `false`.
12
+ * @param {number} [options.biasLevel=2] - Determines the strength of the bias. Must be 1 or greater, where `1` means no bias and higher values increase the bias. Default is `2`.
13
+ * @param {number} [options.min=0] - The minimum value for the random number range. Default is `0`.
14
+ * @param {number} [options.max=1] - The maximum value for the random number range. Default is `1`.
15
+ *
16
+ * @returns {number} A random number between `min` and `max`, optionally biased based on the provided options.
17
+ *
18
+ * @throws {TypeError} If `biasLevel` is not a number or is less than 1.
19
+ * @throws {TypeError} If `min` is not less than `max`, or if either `min` or `max` is not a number.
20
+ * @throws {TypeError} If `upperBias` is not a boolean.
17
21
  */
18
22
  declare const biasedRandom: ({ upperBias, biasLevel, min, max }?: BiasedRandomOptions) => number;
19
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bias-random",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Generates biased random numbers with a customizable bias level, direction, and range",
5
5
  "author": "Reid Moffat <reid.moffat9@gmail.com>",
6
6
  "license": "MIT",