我有 3 个函数,f1
,f2
,f3
。
f1
并且f3
是同步和返回Option<string>
,但是f2
是一个异步函数 return Promise<Option<string>>
。
我应该如何在一个管道中使用这三个功能?
这是我的代码:
import {some, chain} from 'fp-ts/lib/Option';
import {pipe} from 'fp-ts/lib/pipeable';
const f1 = (input: string) => {
return some(input + " f1")
};
const f2 = async (input: string) => {
return some(input + " f2")
};
const f3 = (input: string) => {
return some(input + " f3");
};
const result = pipe(
"X",
f1,
chain(f2),
chain(f3),
);
console.log("result", result);