Random String Builder
A npm package to generate string randomly.
Installation
To install this package, run the following command:
npm install random-string-builder --save
or
yarn add random-string-builder
Usage
To use this package, import it into your project and call its function:
import generator from 'random-string-builder'
const str = generator(8, false, 'predefined', 'alphabetic', undefined, 'uppercase')
console.log(str) // => 'GDUEGSKE'
The string generator is a function that takes six arguments at most that are:
-
length: Number of characters of the string generated (must be greater than zero). Optional. Default:
32
. -
readable: Boolean parameter indicating if yes or no certains characters should be included in the string (
0
,O
,I
andl
). Optional. Default:false
. -
charset_type: Parameter indicating if the set of characters to build generated string is either
predefined
orcustomized
. Optional. Default:predefined
. -
p_charset: String parameter specifying the generic name of the predefined set of characters:
alphanumeric
,alphabetic
,numeric
,hex
,binary
,octal
andpassword
. Compulsory if charset_type is set to 'predefined'. Default:alphanumeric
. -
c_charset: String parameter setting a customized set of characters. Compulsory if charset_type is set to
customized
. -
capitalization: Parameter specifying the string generated is lowercased or uppercase. Takes two values:
lowercase
anduppercase
. Optional.
License
This package is licensed under the ISC License.
Contact
If you have any questions or issues, please contact the package maintainer at ekoulemaneng@gmail.com.