MCPcopy Create free account
hub / github.com/apitable/apitable / runInTimeSlicing

Function runInTimeSlicing

packages/datasheet/src/pc/utils/utils.ts:2–18  ·  view source on GitHub ↗
(gen, frameDelta: number = 25)

Source from the content-addressed store, hash-verified

1// @ts-ignore
2export function runInTimeSlicing(gen, frameDelta: number = 25) {
3 if (typeof gen === 'function') gen = gen();
4 if (!gen || typeof gen.next !== 'function') return;
5
6 return function next() {
7 const start = performance.now();
8 let res: any = null;
9 do {
10 res = gen.next();
11 } while (!res.done && performance.now() - start < frameDelta);
12
13 if (res.done) {
14 return;
15 }
16 setTimeout(next);
17 };
18}

Callers 1

exportDatasheetBaseFunction · 0.90

Calls 1

nextMethod · 0.65

Tested by

no test coverage detected