UNPKG

@vitruvius-labs/ts-predicate

Version:
10 lines (9 loc) 394 B
import { hasNullableProperty } from "./has-nullable-property.mjs"; import { isDefined } from "./is-defined.mjs"; import { itemGuard } from "./utils/item-guard.mjs"; function hasProperty(value, property, test) { return (hasNullableProperty(value, property) && isDefined(value[property]) && (test === undefined || itemGuard(value[property], test))); } export { hasProperty };