@vitruvius-labs/ts-predicate
Version:
TypeScript predicates library
10 lines (9 loc) • 394 B
JavaScript
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 };