Some cleanup

- Use whateverEmitter.event for the onWhatever methods.
- Add readonly to a bunch of things.
- Remove some redundancy in types.
- Move initializations out of the constructor and into the declarations
  where it was reasonable to do so.
- Disable a few no-any violations.
This commit is contained in:
Asher
2019-02-06 11:53:23 -06:00
parent ddf96077a3
commit 588da0443c
16 changed files with 98 additions and 164 deletions

View File

@@ -9,11 +9,10 @@ type nodePtyType = typeof nodePty;
* Implementation of nodePty for the browser.
*/
class Pty implements nodePty.IPty {
private readonly emitter: EventEmitter;
private readonly emitter = new EventEmitter();
private readonly cp: ChildProcess;
public constructor(file: string, args: string[] | string, options: nodePty.IPtyForkOptions) {
this.emitter = new EventEmitter();
this.cp = client.spawn(file, Array.isArray(args) ? args : [args], {
...options,
tty: {
@@ -38,7 +37,8 @@ class Pty implements nodePty.IPty {
return this.cp.title!;
}
public on(event: string, listener: (...args) => void): void {
// tslint:disable-next-line no-any
public on(event: string, listener: (...args: any[]) => void): void {
this.emitter.on(event, listener);
}