Skip to content

Commit

Permalink
null objects
Browse files Browse the repository at this point in the history
  • Loading branch information
steam0r committed Dec 10, 2024
1 parent ec0118d commit 6e03831
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
14 changes: 7 additions & 7 deletions src/electron/electron_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class ElectronApi
{
return {};
}
const result = {};
const result = Object.create(null);
result.opDocs = [];

const opDoc = doc.getDocForOp(opName);
Expand Down Expand Up @@ -813,7 +813,7 @@ class ElectronApi

getChangelog(data)
{
const obj = {};
const obj = Object.create(null);
obj.items = [];
obj.ts = Date.now();
return this.success("OK", obj, true);
Expand Down Expand Up @@ -1143,7 +1143,7 @@ class ElectronApi
}

const results = [];
let projectPackages = {};
let projectPackages = Object.create(null);
currentProject.ops.forEach((op) =>
{
const opName = opsUtil.getOpNameById(op.opId);
Expand Down Expand Up @@ -1372,7 +1372,7 @@ class ElectronApi
const currentProject = settings.getCurrentProject();
const dirInfos = projectsUtil.getOpDirs(currentProject, false);

const opDirs = {};
const opDirs = Object.create(null);
if (currentProject && currentProject.ops)
{
currentProject.ops.forEach((op) =>
Expand Down Expand Up @@ -1463,7 +1463,7 @@ class ElectronApi
const currentProject = settings.getCurrentProject();
const assetPorts = projectsUtil.getProjectAssetPorts(currentProject, true);

const oldNew = {};
const oldNew = Object.create(null);
let projectAssetPath = cables.getAssetPath();
projectAssetPath = path.join(projectAssetPath, "assets");
if (!fs.existsSync(projectAssetPath)) mkdirp.sync(projectAssetPath);
Expand All @@ -1487,7 +1487,7 @@ class ElectronApi
collectOps()
{
const currentProject = settings.getCurrentProject();
const movedOps = {};
const movedOps = Object.create(null);
const allOpNames = [];
if (currentProject && currentProject.ops)
{
Expand Down Expand Up @@ -1745,7 +1745,7 @@ class ElectronApi

if (fromRename) targetDir = opsUtil.getOpSourceDir(oldName);
const problems = opsUtil.getOpRenameProblems(newName, oldName, currentUser, [], null, null, [], true, targetDir);
const hints = {};
const hints = Object.create(null);
const consequences = opsUtil.getOpRenameConsequences(newName, oldName, targetDir);

let newOpDocs = opDocs;
Expand Down
18 changes: 9 additions & 9 deletions src/electron/electron_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class ElectronSettings
this.WINDOW_BOUNDS = "windowBounds";
this.DOWNLOAD_PATH = "downloadPath";

this.opts = {};
this.opts.defaults = {};
this.opts = Object.create(null);
this.opts.defaults = Object.create(null);
this.opts.configName = this.MAIN_CONFIG_NAME;
this.opts.defaults[this.USER_SETTINGS_FIELD] = {};
this.opts.defaults[this.USER_SETTINGS_FIELD] = Object.create(null);
this.opts.defaults[this.PATCHID_FIELD] = null;
this.opts.defaults[this.PROJECTFILE_FIELD] = null;
this.opts.defaults[this.CURRENTPROJECTDIR_FIELD] = null;
this.opts.defaults[this.STORAGEDIR_FIELD] = storageDir;
this.opts.defaults[this.RECENT_PROJECTS_FIELD] = {};
this.opts.defaults[this.RECENT_PROJECTS_FIELD] = Object.create(null);
this.opts.defaults[this.OPEN_DEV_TOOLS_FIELD] = false;
this.opts.defaults[this.DOWNLOAD_PATH] = app.getPath("downloads");

Expand Down Expand Up @@ -178,7 +178,7 @@ class ElectronSettings
const coreFile = path.join(cables.getUiDistPath(), "js", "buildinfo.json");
const uiFile = path.join(cables.getUiDistPath(), "buildinfo.json");
const standaloneFile = path.join(cables.getStandaloneDistPath(), "public", "js", "buildinfo.json");
let core = {};
let core = Object.create(null);
if (fs.existsSync(coreFile))
{
try
Expand All @@ -191,7 +191,7 @@ class ElectronSettings
}
}

let ui = {};
let ui = Object.create(null);
if (fs.existsSync(uiFile))
{
try
Expand All @@ -204,7 +204,7 @@ class ElectronSettings
}
}

let api = {};
let api = Object.create(null);
if (fs.existsSync(standaloneFile))
{
try
Expand Down Expand Up @@ -262,7 +262,7 @@ class ElectronSettings

setRecentProjects(recents)
{
if (!recents) recents = {};
if (!recents) recents = Object.create(null);
return this.set(this.RECENT_PROJECTS_FIELD, recents);
}

Expand Down Expand Up @@ -291,7 +291,7 @@ class ElectronSettings
return p2.updated - p1.updated;
});
files = helper.uniqueArray(files);
const newRecents = {};
const newRecents = Object.create(null);
for (let i = 0; i < 10; i++)
{
if (i > files.length) break;
Expand Down
2 changes: 1 addition & 1 deletion src/export/export_zip_standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class StandaloneZipExport extends SharedExportService
{
this._log.info("exported file " + finalZipFileName + " / " + this.archive.pointer() / 1000000.0 + " mb");

const result = {};
const result = Object.create(null);
result.size = this.archive.pointer() / 1000000.0;
result.path = finalZipFileName;
result.log = this.exportLog;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/files_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class FilesUtil extends SharedFilesUtil
getPatchFiles()
{
const arr = [];
const fileHierarchy = {};
const fileHierarchy = Object.create(null);

const project = settings.getCurrentProject();
if (!project) return arr;
Expand Down
10 changes: 5 additions & 5 deletions src/utils/projects_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ProjectsUtil extends SharedProjectsUtil

addOpDir(project, opDir, atTop = false)
{
if (!project.dirs) project.dirs = {};
if (!project.dirs) project.dirs = Object.create(null);
if (!project.dirs.ops) project.dirs.ops = [];
if (atTop)
{
Expand All @@ -205,7 +205,7 @@ class ProjectsUtil extends SharedProjectsUtil

removeOpDir(project, opDir)
{
if (!project.dirs) project.dirs = {};
if (!project.dirs) project.dirs = Object.create(null);
if (!project.dirs.ops) project.dirs.ops = [];
project.dirs.ops = project.dirs.ops.filter((dirName) =>
{
Expand Down Expand Up @@ -238,7 +238,7 @@ class ProjectsUtil extends SharedProjectsUtil
dirs.forEach((dir) =>
{
const opJsons = helper.getFileNamesRecursive(dir, ".json");
const opLocations = {};
const opLocations = Object.create(null);
opJsons.forEach((jsonLocation) =>
{
const jsonName = path.basename(jsonLocation, ".json");
Expand Down Expand Up @@ -267,7 +267,7 @@ class ProjectsUtil extends SharedProjectsUtil
{
if (fs.existsSync(opDir)) newOrder.push(opDir);
});
if (!currentProject.dirs) currentProject.dirs = {};
if (!currentProject.dirs) currentProject.dirs = Object.create(null);
if (!currentProject.dirs.ops) currentProject.dirs.ops = [];
currentProject.dirs.ops = newOrder.filter((dir) => { return !this.isFixedPositionOpDir(dir); });
currentProject.dirs.ops = helper.uniqueArray(currentProject.dirs.ops);
Expand Down Expand Up @@ -308,7 +308,7 @@ class ProjectsUtil extends SharedProjectsUtil
{
if (this._projectOpDocs && !rebuildCache) return this._projectOpDocs;

const opDocs = {};
const opDocs = Object.create(null);
const opDirs = this.getProjectOpDirs(project, true, false, false);

opDirs.forEach((opDir) =>
Expand Down
10 changes: 5 additions & 5 deletions src_client/cmd_electron.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import standalone from "./renderer.js";

const CABLES_CMD_STANDALONE = {};
const CABLES_CMD_STANDALONE_OVERRIDES = {};
const CABLES_CMD_STANDALONE = Object.create(null);
const CABLES_CMD_STANDALONE_OVERRIDES = Object.create(null);
const CMD_STANDALONE_COMMANDS = [];

CABLES_CMD_STANDALONE.runNpm = () =>
{
const loadingModal = standalone.gui.startModalLoading("Installing packages...");
const options = {};
const options = Object.create(null);
standalone.editor.api("installProjectDependencies", options, (_err, result) =>
{
if (result.data)
Expand Down Expand Up @@ -274,7 +274,7 @@ CABLES_CMD_STANDALONE.openOpDirectory = () =>
}
};

CABLES_CMD_STANDALONE_OVERRIDES.PATCH = {};
CABLES_CMD_STANDALONE_OVERRIDES.PATCH = Object.create(null);
CABLES_CMD_STANDALONE_OVERRIDES.PATCH.saveAs = () =>
{
let patchName = standalone.gui.project() ? standalone.gui.project().name : null;
Expand Down Expand Up @@ -314,7 +314,7 @@ CABLES_CMD_STANDALONE_OVERRIDES.PATCH.renameOp = (opName) =>
}
};

CABLES_CMD_STANDALONE_OVERRIDES.RENDERER = {};
CABLES_CMD_STANDALONE_OVERRIDES.RENDERER = Object.create(null);
CABLES_CMD_STANDALONE_OVERRIDES.RENDERER.fullscreen = () =>
{
standalone.editor.api("cycleFullscreen", { }, (_err, r) => {});
Expand Down
2 changes: 1 addition & 1 deletion src_client/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class CablesStandalone

if (!this._config.isPackaged) window.ELECTRON_DISABLE_SECURITY_WARNINGS = true;

this._loadedModules = {};
this._loadedModules = Object.create(null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion webpack.electron.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default (isLiveBuild, buildInfo, minify = false, analyze = false) =>
{
if (!buildInfo.platform)
{
buildInfo.platform = {};
buildInfo.platform = Object.create(null);
}
if (process.env.BUILD_VERSION)
{
Expand Down

0 comments on commit 6e03831

Please sign in to comment.