You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that for situations where you have one or two results assigned to variables, its easier to write Result.all(res1, res2) than Result.all([res1, res2]) but having used this library in an enterprise environment, its far far more common that we are processing an array of results, leaving the code littered with Result.all(...resultArray).
For a while, this issue was mitigated since we can just spread the array in, as I'm sure was part of the consideration when choosing this function signature. However, if the array of results grows large enough, spreading the array into the parameters could lead to a stack overflow. This had us implement our own version of Result.all which accepts an array, but otherwise is virtually identical.
I think it's a bit of a code smell to re-write tools that come out of the box. Would it be possible to have another variant of Result.all added to the library which accepts an array rather than a spread parameter.
The text was updated successfully, but these errors were encountered:
ConnorSinnott
changed the title
Result.all accepting spread parameters leads to situations for stack overflows
Result.all accepting spread parameters encourages situations for stack overflows
Mar 27, 2024
Hello! I'm curious about the backstory behind why Result.all takes the pattern of
rather than
I understand that for situations where you have one or two results assigned to variables, its easier to write
Result.all(res1, res2)
thanResult.all([res1, res2])
but having used this library in an enterprise environment, its far far more common that we are processing an array of results, leaving the code littered withResult.all(...resultArray)
.For a while, this issue was mitigated since we can just spread the array in, as I'm sure was part of the consideration when choosing this function signature. However, if the array of results grows large enough, spreading the array into the parameters could lead to a stack overflow. This had us implement our own version of Result.all which accepts an array, but otherwise is virtually identical.
I think it's a bit of a code smell to re-write tools that come out of the box. Would it be possible to have another variant of Result.all added to the library which accepts an array rather than a spread parameter.
The text was updated successfully, but these errors were encountered: