Make writePort synchronous (#193)

This commit is contained in:
Snarling 2022-11-04 07:56:20 -04:00 committed by GitHub
parent 55b2cbb549
commit 7ef2675e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

@ -1449,7 +1449,7 @@ const base: InternalAPI<NS> = {
},
writePort:
(ctx) =>
(_port, data = ""): Promise<any> => {
(_port, data): string | number | null => {
const port = helpers.number(ctx, "port", _port);
if (typeof data !== "string" && typeof data !== "number") {
throw helpers.makeRuntimeErrorMsg(
@ -1458,7 +1458,7 @@ const base: InternalAPI<NS> = {
);
}
const iport = helpers.getValidPort(ctx, port);
return Promise.resolve(iport.write(data));
return iport.write(data);
},
write:
(ctx) =>

@ -6291,9 +6291,9 @@ export interface NS {
* RAM cost: 0 GB
*
* Write data to the given Netscript port.
* @returns The data popped off the queue if it was full.
* @returns The data popped off the queue if it was full, or null if it was not full.
*/
writePort(port: number, data: string | number): Promise<PortData>;
writePort(port: number, data: string | number): PortData | null;
/**
* Read data from a port.
* @remarks