INNER CODE UNIT · JavaScript

randomString

Thorium-Sim/thorium · server/classes/computerCore/index.js:41

function randomString(length, chars) {
  var result = "";
  for (let i = length; i > 0; --i) {
    result += chars[Math.floor(Math.random() * chars.length)];
  }
  return result;
}

class Virus {
  constructor(params = {}) {
    this.id = params.id || uuid.v4();
    this.name =
      params.name ||
      randomString(
        10,
        "0123456789abcdefghijklmnopqrstuvwxyz~`!@#$%^&*()_+-={}[]:\";'<>?,./|\\",
      );
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…