File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,24 @@ See the License for the specific language governing permissions and
1515limitations under the License.
1616*/
1717
18+ const LOWERCASE = "abcdefghijklmnopqrstuvwxyz" ;
19+ const UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
20+ const DIGITS = "0123456789" ;
21+
1822export function randomString ( len : number ) : string {
23+ return randomStringFrom ( len , UPPERCASE + LOWERCASE + DIGITS ) ;
24+ }
25+
26+ export function randomLowercaseString ( len : number ) : string {
27+ return randomStringFrom ( len , LOWERCASE ) ;
28+ }
29+
30+ export function randomUppercaseString ( len : number ) : string {
31+ return randomStringFrom ( len , UPPERCASE ) ;
32+ }
33+
34+ function randomStringFrom ( len : number , chars : string ) : string {
1935 let ret = "" ;
20- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ;
2136
2237 for ( let i = 0 ; i < len ; ++ i ) {
2338 ret += chars . charAt ( Math . floor ( Math . random ( ) * chars . length ) ) ;
You can’t perform that action at this time.
0 commit comments