File tree 2 files changed +30
-0
lines changed
Filter options
2 files changed +30
-0
lines changed
Original file line number Diff line number Diff line change
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 > ;
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments