mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +01:00
Make writePort synchronous (#193)
This commit is contained in:
parent
55b2cbb549
commit
7ef2675e2c
@ -1449,7 +1449,7 @@ const base: InternalAPI<NS> = {
|
|||||||
},
|
},
|
||||||
writePort:
|
writePort:
|
||||||
(ctx) =>
|
(ctx) =>
|
||||||
(_port, data = ""): Promise<any> => {
|
(_port, data): string | number | null => {
|
||||||
const port = helpers.number(ctx, "port", _port);
|
const port = helpers.number(ctx, "port", _port);
|
||||||
if (typeof data !== "string" && typeof data !== "number") {
|
if (typeof data !== "string" && typeof data !== "number") {
|
||||||
throw helpers.makeRuntimeErrorMsg(
|
throw helpers.makeRuntimeErrorMsg(
|
||||||
@ -1458,7 +1458,7 @@ const base: InternalAPI<NS> = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const iport = helpers.getValidPort(ctx, port);
|
const iport = helpers.getValidPort(ctx, port);
|
||||||
return Promise.resolve(iport.write(data));
|
return iport.write(data);
|
||||||
},
|
},
|
||||||
write:
|
write:
|
||||||
(ctx) =>
|
(ctx) =>
|
||||||
|
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -6291,9 +6291,9 @@ export interface NS {
|
|||||||
* RAM cost: 0 GB
|
* RAM cost: 0 GB
|
||||||
*
|
*
|
||||||
* Write data to the given Netscript port.
|
* 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.
|
* Read data from a port.
|
||||||
* @remarks
|
* @remarks
|
||||||
|
Loading…
Reference in New Issue
Block a user