@rahulv.dev/rng
Advanced tools
+11
-0
@@ -17,2 +17,13 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.RNG = void 0; | ||
| __exportStar(require("./interfaces/IRNG"), exports); | ||
| const rng_browser_1 = require("./rng.browser"); | ||
| const rng_node_1 = require("./rng.node"); | ||
| let RNGClass; | ||
| if (typeof window !== "undefined" && window.crypto) { | ||
| RNGClass = rng_browser_1.RNG; | ||
| } | ||
| else { | ||
| RNGClass = rng_node_1.RNG; | ||
| } | ||
| exports.RNG = RNGClass; |
+1
-1
| { | ||
| "name": "@rahulv.dev/rng", | ||
| "version": "1.2.0", | ||
| "version": "1.2.1", | ||
| "description": "A secure random number generator.", | ||
@@ -5,0 +5,0 @@ "main": "dist/rng.node.js", |
+5
-8
@@ -37,5 +37,2 @@ # @rahulv.dev/rng | ||
| import { RNG } from "@rahulv.dev/rng"; | ||
| // For browser environment | ||
| import { RNG } from "@rahulv.dev/rng/browser"; | ||
| ``` | ||
@@ -84,8 +81,8 @@ | ||
| Here’s a detailed look at the API methods provided by `@rahulv.dev/rng` and `@rahulv.dev/rng/browser`: | ||
| Here’s a detailed look at the API methods provided by `@rahulv.dev/rng`: | ||
| | Method | Description | Parameters | Returns | | ||
| | ------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `next(upperLimit)` | Generates a secure random number between `0` and `upperLimit - 1`. | `upperLimit: number`: The upper limit for the random number (exclusive) | `Promise<number>`: A random number within the specified range. | | ||
| | `nextRange(ranges)` | Generates random numbers for an array of upper limits. | `ranges: number[]`: An array of upper limits. Each element specifies the exclusive upper limit for the corresponding random number. | `Promise<number[]>`: An array of random numbers, each within the range specified by the corresponding element in the input array. | | ||
| | Method | Description | Parameters | Returns | | ||
| | ------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | ||
| | `next(upperLimit)` | Generates a secure random number between `0` and `upperLimit - 1`. | `upperLimit: number`: The upper limit for the random number (exclusive) | `number`: A random number within the specified range. | | ||
| | `nextRange(ranges)` | Generates random numbers for an array of upper limits. | `ranges: number[]`: An array of upper limits. Each element specifies the exclusive upper limit for the corresponding random number. | `number[]`: An array of random numbers, each within the range specified by the corresponding element in the input array. | | ||
@@ -92,0 +89,0 @@ ### Usage Examples |
+2
-0
| export * from "./interfaces/IRNG"; | ||
| import { RNG as RngBrowser } from "./rng.browser"; | ||
| export declare const RNG: typeof RngBrowser; |
10137
2.37%111
13.27%118
-2.48%