export const EMPTY_OBJ: { readonly [key: string]: any } = Object.freeze({}) export const EMPTY_ARR: [] = [] export const NOOP = () => {} export const isOn = (key: string) => key[0] === 'o' && key[1] === 'n' export const extend = ( a: T, b: U ): T & U => { for (const key in b) { ;(a as any)[key] = b[key] } return a as any } export const isArray = Array.isArray export const isFunction = (val: any): val is Function => typeof val === 'function' export const isString = (val: any): val is string => typeof val === 'string' export const isObject = (val: any): val is Record => val !== null && typeof val === 'object' const vnodeHooksRE = /^vnode/ export const isReservedProp = (key: string): boolean => key === 'key' || key === 'ref' || vnodeHooksRE.test(key) const camelizeRE = /-(\w)/g export const camelize = (str: string): string => { return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')) } const hyphenateRE = /\B([A-Z])/g export const hyphenate = (str: string): string => { return str.replace(hyphenateRE, '-$1').toLowerCase() } export const capitalize = (str: string): string => { return str.charAt(0).toUpperCase() + str.slice(1) }