mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +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.`,
|
`port.write: Tried to write type ${typeof value}. Only string and number types may be written to ports.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { data, resolve } = getPort(n);
|
const port = getPort(n);
|
||||||
data.push(value);
|
port.data.push(value);
|
||||||
resolve();
|
port.resolve();
|
||||||
if (data.length > Settings.MaxPortCapacity) return data.shift() as PortData;
|
if (port.data.length > Settings.MaxPortCapacity) return port.data.shift() as PortData;
|
||||||
return null;
|
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.`,
|
`port.write: Tried to write type ${typeof value}. Only string and number types may be written to ports.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { data, resolve } = getPort(n);
|
const port = getPort(n);
|
||||||
if (data.length >= Settings.MaxPortCapacity) return false;
|
if (port.data.length >= Settings.MaxPortCapacity) return false;
|
||||||
data.push(value);
|
port.data.push(value);
|
||||||
resolve();
|
port.resolve();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user