diff --git a/src/lib/times.ts b/src/lib/times.ts deleted file mode 100644 index 3c1f10f..0000000 --- a/src/lib/times.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const times = (n: number, fn: (num: number) => T): T[] => - Array(n) - .fill(undefined) - .map((_, i) => fn(i)); diff --git a/src/lib/util.ts b/src/lib/util.ts index a9e4cb9..7b42147 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -1,3 +1,11 @@ export function isDefined(value: T | undefined | null): value is T { return value !== undefined && value !== null; } + +export const isPromise = (val: void | Promise): val is Promise => + val && (>val).then !== undefined; + +export const times = (n: number, fn: (num: number) => T): T[] => + Array(n) + .fill(undefined) + .map((_, i) => fn(i));