@malloydata/render 0.0.24-dev230215185525 → 0.0.24-dev230216003028

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,15 +3,6 @@ export declare function getColorScale(type: "temporal" | "ordinal" | "quantitati
3
3
  range: string[];
4
4
  } | undefined;
5
5
  export declare function timeToString(time: Date, timeframe: DateTimeframe | TimestampTimeframe): string;
6
- /**
7
- * Use this function to break up expensive computation over multiple tasks.
8
- *
9
- * @returns A promise, which when awaited, puts subsequent code in a separate task.
10
- *
11
- * This is useful for cases when expensive code needs to run "concurrently" with a
12
- * rendering / UI task. Sprinkling in `yieldTask`s into a long task allows other
13
- * tasks to run periodically.
14
- */
15
6
  export declare function yieldTask(): Promise<void>;
16
7
  export declare function createErrorElement(document: Document, error: string | Error): HTMLElement;
17
8
  export declare function createNullElement(document: Document): HTMLElement;
@@ -141,7 +141,16 @@ exports.timeToString = timeToString;
141
141
  * rendering / UI task. Sprinkling in `yieldTask`s into a long task allows other
142
142
  * tasks to run periodically.
143
143
  */
144
+ let LAST_YIELD_TIME = undefined;
145
+ const YIELD_DEBOUNCE = 100; // milliseconds
144
146
  async function yieldTask() {
147
+ const currentTime = Date.now();
148
+ // We don't actually yield every time the function is called, because that can add a lot of
149
+ // overhead in terms of new tasks. Instead, we debounce yielding to once every 100ms.
150
+ if (LAST_YIELD_TIME && currentTime < LAST_YIELD_TIME + YIELD_DEBOUNCE) {
151
+ return;
152
+ }
153
+ LAST_YIELD_TIME = currentTime;
145
154
  return new Promise((resolve) => {
146
155
  setTimeout(resolve, 0);
147
156
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/render",
3
- "version": "0.0.24-dev230215185525",
3
+ "version": "0.0.24-dev230216003028",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "prepublishOnly": "npm run build"
19
19
  },
20
20
  "dependencies": {
21
- "@malloydata/malloy": "^0.0.24-dev230215185525",
21
+ "@malloydata/malloy": "^0.0.24-dev230216003028",
22
22
  "us-atlas": "^3.0.0",
23
23
  "vega": "^5.21.0",
24
24
  "vega-lite": "^5.2.0"