Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: "for loop" - argv to config; in main_executor.js #183

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main_executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ async function run() {
config.dbNodesTable = typeof(argv.dbnodestable) === "string" ? argv.dbnodestable.trim() : "state.nodes";
config.dbProgramTable = typeof(argv.dbprogramtable) === "string" ? argv.dbprogramtable.trim() : "state.program";

for (let value of ['debug', 'unsigned', 'execute', 'tracer', 'counters', 'skip', 'verbose']) {
config[value] = (argv[value] === true ? true : (config[value] ?? false));
for (const value of ['debug', 'unsigned', 'execute', 'tracer', 'counters', 'skip', 'verbose']) {
config[value] ||= argv[value] === true;
}
Comment on lines +116 to 118
Copy link
Author

@Pranav-yadav Pranav-yadav Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though, not that it's better or worse, I would use even more specific syntax like below; @zkronos73 WDYT?

Suggested change
for (const value of ['debug', 'unsigned', 'execute', 'tracer', 'counters', 'skip', 'verbose']) {
config[value] ||= argv[value] === true;
}
['debug', 'unsigned', 'execute', 'tracer', 'counters', 'skip', 'verbose'].forEach((value) => {
config[value] ||= argv[value] === true;
});


const input = JSON.parse(await fs.promises.readFile(config.inputFile, "utf8"));
Expand Down