Join a deterministic set of resolved task values with Promise.all and label the coordination outcome.

promise join A Promise.all join awaits every task value before deriving one scalar status, so the report stays deterministic.

Promise All Coordination Report

taskCount
promise_all_coordination.js
Replay: real traced execution (multi-file project)
const taskCount = 3;
let joined = 0;
let outcome = "partial";

async function coordinate(count) {
    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));
    const values = await Promise.all(tasks);
    joined = values.reduce((sum, v) => sum + v, 0);
    if (joined >= 10) {
        outcome = "full";
    } else if (joined >= 3) {
        outcome = "quorum";
    }
    console.log(`tasks=${count} joined=${joined} status=${outcome}`);
}

coordinate(taskCount);
const taskCount = 1;
let joined = 0;
let outcome = "partial";

async function coordinate(count) {
    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));
    const values = await Promise.all(tasks);
    joined = values.reduce((sum, v) => sum + v, 0);
    if (joined >= 10) {
        outcome = "full";
    } else if (joined >= 3) {
        outcome = "quorum";
    }
    console.log(`tasks=${count} joined=${joined} status=${outcome}`);
}

coordinate(taskCount);
const taskCount = 4;
let joined = 0;
let outcome = "partial";

async function coordinate(count) {
    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));
    const values = await Promise.all(tasks);
    joined = values.reduce((sum, v) => sum + v, 0);
    if (joined >= 10) {
        outcome = "full";
    } else if (joined >= 3) {
        outcome = "quorum";
    }
    console.log(`tasks=${count} joined=${joined} status=${outcome}`);
}

coordinate(taskCount);
  1. taskCount ← 3, joined ← 0, outcome ← partial

    1const taskCount→ 3 = 3;  //@taskCount=1, 42let joined→ 0 = 0;3let outcome→ partial = "partial";45async function coordinate(count) {6    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));7    const values = await Promise.all(tasks);8    joined = values.reduce((sum, v) => sum + v, 0);9    if (joined >= 10) {10        outcome = "full";11    } else if (joined >= 3) {12        outcome = "quorum";13    }14    console.log(`tasks=${count} joined=${joined} status=${outcome}`);15}1617coordinate(taskCount3);
  2. tasks ← [object Promise],[object Promise],[object Promise]

    2let joined = 0;3let outcome = "partial";45async function coordinate(count3) {6    const tasks→ [object Promise],[object Promise],[object Promise] = Array.from({ length: count3 }, (_, i) => Promise.resolve(i + 1));7    const values = await Promise.all(tasks[object Promise],[object Promise],[object Promise]);8    joined = values.reduce((sum, v) => sum + v, 0);
  3. values ← 1,2,3, joined ← 6

    5async function coordinate(count) {6    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));7    const values→ 1,2,3 = await Promise.all(tasks[object Promise],[object Promise],[object Promise]);8    joined = values1,2,3.reduce((sum, v) => sum + v, 0);9    if (joined >= 10) {10        outcome = "full";11    } else if (joined >= 3) {12        outcome = "quorum";13    }14    console.log(`tasks=${count} joined=${joined} status=${outcome}`);15}1617coordinate(taskCount3);
    values this step6joined
  4. if (joined >= 3)

    10    outcome = "full";11} else if (joined6 >= 3) {12    outcome = "quorum";13}
  5. console.log(`tasks=${count} joined=${joined} status=${outcome}`);

    12        outcome = "quorum";13    }14    console.log(`tasks=${count3} joined=${joined6} status=${outcomequorum}`);15}
    outputtasks=3 joined=6 status=quorum
  1. taskCount ← 1, joined ← 0, outcome ← partial

    1const taskCount→ 1 = 1;2let joined→ 0 = 0;3let outcome→ partial = "partial";45async function coordinate(count) {6    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));7    const values = await Promise.all(tasks);8    joined = values.reduce((sum, v) => sum + v, 0);9    if (joined >= 10) {10        outcome = "full";11    } else if (joined >= 3) {12        outcome = "quorum";13    }14    console.log(`tasks=${count} joined=${joined} status=${outcome}`);15}1617coordinate(taskCount1);
  2. tasks ← [object Promise]

    2let joined = 0;3let outcome = "partial";45async function coordinate(count1) {6    const tasks→ [object Promise] = Array.from({ length: count1 }, (_, i) => Promise.resolve(i + 1));7    const values = await Promise.all(tasks[object Promise]);8    joined = values.reduce((sum, v) => sum + v, 0);
  3. values ← 1, joined ← 1

    5async function coordinate(count) {6    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));7    const values→ 1 = await Promise.all(tasks[object Promise]);8    joined = values1.reduce((sum, v) => sum + v, 0);9    if (joined >= 10) {10        outcome = "full";11    } else if (joined >= 3) {12        outcome = "quorum";13    }14    console.log(`tasks=${count1} joined=${joined1} status=${outcomepartial}`);15}1617coordinate(taskCount1);
    outputtasks=1 joined=1 status=partial
  1. taskCount ← 4, joined ← 0, outcome ← partial

    1const taskCount→ 4 = 4;2let joined→ 0 = 0;3let outcome→ partial = "partial";45async function coordinate(count) {6    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));7    const values = await Promise.all(tasks);8    joined = values.reduce((sum, v) => sum + v, 0);9    if (joined >= 10) {10        outcome = "full";11    } else if (joined >= 3) {12        outcome = "quorum";13    }14    console.log(`tasks=${count} joined=${joined} status=${outcome}`);15}1617coordinate(taskCount4);
  2. tasks ← [object Promise],[object Promise],[object Promise],[object Promise]

    2let joined = 0;3let outcome = "partial";45async function coordinate(count4) {6    const tasks→ [object Promise],[object Promise],[object Promise],[object Promise] = Array.from({ length: count4 }, (_, i) => Promise.resolve(i + 1));7    const values = await Promise.all(tasks[object Promise],[object Promise],[object Promise],[object Promise]);8    joined = values.reduce((sum, v) => sum + v, 0);
  3. values ← 1,2,3,4, joined ← 10

    5async function coordinate(count) {6    const tasks = Array.from({ length: count }, (_, i) => Promise.resolve(i + 1));7    const values→ 1,2,3,4 = await Promise.all(tasks[object Promise],[object Promise],[object Promise],[object Promise]);8    joined = values1,2,3,4.reduce((sum, v) => sum + v, 0);9    if (joined >= 10) {10        outcome = "full";11    } else if (joined >= 3) {12        outcome = "quorum";13    }14    console.log(`tasks=${count} joined=${joined} status=${outcome}`);15}1617coordinate(taskCount4);
    values this step10joined
  4. if (joined >= 10)

    7const values = await Promise.all(tasks);8joined = values.reduce((sum, v) => sum + v, 0);9if (joined10 >= 10) {10    outcome = "full";11} else if (joined >= 3) {
  5. console.log(`tasks=${count} joined=${joined} status=${outcome}`);

    12        outcome = "quorum";13    }14    console.log(`tasks=${count4} joined=${joined10} status=${outcomefull}`);15}
    outputtasks=4 joined=10 status=full