1 | const statement = require("./statement.js"); |
2 |
|
3 | class Event { |
4 | constructor() { |
5 | this.statements = []; |
6 | this.push(arguments); |
7 | return this; |
8 | } |
9 |
|
10 | push() { |
11 | if (arguments.length == 1) { |
12 | if (arguments[0].statements) this.statements.push(arguments[0].statements); // object is an Event |
13 | else this.statements.push(arguments[0]); // object is a Statement |
14 | } |
15 | else if (arguments.length == 3) this.statements.push(new statement(arguments[0], arguments[1], arguments[2])); |
16 | else throw new Error("Expected 1 or 3 arguments"); |
17 | return this; |
18 | } |
19 | } |
20 |
|
21 | module.exports = Event; |
22 |
|