MCPcopy Index your code
hub / github.com/ampproject/amphtml / peek

Method peek

src/service/task-queue.js:108–120  ·  view source on GitHub ↗

* Returns the task with the minimal score based on the provided scoring * callback. * @param {function(!TaskDef):number} scorer * @return {?TaskDef}

(scorer)

Source from the content-addressed store, hash-verified

106 * @return {?TaskDef}
107 */
108 peek(scorer) {
109 let minScore = 1e6;
110 let minTask = null;
111 for (let i = 0; i < this.tasks_.length; i++) {
112 const task = this.tasks_[i];
113 const score = scorer(task);
114 if (score < minScore) {
115 minScore = score;
116 minTask = task;
117 }
118 }
119 return minTask;
120 }
121
122 /**
123 * Iterates over all tasks in queue in the insertion order.

Callers 4

test-task-queue.jsFile · 0.45
nextTask_Method · 0.45
work_Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected