|
@@ -94,7 +94,7 @@ export class Utils
|
94
|
94
|
/**
|
95
|
95
|
* Wait a few milliseconds
|
96
|
96
|
* @param milliseconds how long should we wait?
|
97
|
|
- * @returns a promise that resolves soon after the specified time
|
|
97
|
+ * @returns a promise that is resolved soon after the specified time
|
98
|
98
|
*/
|
99
|
99
|
static wait(milliseconds: number): SpeedyPromise<void>
|
100
|
100
|
{
|
|
@@ -104,6 +104,20 @@ export class Utils
|
104
|
104
|
}
|
105
|
105
|
|
106
|
106
|
/**
|
|
107
|
+ * Run SpeedyPromises sequentially
|
|
108
|
+ * @param promises an array of SpeedyPromises
|
|
109
|
+ * @returns a promise that is resolved as soon as all input promises are
|
|
110
|
+ * resolved, or that is rejected as soon as an input promise is rejected
|
|
111
|
+ */
|
|
112
|
+ static runInSequence<T>(promises: SpeedyPromise<T>[]): SpeedyPromise<T>
|
|
113
|
+ {
|
|
114
|
+ return promises.reduce(
|
|
115
|
+ (prev, curr) => prev.then(() => curr),
|
|
116
|
+ Speedy.Promise.resolve()
|
|
117
|
+ );
|
|
118
|
+ }
|
|
119
|
+
|
|
120
|
+ /**
|
107
|
121
|
* Convert a resolution type to a resolution measured in pixels
|
108
|
122
|
* @param resolution resolution type
|
109
|
123
|
* @param aspectRatio width / height ratio
|