Refactor for ... in loops

This commit is contained in:
nickofolas
2022-01-15 18:45:03 -06:00
parent d5c3d89613
commit ab841f7530
54 changed files with 128 additions and 130 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
helper.updateDynamicRam("getOtherGangInformation", getRamCost(player, "gang", "getOtherGangInformation"));
checkGangApiAccess("getOtherGangInformation");
const cpy: any = {};
for (const gang in AllGangs) {
for (const gang of Object.keys(AllGangs)) {
cpy[gang] = Object.assign({}, AllGangs[gang]);
}
+2 -2
View File
@@ -113,7 +113,7 @@ export function NetscriptSingularity(
// If player has a gang with this faction, return all augmentations.
if (player.hasGangWith(facname)) {
const res = [];
for (const augName in Augmentations) {
for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const aug = Augmentations[augName];
@@ -165,7 +165,7 @@ export function NetscriptSingularity(
let augs = [];
if (player.hasGangWith(faction)) {
for (const augName in Augmentations) {
for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const tempAug = Augmentations[augName];
+1 -1
View File
@@ -273,7 +273,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
const orders: any = {};
const stockMarketOrders = StockMarket["Orders"];
for (const symbol in stockMarketOrders) {
for (const symbol of Object.keys(stockMarketOrders)) {
const orderBook = stockMarketOrders[symbol];
if (orderBook.constructor === Array && orderBook.length > 0) {
orders[symbol] = [];
+1 -1
View File
@@ -28,7 +28,7 @@ export function toNative(pseudoObj: any): any {
} else {
// Object.
nativeObj = {};
for (const key in pseudoObj.properties) {
for (const key of Object.keys(pseudoObj.properties)) {
const val = pseudoObj.properties[key];
nativeObj[key] = toNative(val);
}