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。

381 B
Raw Blame
export function createAsyncLock() {
    let lock = Promise.resolve();
    return async function withLock(fn) {
        const prev = lock;
        let release;
        lock = new Promise((resolve) => {
            release = resolve;
        });
        await prev;
        try {
            return await fn();
        }
        finally {
            release?.();
        }
    };
}