-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathoutput.ts
29 lines (26 loc) · 799 Bytes
/
output.ts
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
import { EventEmitter } from 'events';
import P1Reader from '../p1-reader';
/**
* Base Output class, extend this class to create a new output.
*/
export default abstract class Output extends EventEmitter {
/**
* You can override the constructor,
* but this makes sure you can never create a new instance of 'Output'
*/
constructor() {
super();
if (this.constructor === Output) {
throw new Error("Abstract classes can't be instantiated.");
}
}
/**
* start is the entry point of any new output.
* @param {P1Reader} p1Reader This will be the instance of the P1Reader, use it to listen for events.
*/
abstract start(p1Reader: P1Reader): void;
/**
* close is where you would close your output, it needed.
*/
abstract close(): Promise<void>;
}