zgg-ui
Version:
2.0.1 正式版本 基于 Vue 3、UniApp 和 TypeScript 开发的多端适配移动端 UI 组件库,旨在提供丰富的组件集合,帮助开发者快速构建多端响应式的移动应用界面
28 lines (24 loc) • 645 B
text/typescript
import { isSymbol } from '@vue/shared'
import { reIsDeepProp, reIsPlainProp } from './_common'
import type { PropertyPath } from './_common'
export function isKey(value: PropertyPath, object: any) {
if (Array.isArray(value)) {
return false
}
const type = typeof value
if (
type == 'number' ||
type == 'symbol' ||
type == 'boolean' ||
value == null ||
isSymbol(value)
) {
return true
}
return (
reIsPlainProp.test(value as string) ||
!reIsDeepProp.test(value as string) ||
// eslint-disable-next-line unicorn/new-for-builtins
(object != null && (value as any) in Object(object))
)
}