refactor(runtime-core): extract promise check into shared (#325)

This commit is contained in:
Dmitry Sharshakov
2019-10-17 22:47:26 +03:00
committed by Evan You
parent bb9dca2047
commit 7305f693b1
3 changed files with 10 additions and 8 deletions

View File

@@ -41,6 +41,10 @@ export const isSymbol = (val: any): val is symbol => typeof val === 'symbol'
export const isObject = (val: any): val is Record<any, any> =>
val !== null && typeof val === 'object'
export function isPromise<T = any>(val: any): val is Promise<T> {
return isObject(val) && isFunction(val.then) && isFunction(val.catch)
}
export const objectToString = Object.prototype.toString
export const toTypeString = (value: unknown): string =>
objectToString.call(value)