Stack safe task array #1563
-
I saw that #1345 has been merged, but I do not fully understand how to use I have an array of about 10.000 items that are converted. Each conversion requires an api call. The following code works for about 2.000 items, but if the array is larger I get How can I make the following stack-safe? I believe pipe(
paymentTransactions,
A.map(convertTransaction),
A.sequence(T.ApplicativeSeq),
mergeConversionResultsAndErrors,
T.map(
flow(
S.mapLeft(flow(A.map(serializeConversionFailureToCsv), O.fromPredicate(A.isNonEmpty))),
S.map(flow(A.map(serializePaymentTransactionToDatevCsv), O.fromPredicate(A.isNonEmpty))),
(r) => ({ erroneousLines: r.left, convertedLines: r.right }),
),
),
); EDIT: changing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
As you wrote, you have to replace |
Beta Was this translation helpful? Give feedback.
As you wrote, you have to replace
A.sequence(T.ApplicativeSeq)
withT.sequenceArray
. If you're not fine with a readonly array, you can usetoArray
fromReadonlyArray
module.