random str option
This commit is contained in:
parent
38d9ed0f9f
commit
0a50728469
1 changed files with 2 additions and 2 deletions
|
|
@ -32,9 +32,9 @@ export function timeAgo(unixTimestamp: number): string {
|
||||||
return Math.floor(seconds) + " seconds ago";
|
return Math.floor(seconds) + " seconds ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function randomStr(length: number): string {
|
export function randomStr(length: number, withNumbers = true): string {
|
||||||
let result = '';
|
let result = '';
|
||||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'.toUpperCase();
|
const characters = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' + (withNumbers ? '123456789' : '')).toUpperCase();
|
||||||
const charactersLength = characters.length;
|
const charactersLength = characters.length;
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
while (counter < length) {
|
while (counter < length) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue