Skip to content

Bugfix: Do not unwrap / destructure array contents into combine list.

Compare
Choose a tag to compare
@supermacro supermacro released this 25 Feb 15:44
· 324 commits to master since this release

This release patches a bug where calling combine on a Result<T, E>[] or ResultAsync<T, E>[] and the T values were lists, then those lists would get concatenated into a single output list:

Example:

import { combine, ok } from 'neverthrow'

combine([
  ok([ 1, 2, 3 ]),
  ok([ 'hello', 'world ])
])

// before v4.1.1, the above would incorrectly return [ 1, 2, 3, 'hello', 'world' ]
// 
// actual output should be [ [ 1,2,3 ], [ 'hello', 'world' ] ] 

The fix of the bug can be found here:

a5e66a8

I decided to continue using Array.prototype.concat in spite of this subtlety because it does not mutate references (unlike Array.prototype.push).