Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

516 B
Raw Blame
const writeQueues = new Map();
export async function serializePathWrite(key, run) {
    const previous = writeQueues.get(key) ?? Promise.resolve();
    const task = (async () => {
        await previous.catch(() => undefined);
        return await run();
    })();
    const done = task.then(() => undefined, () => undefined);
    writeQueues.set(key, done);
    try {
        return await task;
    }
    finally {
        if (writeQueues.get(key) === done) {
            writeQueues.delete(key);
        }
    }
}