Skip to content

Commit

Permalink
chore: use consistent signature for shared utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 17, 2020
1 parent 0c1fe72 commit 202532c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export const isSymbol = (val: unknown): val is symbol => typeof val === 'symbol'
export const isObject = (val: unknown): val is Record<any, any> =>
val !== null && typeof val === 'object'

export function isPromise<T = any>(val: unknown): val is Promise<T> {
export const isPromise = <T = any>(val: unknown): 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)

export function toRawType(value: unknown): string {
export const toRawType = (value: unknown): string => {
return toTypeString(value).slice(8, -1)
}

Expand All @@ -72,7 +72,7 @@ export const isReservedProp = /*#__PURE__*/ makeMap(
'onVnodeBeforeUnmount,onVnodeUnmounted'
)

function cacheStringFunction<T extends (str: string) => string>(fn: T): T {
const cacheStringFunction = <T extends (str: string) => string>(fn: T): T => {
const cache: Record<string, string> = Object.create(null)
return ((str: string) => {
const hit = cache[str]
Expand Down Expand Up @@ -105,7 +105,7 @@ export const hasChanged = (value: any, oldValue: any): boolean =>
value !== oldValue && (value === value || oldValue === oldValue)

// for converting {{ interpolation }} values to displayed strings.
export function toDisplayString(val: unknown): string {
export const toDisplayString = (val: unknown): string => {
return val == null
? ''
: isArray(val) || (isPlainObject(val) && val.toString === objectToString)
Expand Down

0 comments on commit 202532c

Please sign in to comment.