Skip to content

Commit

Permalink
fix(assign): Use map internally
Browse files Browse the repository at this point in the history
  • Loading branch information
kofno committed May 28, 2018
1 parent 7dcb497 commit dec4cac
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Ok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class Ok<Err, A> extends Result<Err, A> {
other: Result<Err, B> | ((a: A) => Result<Err, B>)
): Result<Err, A & { [k in K]: B }> {
const result = other instanceof Result ? other : other(this.value);
return result.andThen(b =>
ok<Err, A & { [k in K]: B }>({ ...Object(this.value), [k.toString()]: b })
);
return result.map<A & { [k in K]: B }>(b => ({
...Object(this.value),
[k.toString()]: b,
}));
}
}

Expand Down

0 comments on commit dec4cac

Please sign in to comment.