Archived
1
0

Web socket + fill setup

This commit is contained in:
Asher
2019-01-14 17:19:29 -06:00
committed by Kyle Carberry
parent 14f91686c5
commit 24a86b81ba
12 changed files with 64 additions and 65 deletions

View File

@ -8,11 +8,11 @@ export class CP {
private readonly client: Client,
) { }
public exec(
public exec = (
command: string,
options?: { encoding?: BufferEncoding | string | "buffer" | null } & cp.ExecOptions | null | ((error: Error | null, stdout: string, stderr: string) => void) | ((error: Error | null, stdout: Buffer, stderr: Buffer) => void),
callback?: ((error: Error | null, stdout: string, stderr: string) => void) | ((error: Error | null, stdout: Buffer, stderr: Buffer) => void),
): cp.ChildProcess {
): cp.ChildProcess => {
const process = this.client.spawn(command);
let stdout = "";
@ -41,11 +41,11 @@ export class CP {
return process;
}
public fork(modulePath: string): cp.ChildProcess {
public fork = (modulePath: string): cp.ChildProcess => {
return this.client.fork(modulePath);
}
public spawn(command: string, args?: ReadonlyArray<string> | cp.SpawnOptions, _options?: cp.SpawnOptions): cp.ChildProcess {
public spawn = (command: string, args?: ReadonlyArray<string> | cp.SpawnOptions, _options?: cp.SpawnOptions): cp.ChildProcess => {
return this.client.spawn(command, args, options);
}

View File

@ -1,32 +1,5 @@
import * as net from "net";
/**
* Implementation of Socket for the browser.
*/
class Socket extends net.Socket {
public connect(): this {
throw new Error("not implemented");
}
}
/**
* Implementation of Server for the browser.
*/
class Server extends net.Server {
public listen(
_port?: number | any | net.ListenOptions, // tslint:disable-line no-any so we can match the Node API.
_hostname?: string | number | Function,
_backlog?: number | Function,
_listeningListener?: Function,
): this {
throw new Error("not implemented");
}
}
type NodeNet = typeof net;
/**
@ -35,11 +8,11 @@ type NodeNet = typeof net;
export class Net implements NodeNet {
public get Socket(): typeof net.Socket {
return Socket;
throw new Error("not implemented");
}
public get Server(): typeof net.Server {
return Server;
throw new Error("not implemented");
}
public connect(): net.Socket {
@ -65,8 +38,8 @@ export class Net implements NodeNet {
public createServer(
_options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean } | ((socket: net.Socket) => void),
_connectionListener?: (socket: net.Socket) => void,
): Server {
return new Server();
): net.Server {
throw new Error("not implemented");
}
}