-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.js
40 lines (34 loc) · 780 Bytes
/
event.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
const { ErrArguments } = require('./errors')
const { Path } = require('./path')
const EventTypes = {
Remove: 'remove',
Write: 'write',
Create: 'create',
Rename: 'rename',
Move: 'move'
}
class Event {
Type = EventTypes.Create
FromPath = new Path()
ToPath = new Path()
constructor(type = EventTypes.Create, fromPath = new Path(), toPath = new Path()) {
if (Object.values(EventTypes).indexOf(type) === -1) {
throw ErrArguments
}
this.Type = type
this.FromPath = fromPath
this.ToPath = toPath
}
String() {
let s = `event ${this.FromPath.String()}`
if (this.Type === EventTypes.Rename) {
s += ` -> ${this.ToPath.String()}`
}
s += ` [${this.Type}]`
return s
}
}
module.exports = {
EventTypes,
Event
}