UNPKG

@proem/some

Version:

Proem package for handling possibly null values

10 lines (7 loc) 268 B
/* Package for handling possibly null values. */ export const map = <A, B>(value: A | null, mapper: (value: A) => B): B | null => value === null ? null : mapper(value) map.partial = <A, B>(mapper: (value: A) => B) => (value: A): B | null => map(value, mapper)