UNPKG

lean4-code-actions

Version:

Refactorings and snippets for Lean 4

8 lines (6 loc) 293 B
import { MapperP } from './index' const getMaybe = <In, Out>(mappers: MapperP<In, Out | undefined>[]) => async (input: In) => { return mappers.reduce<Promise<Out | undefined>>(async (result, mapper) => { return (await result) ?? (await mapper(input)) }, Promise.resolve(undefined)) }