mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
BUGFIX: Fix writePort() error where deconstructing the Port class caused the reduce() function to lose its 'this' reference (#1037)
This commit is contained in:
parent
157ff8ea88
commit
39c5a356b1
@ -49,10 +49,10 @@ export function writePort(n: PortNumber, value: unknown): PortData | null {
|
||||
`port.write: Tried to write type ${typeof value}. Only string and number types may be written to ports.`,
|
||||
);
|
||||
}
|
||||
const { data, resolve } = getPort(n);
|
||||
data.push(value);
|
||||
resolve();
|
||||
if (data.length > Settings.MaxPortCapacity) return data.shift() as PortData;
|
||||
const port = getPort(n);
|
||||
port.data.push(value);
|
||||
port.resolve();
|
||||
if (port.data.length > Settings.MaxPortCapacity) return port.data.shift() as PortData;
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -62,10 +62,10 @@ export function tryWritePort(n: PortNumber, value: unknown): boolean {
|
||||
`port.write: Tried to write type ${typeof value}. Only string and number types may be written to ports.`,
|
||||
);
|
||||
}
|
||||
const { data, resolve } = getPort(n);
|
||||
if (data.length >= Settings.MaxPortCapacity) return false;
|
||||
data.push(value);
|
||||
resolve();
|
||||
const port = getPort(n);
|
||||
if (port.data.length >= Settings.MaxPortCapacity) return false;
|
||||
port.data.push(value);
|
||||
port.resolve();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user