UNPKG
lean4-code-actions
Version:
latest (1.1.32)
1.1.32
Refactorings and snippets for Lean 4
lean4-code-actions
/
libs
/
utils
/
Mapper
/
getMaybe.ts
8 lines
(6 loc)
•
293 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
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
)) }