Releases: Gozala/value-result
Release list
Implement `map2` ... `map5` functions.
In this release library API is extended with a following functions:
map2
Apply a function to two results, if both results are Ok. If not, the first argument which is an Error will propagate through.
Result.map2
( (x, y) => x + y
, Result.ok(1)
, Result.ok(2)
) // => Ok(3)
Result.map2
( (x, y) => x + y
, Result.ok(1)
, Result.error('NaN')
) // => Error('NaN')
Result.map2
( (x, y) => x + y
, Result.error('Boom')
, Result.ok(2)
) // => Error('Boom')
Result.map2
( (x, y) => x + y
, Result.error('Boom')
, Result.error('NaN')
) // => Error('Boom')map3
Apply a function to three results, if all results are Ok. If not, the first result that is Error will propagate through.
Result.map3
( (a, b, c) => a + b + c
, Result.ok(1)
, Result.ok(2)
, Result.ok(10)
) // => Ok(13)
Result.map3
( (a, b, c) => a + b + c
, Result.ok(1)
, Result.error('NaN')
, Result.ok(10)
) // => Error('NaN')
Result.map3
( (a, b, c) => a + b + c
, Result.error('Boom')
, Result.ok(2)
, Result.ok(10)
) // => Error('Boom')
Result.map3
( (a, b, c) => a + b + c
, Result.error('Boom')
, Result.error('NaN')
, Result.ok(10)
) // => Error('Boom')
Result.map3
( (a, b, c) => a + b + c
, Result.ok(2)
, Result.ok(10)
, Result.error('Oops')
) // => Error('Oops')map4
Apply a function to four results, if all results are Ok. If not, the first result that is Error will propagate through.
Result.map4
( (a, b, c, d) => a + b + c + d
, Result.ok(1)
, Result.ok(2)
, Result.ok(10)
, Result.ok(7)
) // => Ok(20)
Result.map4
( (a, b, c, d) => a + b + c + d
, Result.ok(1)
, Result.ok(2)
, Result.error('Oops')
, Result.ok(7)
) // => Error('Oops')
Result.map4
( (a, b, c, d) => a + b + c + d
, Result.ok(1)
, Result.ok(2)
, Result.ok(7)
, Result.error('Oops')
) // => Error('Oops')
Result.map4
( (a, b, c, d) => a + b + c + d
, Result.ok(1)
, Result.error('Oops')
, Result.ok(2)
, Result.error('Boom')
) // => Error('Oops')map5
Apply a function to five results, if all results are Ok. If not, the first result that is Error will propagate through.
Result.map5
( (a, b, c, d, e) => a + b + c + d + e
, Result.ok(1)
, Result.ok(2)
, Result.ok(10)
, Result.ok(7)
, Result.ok(3)
) // => Ok(23)
Result.map5
( (a, b, c, d, e) => a + b + c + d + e
, Result.ok(1)
, Result.ok(2)
, Result.error('Oops')
, Result.ok(7)
, Result.ok(3)
) // => Error('Oops')
Result.map5
( (a, b, c, d, e) => a + b + c + d + e
, Result.ok(1)
, Result.ok(2)
, Result.ok(7)
, Result.ok(3)
, Result.error('Oops')
) // => Error('Oops')
Result.map5
( (a, b, c, d, e) => a + b + c + d + e
, Result.ok(1)
, Result.error('Oops')
, Result.ok(2)
, Result.error('Boom')
, Result.ok(7)
) // => Error('Oops')Reconfigure babel & flow
Babel bug T7044 caused generated code to contain flow comments. That in turn triggered facebook/flow#1311 which:
- Forced us to configure flow such that it would ignore
liband required mapping configuration so that test files would also type check. - Forced users that depend on this package to go through the same configuration hazards as above.
With this change additional babel plugin is used to really stripping out comments from output and there for avoid flow failures when dealing with lib which is no longer ignored & there for users don’t need additional configuration.