@reverse/random
Advanced tools
+0
-0
| export declare function chance(percent: number): boolean; |
+0
-0
@@ -0,0 +0,0 @@ export * from './chance'; |
+2
-3
| { | ||
| "name": "@reverse/random", | ||
| "version": "1.0.10", | ||
| "version": "1.0.11", | ||
| "description": "Easy random generation.", | ||
@@ -27,4 +27,3 @@ "main": "index.js", | ||
| "*.d.ts" | ||
| ], | ||
| "gitHead": "219934f44b4f4bb7f7122257edfc91d9f3b52753" | ||
| ] | ||
| } |
+0
-0
| export declare function randomInt(min: number, max: number): number; |
+0
-0
| export declare function randomList<T>(list: ReadonlyArray<T>, items?: number, requiredValues?: ReadonlyArray<T>): ReadonlyArray<T>; |
+0
-0
| export declare function randomOf<T>(list: ReadonlyArray<T>): T; |
+26
-2
| # @reverse/random | ||
| > Easy random generation. | ||
| You can install with nodejs and npm | ||
| ``` | ||
@@ -10,2 +12,3 @@ npm i @reverse/random | ||
| ## Table of Contents | ||
| - [randomInt](#randomIntmin-max) | ||
@@ -17,8 +20,14 @@ - [chance](#chancepercent) | ||
| ## Usage | ||
| ### randomInt(min, max) | ||
| > Generates a random whole number between two values. | ||
| #### Parameters | ||
| - `min: Number`: The minimum number to generate inclusivly. | ||
| - `max: Number`: The maximum number to generate inclusivly. | ||
| #### Example | ||
| ```js | ||
@@ -32,6 +41,11 @@ import { randomInt } from '@reverse/random'; | ||
| ### chance(percent) | ||
| > Returns true a percent amount of the time. | ||
| #### Parameters | ||
| - `percent: Number`: The percent chance to return true. | ||
| #### Example | ||
| ```js | ||
@@ -43,6 +57,6 @@ import { chance } from '@reverse/random'; | ||
| chance(0) | ||
| chance(0); | ||
| // false | ||
| chance(50) | ||
| chance(50); | ||
| // Example Output: true | ||
@@ -52,6 +66,11 @@ ``` | ||
| ### randomOf(list) | ||
| > Returns a random element from an array. | ||
| #### Parameters | ||
| - `list: Array`: The array to pick from. | ||
| #### Example | ||
| ```js | ||
@@ -65,8 +84,13 @@ import { randomOf } from '@reverse/random'; | ||
| ### randomList(list, items, requiredValues) | ||
| > Picks multiple values from an array. | ||
| #### Parameters | ||
| - `list: Array`: The array to choose from. | ||
| - `items: Number`: How many items should be returned. Default 1. | ||
| - `requiredValues: Array`: The values that have to be in the returned items. Default []. | ||
| #### Example | ||
| ```js | ||
@@ -73,0 +97,0 @@ import { randomList } from '@reverse/random'; |
| {"version":3,"file":"chance.js","sourceRoot":"","sources":["chance.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,MAAM,CAAC,OAAe;IACpC,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,OAAO,CAAC;AACxC,CAAC"} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"} |
-21
| MIT License | ||
| Copyright (c) 2019 Reverse Squared | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
| {"version":3,"file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