MCPcopy Create free account
hub / github.com/Tencent/libpag / exec

Method exec

web/src/utils/queue.ts:9–29  ·  view source on GitHub ↗
(fn: (...args: any[]) => any, scope: any, ...args: any[])

Source from the content-addressed store, hash-verified

7 private queue: Task[] = [];
8
9 public exec<T>(fn: (...args: any[]) => any, scope: any, ...args: any[]): Promise<T> {
10 return new Promise((resolve, reject) => {
11 const copyFn = async () => {
12 if (!fn) {
13 reject(new Error('Function is null!'));
14 return;
15 }
16 try {
17 const res = await fn.call(scope, ...args);
18 resolve(res);
19 } catch (e) {
20 reject(e);
21 }
22 };
23 this.queue.push({
24 fn: copyFn,
25 });
26 if (this.executing) return;
27 this.execNextTask();
28 });
29 }
30
31 private execNextTask() {
32 if (this.queue.length < 1) {

Callers 15

fetchMethod · 0.80
showMessageMethod · 0.80
GetVideoFirstFrameMethod · 0.80
server.jsFile · 0.80
setup.emsdk.wx.jsFile · 0.80
setup.emsdk.jsFile · 0.80
loadFunction · 0.80
flushMethod · 0.80
prepareMethod · 0.80
queue.spec.tsFile · 0.80
onReadyFunction · 0.80
onReadyFunction · 0.80

Calls 1

execNextTaskMethod · 0.95

Tested by

no test coverage detected