This is imported from https://github.com/mozilla-services/screenshots/. It has been reviewed as patches landed, but also reviewed by Mossop and kmag. This also includes the patch from bug 1356394 MozReview-Commit-ID: FXIVw7WjxlN
15 lines
376 B
JavaScript
15 lines
376 B
JavaScript
/* exported randomString */
|
|
|
|
"use strict";
|
|
|
|
this.randomString = function randomString(length, chars) {
|
|
let randomStringChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
chars = chars || randomStringChars;
|
|
let result = "";
|
|
for (let i=0; i<length; i++) {
|
|
result += chars[Math.floor(Math.random() * chars.length)]
|
|
}
|
|
return result;
|
|
}
|
|
null;
|