UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

13 lines (9 loc) 508 B
import { Dictionary, getValue, getValueOr } from "./main.ts"; // test if an object has a property with given name, independent of its value export function has(propName: string, dict: Dictionary): boolean; export function has(propName: string): (dict: Dictionary) => boolean; export function has(propName: string, dict?: Dictionary) { if (arguments.length === 1) return (theDict: Dictionary) => has(propName, theDict); else return Object.keys(getValueOr({}, dict)).includes(getValue(propName)); }