Would want to:
write an entire chain of function calls as pipe (the pipe function can be from Lodash or other libs)
My working but incomplete attempt:
This works, I'm half happy with this but not 100% what I want:
import {filter, map, pipe} from 'lodash/fp';
const anAwesomeFunction = async stuff => {
const data = await fetchData(stuff);
return {
title: 'example',
data
};
};
const pipingRocks = await pipe(
filter({status: 'fulfilled'}),
map(
(promiseLikeObj: PromiseFulfilledResult) => promiseLikeObj.value
)
)(await Promise.allSettled(map(anAwesomeFunction, result)));
What I'd like to have:
As far as I read pipe from lodash doesn't get async functions: lodash fp docs
import {filter, map, pipe} from 'lodash/fp';
const anAwesomeFunction = async stuff => {
const data = await fetchData(stuff);
return {
title: 'example',
data
};
};
const pipingRocks = await pipe(
map(anAwesomeFunction),
Promise.allSettled, // here lies my doubt on how to bind it
filter({status: 'fulfilled'}),
map(
(promiseLikeObj: PromiseFulfilledResult) => promiseLikeObj.value
)
)(result);
I have also tried with: import pPipe from 'p-pipe';