Skip to content

Commit

Permalink
chore(util): add <T> to isPromise
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Aug 28, 2020
1 parent 363d258 commit 2b8a8de
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/helpers.ts
Expand Up @@ -88,4 +88,5 @@ export const isNumber = (v: any): v is boolean => typeof v === 'number';
export const isObject = (val: Object) => val != null && typeof val === 'object' && Array.isArray(val) === false;
export const isString = (v: any): v is string => typeof v === 'string';
export const isIterable = (v: any): v is Iterable<any> => isDefined(v) && isFunction(v[Symbol.iterator]);
export const isPromise = (v: any): v is Promise<any> => !!v && (typeof v === 'object' || typeof v === 'function') && typeof v.then === 'function';
export const isPromise = <T = any>(v: any): v is Promise<T> =>
!!v && (typeof v === 'object' || typeof v === 'function') && typeof v.then === 'function';

0 comments on commit 2b8a8de

Please sign in to comment.