1.0.1 • Published 5 years ago
node-random-string v1.0.1
node-random-string
To create a random string.
Installation
To install node-random-string, use npm:
npm i node-random-string -S
Usage
import randomString from 'node-random-string';
randomString();
/* '1Uobd2CVV2mXwc7F7yKCvLRVgUBDH3DB' */
randomString(12);
/* 'uU4u1QyytM4U' */
randomString({
length: 12,
charset: 'alphabetic'
});
/* 'nORLfqUfkuxn' */
randomstring({
chars: 'abc'
});
/* 'bbcaaccbacccccbabacacbacabbcbccb' */
randomString({
length: 12,
upperCase: true
});
/* 'FQVI8YMT1D81' */
Options
length
- define the length of the string. (default: 32) OPTIONALcharset
- define the character set for the string. (default: 0-9 a-z A-Z) OPTIONALchars
- define the characters of the string. (default: null) OPTIONALlowerCase
- define whether the output should be lowercase only. (default: null) OPTIONALupperCase
- define whether the output should be uppercase only. (default: null) OPTIONAL
Tests
npm install
npm test