Index

lognestmonster / 478c0cd

A general-purpose single-header C logging library and parser for event-based logs. (Incomplete)

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
1925 Dec 2018 21:149e7f4dfUpdate event.jsJoshua1147N

Blob @ lognestmonster / src / event.js

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