-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserMap.js
68 lines (55 loc) · 1.17 KB
/
UserMap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const User = require("./user.js")
class UserMap extends Map {
constructor(file) {
super()
}
load() {
throw new Error("Method not implemented.")
}
find(userId) {
return Array.from(this.values()).filter((u) => {
return u.userId == userId
})
}
getUsersInSession(session) {
return Array.from(this.values()).filter((u) => {
if (!u.server) {
return false
}
const userSession = u.server.split("#")[1]
return userSession == session
})
}
getUsedUrls() {
return Array.from(this.values())
.filter((u) => {
return u.experimentUrl
})
.map((u) => {
return u.experimentUrl
})
}
dump() {
const data = []
this.forEach((v, k) => {
data.push(v.serialize())
})
return JSON.stringify(data)
}
upsert(user) {
throw new Error("Method not implemented.")
}
save(user) {
throw new Error("Method not implemented.")
}
saveAll() {
throw new Error("Method not implemented.")
}
findAll() {
throw new Error("Method not implemented.")
}
forceSave() {
throw new Error("Method not implemented.")
}
}
module.exports = UserMap