@evokegroup/string-generator
v1.0.0
Published
Generates random strings
Downloads
5
Keywords
Readme
@evokegroup/string-generator
Generates random strings
Class: StringGenerator
constructor(characters)
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| characters | number
, string
| | The set of characters to use to generate codes |
Usage
const StringGenerator = require('@evokegroup/string-generator');
const generator1 = new StringGenerator();
const generator2 = new StringGenerator(StringGenerator.EChars.AlphaUpper | StringGenerator.EChars.Numeric);
const generator3 = new StringGenerator('2346789BCDFGHJKMPQRTVWXY');
Methods
generate(length) ⇒ string
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| length | number
| | The length of the string to generate |
Usage
const StringGenerator = require('@evokegroup/string-generator');
const generator = new StringGenerator();
const randomString = generator.generate(8); // 4J#im9+w
Static Properties
EChars
| Property | Description | | -------- | ----------- | | AlphaLower | Lower case alpha characters | | AlphaUpper | Upper case alpha characters | | Numeric | Numeric characters | | Symbols | Symbol characters | | Unambiguous | Only unambiguous characters |