3 ms·
I'd prefer an api like this: const [result, error] = attempt(() => someFunc()); This way you don't have to wrap all your functions.
by meowtimemania 3y ago
I'd prefer an api like this:
const [result, error] = attempt(() => someFunc());
This way you don't have to wrap all your functions.
- tentacleuno 3y agoThat seems a lot more ergonomic. I can already see someone copy-pasting `wrap(myFunction)(args)` everywhere :-)
- musicq 3y agoI think the most usual way in a project is to use this style. Wrap is a simple way to let you get Result type without refactoring your implementation. https://musicq.gitbook.io/unwrapit/recipe/return-result-without-wrap-it https://musicq.gitbook.io/unwrapit/recipe/return-result-with...
- meowtimemania 3y agoThen I'm tightly coupling all my code to this library. I would prefer to write javascript like normal and not import a library anytime I author a function.
- vmfunction 3y agohave you look at ts-fp, it is ts not js, but still.