mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 11:10:58 +02:00
prettify, sorry for the big ass commit
This commit is contained in:
+36
-36
@@ -1,51 +1,51 @@
|
||||
import { Settings } from "./Settings/Settings";
|
||||
|
||||
export class NetscriptPort {
|
||||
data: any[] = [];
|
||||
data: any[] = [];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
write(data: any): any {
|
||||
this.data.push(data);
|
||||
if (this.data.length > Settings.MaxPortCapacity) {
|
||||
return this.data.shift();
|
||||
}
|
||||
return null;
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
write(data: any): any {
|
||||
this.data.push(data);
|
||||
if (this.data.length > Settings.MaxPortCapacity) {
|
||||
return this.data.shift();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
tryWrite(data: any): boolean {
|
||||
if (this.data.length >= Settings.MaxPortCapacity) {
|
||||
return false;
|
||||
}
|
||||
this.data.push(data);
|
||||
return true;
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
tryWrite(data: any): boolean {
|
||||
if (this.data.length >= Settings.MaxPortCapacity) {
|
||||
return false;
|
||||
}
|
||||
this.data.push(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
read(): any {
|
||||
if (this.data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
}
|
||||
return this.data.shift();
|
||||
read(): any {
|
||||
if (this.data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
}
|
||||
return this.data.shift();
|
||||
}
|
||||
|
||||
peek(): any {
|
||||
if (this.data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
} else {
|
||||
const foo = this.data.slice();
|
||||
return foo[0];
|
||||
}
|
||||
peek(): any {
|
||||
if (this.data.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
} else {
|
||||
const foo = this.data.slice();
|
||||
return foo[0];
|
||||
}
|
||||
}
|
||||
|
||||
full(): boolean {
|
||||
return this.data.length == Settings.MaxPortCapacity;
|
||||
}
|
||||
full(): boolean {
|
||||
return this.data.length == Settings.MaxPortCapacity;
|
||||
}
|
||||
|
||||
empty(): boolean {
|
||||
return this.data.length === 0;
|
||||
}
|
||||
empty(): boolean {
|
||||
return this.data.length === 0;
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.data.length = 0;
|
||||
}
|
||||
clear(): void {
|
||||
this.data.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user