mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 17:53:00 +02:00
PORTS: Add ns.nextPortWrite() as a safer option (#1036)
This commit is contained in:
@@ -97,7 +97,7 @@ import { getBitNodeMultipliers } from "./BitNode/BitNode";
|
||||
import { assert, arrayAssert, stringAssert, objectAssert } from "./utils/helpers/typeAssertion";
|
||||
import { cloneDeep, escapeRegExp } from "lodash";
|
||||
import numeral from "numeral";
|
||||
import { clearPort, peekPort, portHandle, readPort, tryWritePort, writePort } from "./NetscriptPort";
|
||||
import { clearPort, peekPort, portHandle, readPort, tryWritePort, writePort, nextPortWrite } from "./NetscriptPort";
|
||||
import { FilePath, resolveFilePath } from "./Paths/FilePath";
|
||||
import { hasScriptExtension } from "./Paths/ScriptFilePath";
|
||||
import { hasTextExtension } from "./Paths/TextFilePath";
|
||||
@@ -1373,6 +1373,10 @@ export const ns: InternalAPI<NSFull> = {
|
||||
}
|
||||
return tryWritePort(portNumber, data);
|
||||
},
|
||||
nextPortWrite: (ctx) => (_portNumber) => {
|
||||
const portNumber = helpers.portNumber(ctx, _portNumber);
|
||||
return nextPortWrite(portNumber);
|
||||
},
|
||||
readPort: (ctx) => (_portNumber) => {
|
||||
const portNumber = helpers.portNumber(ctx, _portNumber);
|
||||
return readPort(portNumber);
|
||||
|
||||
Reference in New Issue
Block a user