New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mk-randoms

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mk-randoms

Random integer, Random array element, Random string, Random boolean with given probability, Random offset of numerical

latest
Source
npmnpm
Version
1.2.3
Version published
Maintainers
1
Created
Source

mk-randoms

Generate random values of different types with clear syntax with 1K lib.

Random integer, random array element, random string, random boolean with given probability, random offset of numerical.

Type declaration added for Typescript.

Installation

npm install --save mk-randoms

Inclusion

Node js:

var random = require('mk-randoms')

ES6:

import random from 'mk-randoms/dist/random.es6'
import random from 'mk-randoms' // this will work as well

Browser:

<script src="node_modules/mk-randoms/dist/random.min.js"></script>

Usage

random.num(min, max)

Random numerical value between min and max values.

random.int(min, max)

Random integer between min and max values.

random.ok([okProbability])

Random boolean. okProbability - is an optional probability of "TRUE" value percentage, dafault is 50.

random.str([length][, sourceStr])

Random string. length: is a length of string, dafault is 1. sourceStr: is a set of acceptable characters, default is "abcdefghijklmnopqrstuvwxyz"

random.element(arr[, quantity])

Random element of array, or array - random subset of sourse array, where every source element can be copied no more then one time. arr: source array. quantity: default is 1, if 1 returns random array element, otherwise it is a length of resulting array, if quantity is larger then source array length, then returns source array.

random.shift(val[, percentage])

Random shift of numerical value. val: original number. percentage: amplitude of discrepancy, default is 10.

random.intShift(val[, percentage])

Random integer shift of integer value. val: original number. percentage: amplitude of discrepancy, default is 10.

Keywords

random

FAQs

Package last updated on 05 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts