Sha256: ca4784a68537915d80162553a916d8498a8aade9fa09d3e83b17d91e4b1aec89
Contents?: true
Size: 578 Bytes
Versions: 185
Compression:
Stored size: 578 Bytes
Contents
const ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', BASE = 10, usedNames = {}; const random = max => Math.floor(Math.random() * max); const generateName = () => { let name = ALPHA.charAt(random(ALPHA.length)) + ALPHA.charAt(random(ALPHA.length)) + random(BASE) + random(BASE) + random(BASE); usedNames[name] ? name = generateName() : usedNames[name] = true; return name; }; export default class Robot { constructor() { this.robotName = generateName(); } get name() { return this.robotName; } reset() { this.robotName = generateName(); } }
Version data entries
185 entries across 185 versions & 1 rubygems