Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2610148

Browse filesBrowse files
committed
await
1 parent 794cc8b commit 2610148
Copy full SHA for 2610148

File tree

2 files changed

+30
-0
lines changed
Filter options

2 files changed

+30
-0
lines changed

‎lib/functions/await.d.ts

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ITask } from "../types";
2+
/**
3+
* Returns an Promise which will resolve when the condition is satisfied, or rejected if timeout expired
4+
* @param condition Task which should resolve with check result
5+
* @param delay Delay between when condition task return value and run new one
6+
* @param timeout Timeout before promise will rejected. `-1` for endless waiting.
7+
* @returns Promise
8+
*/
9+
export declare function await(condition: ITask, delay: number, timeout?: number): Promise<any>;

‎lib/functions/await.js

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use strict";
2+
var prow = require("../prow");
3+
/**
4+
* Returns an Promise which will resolve when the condition is satisfied, or rejected if timeout expired
5+
* @param condition Task which should resolve with check result
6+
* @param delay Delay between when condition task return value and run new one
7+
* @param timeout Timeout before promise will rejected. `-1` for endless waiting.
8+
* @returns Promise
9+
*/
10+
function await(condition, delay, timeout) {
11+
if (timeout === void 0) { timeout = -1; }
12+
return new Promise(function (resolve, reject) {
13+
var conditionHandler = function (result) {
14+
if (result) {
15+
resolve();
16+
}
17+
};
18+
prow.retry(condition, -1, delay, timeout).then(conditionHandler).catch(reject);
19+
});
20+
}
21+
exports.await = await;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.