chore: minor improvements in for cycle (#18)
This commit is contained in:
parent
8331e4dd73
commit
216904fd6e
3 changed files with 17 additions and 29 deletions
|
|
@ -85,11 +85,9 @@ export class Armory {
|
||||||
websiteRoot: this.config.websiteRoot,
|
websiteRoot: this.config.websiteRoot,
|
||||||
iframeMode: this.config.iframeMode,
|
iframeMode: this.config.iframeMode,
|
||||||
};
|
};
|
||||||
for (const key in locals) {
|
for (const key of Object.keys(locals)) {
|
||||||
if (locals.hasOwnProperty(key)) {
|
|
||||||
app.locals[key] = locals[key];
|
app.locals[key] = locals[key];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
app.locals.locals = locals;
|
app.locals.locals = locals;
|
||||||
|
|
||||||
app.engine(
|
app.engine(
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ export class Config {
|
||||||
} else if (typeof model === "object") {
|
} else if (typeof model === "object") {
|
||||||
const obj = {};
|
const obj = {};
|
||||||
Config.loadObjFromEnv(logger, obj, model, parentName + i);
|
Config.loadObjFromEnv(logger, obj, model, parentName + i);
|
||||||
if (Object.keys(obj).length > 0) {
|
if (Object.keys(obj).length) {
|
||||||
arr.push(obj);
|
arr.push(obj);
|
||||||
}
|
}
|
||||||
} else if (process.env.hasOwnProperty(key)) {
|
} else if (process.env.hasOwnProperty(key)) {
|
||||||
|
|
@ -161,7 +161,7 @@ export class Config {
|
||||||
for (const field of missing) {
|
for (const field of missing) {
|
||||||
logger.warn(`Field ${parentName}${field} is missing from config.json!`);
|
logger.warn(`Field ${parentName}${field} is missing from config.json!`);
|
||||||
}
|
}
|
||||||
for (const key in model) {
|
for (const key of Object.keys(model)) {
|
||||||
if (typeof model[key] === "object" && obj.hasOwnProperty(key)) {
|
if (typeof model[key] === "object" && obj.hasOwnProperty(key)) {
|
||||||
Config.checkAllMissingFields(logger, obj[key], model[key], parentName + key);
|
Config.checkAllMissingFields(logger, obj[key], model[key], parentName + key);
|
||||||
}
|
}
|
||||||
|
|
@ -169,12 +169,8 @@ export class Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static hasMissingFields(obj: object, model: object): string[] {
|
private static hasMissingFields(obj: object, model: object): string[] {
|
||||||
const missing = [];
|
const objProp = Object.keys(obj);
|
||||||
for (const key in model) {
|
const missingProps = Object.keys(model).filter((key) => !objProp.includes(key));
|
||||||
if (!obj.hasOwnProperty(key)) {
|
return missingProps;
|
||||||
missing.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return missing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,21 +125,17 @@ async function download(dir: string, file: string): Promise<string | any> {
|
||||||
|
|
||||||
function queueTexturesAndModels(item: any): void {
|
function queueTexturesAndModels(item: any): void {
|
||||||
if (item.TextureFiles !== null) {
|
if (item.TextureFiles !== null) {
|
||||||
for (const key in item.TextureFiles) {
|
for (const file in Object.values(item.TextureFiles)) {
|
||||||
for (const file of item.TextureFiles[key]) {
|
if (file["FileDataId"] !== 0) {
|
||||||
if (file.FileDataId !== 0) {
|
texturesDownloadQueue.add(file["FileDataId"]);
|
||||||
texturesDownloadQueue.add(file.FileDataId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.ModelFiles !== null) {
|
if (item.ModelFiles !== null) {
|
||||||
for (const key in item.ModelFiles) {
|
for (const file of Object.values(item.ModelFiles)) {
|
||||||
for (const file of item.ModelFiles[key]) {
|
if (file["FileDataId"] !== 0) {
|
||||||
if (file.FileDataId !== 0) {
|
modelsDownloadQueue.add(file["FileDataId"]);
|
||||||
modelsDownloadQueue.add(file.FileDataId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +145,7 @@ function queueTexturesAndModels(item: any): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Textures !== null) {
|
if (item.Textures !== null) {
|
||||||
for (const key in item.Textures) {
|
for (const key of Object.keys(item.Textures)) {
|
||||||
if (item.Textures[key] !== 0) {
|
if (item.Textures[key] !== 0) {
|
||||||
texturesDownloadQueue.add(item.Textures[key]);
|
texturesDownloadQueue.add(item.Textures[key]);
|
||||||
}
|
}
|
||||||
|
|
@ -157,7 +153,7 @@ function queueTexturesAndModels(item: any): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Textures2 !== null) {
|
if (item.Textures2 !== null) {
|
||||||
for (const key in item.Textures2) {
|
for (const key of Object.keys(item.Textures2)) {
|
||||||
if (item.Textures2[key] !== 0) {
|
if (item.Textures2[key] !== 0) {
|
||||||
texturesDownloadQueue.add(item.Textures2[key]);
|
texturesDownloadQueue.add(item.Textures2[key]);
|
||||||
}
|
}
|
||||||
|
|
@ -196,11 +192,9 @@ async function downloadRaces(): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const textureFiles = Object.keys(customizationJson.TextureFiles)
|
const textureFiles = Object.values(customizationJson.TextureFiles).flat();
|
||||||
.map((key) => customizationJson.TextureFiles[key])
|
|
||||||
.flat();
|
|
||||||
for (const file of textureFiles) {
|
for (const file of textureFiles) {
|
||||||
texturesDownloadQueue.add(file.FileDataId);
|
texturesDownloadQueue.add(file["FileDataId"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.increment();
|
progress.increment();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue