Do not use for..in operator for iterate over an array
Change-Id: I2d73e80a313adb8a22488dd8ddaa1034ee4dd7ee
diff --git a/package.json b/package.json
index 22e400c..ce2dc13 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cord_workflow_controller",
- "version": "0.5.2",
+ "version": "0.5.3",
"description": "CORD Workflow Controller",
"main": "src/server.js",
"scripts": {
diff --git a/src/controllers/ws_manager.js b/src/controllers/ws_manager.js
index 4ce95c5..539c415 100644
--- a/src/controllers/ws_manager.js
+++ b/src/controllers/ws_manager.js
@@ -422,7 +422,7 @@
}
let results = [];
- for(let d in message.data) {
+ message.data.forEach((d) => {
if(!('workflow_id' in d)) {
// error
errorMessage = `field 'workflow_id' does not exist in message body - ${JSON.stringify(d)}`;
@@ -454,7 +454,7 @@
// set workflow status
let result = eventrouter.setWorkflowRunStatus(workflowRunId, status);
results.append(result);
- }
+ });
cb(null, results);
return;
diff --git a/src/server.js b/src/server.js
index 6f70d3a..182985a 100644
--- a/src/server.js
+++ b/src/server.js
@@ -51,9 +51,9 @@
// load built-in workflows
let workflows = workflowLoader.loadAllWorkflows();
- for(let workflow in workflows) {
+ workflows.forEach((workflow) => {
eventrouter.addWorkflow(workflow);
- }
+ });
});
app.server = server;
return server;
diff --git a/src/workflows/loader.js b/src/workflows/loader.js
index a7bc275..278a144 100644
--- a/src/workflows/loader.js
+++ b/src/workflows/loader.js
@@ -114,9 +114,9 @@
// found workflow essence file in json format
let workflows = loadWorkflows(dirEntry);
if(workflows) {
- for(let workflow in workflows) {
+ workflows.forEach((workflow) => {
allWorkflows.push[workflow];
- }
+ });
}
}
});