Is your feature request related to a problem? Please describe.
I'm on my fourth project using Crocks and I keep reaching for the same function getPropOrError (and getPathOrError). Instead of me releasing my own library, or copy/pasting the function around I think it would be good to have this in the standard library.
Describe the solution you'd like
getPropOrError :: String -> a -> Result Error b
getPathOrError :: [ String ] -> a -> Result Error b
Describe alternatives for how you do this now
Doing a maybeToResult on getProp with an Error if getProp returns a Nothing.
Code
Do you have example code or tests in a Repl for what you'd like added?
// getPropOrError :: String -> a -> Result Error b
const getPropOrError = curry((prop, obj) =>
maybeToResult(new Error(`'${prop}' is mandatory and missing`), getProp(prop, obj))
);
Additional context
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe.
I'm on my fourth project using Crocks and I keep reaching for the same function
getPropOrError(andgetPathOrError). Instead of me releasing my own library, or copy/pasting the function around I think it would be good to have this in the standard library.Describe the solution you'd like
getPropOrError :: String -> a -> Result Error bgetPathOrError :: [ String ] -> a -> Result Error bDescribe alternatives for how you do this now
Doing a
maybeToResultongetPropwith anErrorifgetPropreturns aNothing.Code
Do you have example code or tests in a Repl for what you'd like added?
Additional context
Add any other context or screenshots about the feature request here.