MCPcopy Create free account
hub / github.com/RandomAPI/Randomuser.me-Node / random

Function random

api/1.2/api.js:380–398  ·  view source on GitHub ↗
(mode, length)

Source from the content-addressed store, hash-verified

378}
379
380function random(mode, length) {
381 let result = '';
382 let chars;
383
384 if (mode == 1) {
385 chars = 'abcdef1234567890';
386 } else if (mode == 2) {
387 chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
388 } else if (mode == 3) {
389 chars = '0123456789';
390 } else if (mode == 4) {
391 chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
392 }
393 for (let i = 0; i < length; i++) {
394 result += chars[range(0, chars.length-1)];
395 }
396
397 return result;
398}
399
400function randomItem(arr) {
401 return arr[range(0, arr.length-1)];

Callers 15

generateMethod · 0.70
defaultSeedMethod · 0.70
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50
inject.jsFile · 0.50

Calls 1

rangeFunction · 0.70

Tested by

no test coverage detected