Skip to content

Commit

Permalink
feat(fn): add function for resolving values from function series
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd committed Nov 4, 2018
1 parent 788a5ec commit ac97f78
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/@ionic/cli-framework/src/utils/fn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function resolveValueSync<T>(...fns: (() => T | undefined)[]): T | undefined {
for (const fn of fns) {
const result = fn();

if (result) {
return result;
}
}
}

export async function resolveValue<T>(...fns: (() => Promise<T | undefined>)[]): Promise<T | undefined> {
for (const fn of fns) {
const result = await fn();

if (result) {
return result;
}
}
}

0 comments on commit ac97f78

Please sign in to comment.