MCPcopy Create free account
hub / github.com/ampproject/amphtml / yieldThread

Function yieldThread

extensions/amp-analytics/0.1/resource-timing.js:55–59  ·  view source on GitHub ↗

* Yields the thread before running the function to avoid causing jank. (i.e. a * task that takes over 16ms.) * @param {function(): OUT} fn * @return {!Promise } * @template OUT

(fn)

Source from the content-addressed store, hash-verified

53 * @template OUT
54 */
55function yieldThread(fn) {
56 return new Promise((resolve) => {
57 setTimeout(() => resolve(fn()));
58 });
59}
60
61/**
62 * Checks whether the given object is a valid resource timing spec.

Callers 1

serializeResourceTimingFunction · 0.85

Calls 2

resolveFunction · 0.50
fnFunction · 0.50

Tested by

no test coverage detected