Need private packages and team management tools?Check out npm Teams »

genrandom

1.4.0 • Public • Published

GenRandom

travis build MIT licensed codecov version downloads semantic-release

Description

genrandom (generate random) is a (numeric or alpha numeric) generator by length and segments — Edit

Installation

npm install genrandom --save

Import

import { rNumber, rNumChar } from 'genrandom'

Usage Examples

Return a random number n characters long

rNumber(10) // <= 8210706073
typeof rNumber(10) // <= number

Return a string of random numbers with multiple segments

rNumber(3, 3, 10) // <= 615-807-8046602819
typeof rNumber(3, 3, 10) // <= string

Return a string containing numbers and characters

rNumChar(10) // <= wUDMJd1BRH
typeof rNumChar(10) // <= string

Return a string containing numbers and characters with multiple segments

rNumChar(10, 2, 3) // <= mW13MGs4Vh-pq-Itb
typeof rNumChar(10, 2, 3) // <= string

Return a string containing characters only

rChar(5) // <= JdgBR
typeof rChar(5) // <= string

Return a string containing characters with multiple segments

rChar(5, 6, 3) // <= izMEm-TmeOFQ-JPH

Return a string containing letters, numbers, and symbols

rNumCharSymbol(5) // <= 8V!<#

Return a string containing letters, numbers, and symbols with segments

rNumCharSymbol(5, 8, 12) // <= +<GPE-OHf3aS&&-kh)@IhYVdD2}

Using genrandom in a browser

Include the genrandom script into your html:

'<script src="https://unpkg.com/genrandom/dist/genrandom.umd.js"></script>'

or use the minified version

'<script src="https://unpkg.com/genrandom/dist/genrandom.umd.min.js"></script>'

Call it:

'<script>
     var newRandomNumber = genrandom.rNumber(10, 5, 8);
     console.log("Random Number", newRandomNumber); // <= 2374867366-80085-23113014
</script>'

Coming...

Random Name Generation

Improvements and Bugs

If you find any issues or see something that can be improved? https://github.com/jwright04/genrandom/issues

License

MIT

Install

npm i genrandom

DownloadsWeekly Downloads

1

Version

1.4.0

License

MIT

Unpacked Size

35.1 kB

Total Files

8

Last publish

Collaborators

  • avatar