UNPKG

468 BJavaScriptView Raw
1'use strict'
2
3class User {
4 // Represents a participating user in the chat.
5 //
6 // id - A unique ID for the user.
7 // options - An optional Hash of key, value pairs for this user.
8 constructor (id, options) {
9 this.id = id
10
11 if (options == null) {
12 options = {}
13 }
14
15 Object.keys(options).forEach((key) => {
16 this[key] = options[key]
17 })
18
19 if (!this.name) {
20 this.name = this.id.toString()
21 }
22 }
23}
24
25module.exports = User