/**
* Parses task queue data for manual execution.
* Supports older JavaScript versions (ES5).
*
* @param {Array<Object>} taskQueue - An array of task objects.
* Each task object should have at least a 'name' property.
* Optionally, it can have other properties like 'description', 'priority', etc.
* @returns {Array<Object>} - An array of task objects suitable for manual execution.
*/
function parseTaskQueue(taskQueue) {
if (!Array.isArray(taskQueue)) {
console.error("Invalid input: taskQueue must be an array.");
return [];
}
const manualTasks = [];
for (let i = 0; i < taskQueue.length; i++) {
const task = taskQueue[i];
if (typeof task !== 'object' || task === null) {
console.warn("Skipping invalid task object at index", i);
continue; // Skip non-object tasks
}
if (typeof task.name !== 'string' || task.name.trim() === '') {
console.warn("Skipping task with missing or empty name at index", i);
continue; // Skip tasks without a name
}
// Create a copy of the task to avoid modifying the original
const manualTask = { ...task };
manualTasks.push(manualTask);
}
return manualTasks;
}
Add your comment