diff options
Diffstat (limited to 'src/util.ts')
-rw-r--r-- | src/util.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util.ts b/src/util.ts new file mode 100644 index 0000000..2292820 --- /dev/null +++ b/src/util.ts @@ -0,0 +1,13 @@ +'use strict'; + + +export function mapPromises<T>(promises: {[key: string]: Promise<T>}): Promise<{[key: string]: T}> { + var p: Promise<void>[] = [] + var ret: {[key: string]: T} = {} + + _.forOwn(promises, (v, k) => { + p.push(v.then(r => {ret[k] = r;})); + }); + + return Promise.all(p).then(() => ret); +} |