|
let chain: Promise<void> = Promise.resolve();
|
|
|
|
/** 序列化 Threads 瀏覽器操作,避免同時開多個 profile 實例。 */
|
|
export function withSessionLock<T>(fn: () => Promise<T>): Promise<T> {
|
|
const run = chain.then(fn);
|
|
chain = run.then(
|
|
() => undefined,
|
|
() => undefined
|
|
);
|
|
return run;
|
|
} |