Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ColourGenerator {
- constructor () {
- this.map = new Map()
- }
- newColour (name) {
- const colour = '#'+((1<<24)*Math.random()|0).toString(16).padStart(6,'0')
- this.map.set(name, colour)
- }
- getColour (name) {
- if (!this.map.has(name)) this.newColour(name)
- return this.map.get(name)
- }
- }
- module.exports = new ColourGenerator()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement