Basic Option creation

Useful to make code shorter and more expressive.

import * as O from "fp-ts/Option"  
import { pipe } from "fp-ts/function"  
import DateTime from "luxon"  
  
const getFoo = async (): Promise<string | null> => Promise.resolve(null)  
  
const lastSyncTime = pipe(  
 O.fromNullable(await getFoo()), O.map(DateTime.fromISO), O.getOrElse(() => DateTime.local()))  

Would you like to connect? Subscribe via email or RSS , or follow me on Twitter!