1 | const statement = require("./statement.js"); |
2 |
|
3 | class Queue { |
4 | constructor(name, location) { |
5 | this.name = name; |
6 | this.location = location; |
7 | this.queue = []; |
8 | } |
9 |
|
10 | push() { |
11 | if (arguments.length >= 3) { |
12 | if (typeof arguments[0] == "string" && typeof arguments[1] == "string" && typeof arguments[2] == "string") { |
13 | this.queue.push(new statement(arguments[0], arguments[1], arguments[2])); |
14 | } else throw new Error("Expected 3 strings for Statement creation"); |
15 | } else if (arguments.length > 0) { |
16 | if (arguments[0].statements) this.queue.push(arguments[0].statements); // object is an Event |
17 | else if (arguments[0].timestamp) this.queue.push(arguments[0]); // object is a Statement |
18 | else throw new Error("Expected an Event or Statement object"); |
19 | } else throw new Error("Expeted at least one argument"); |
20 | return this; |
21 | } |
22 |
|
23 | write() { |
24 | return this; |
25 | } |
26 | } |
27 |
|
28 | module.exports = Queue; |
29 |
|