Permalink
Fetching contributors…
Cannot retrieve contributors at this time
11 lines (10 sloc) 244 Bytes
/**
* Only call and return the result of `f` if `obj` is defined (not null nor
* undefined)
*/
export function map<T, R>(
obj: T | undefined | null,
f: (t: T) => R
): R | undefined {
return obj != null ? f(obj) : undefined
}