API improvement ideas (usable behind @beta flag on npm)
See original GitHub issueJust writing this here publicly to see if others agree or disagree.
I think it would be nice to have a utility function that has the following signature:
Promise<Result<T, E>> => ResultAsync<T, E>
Since sometimes it’s easier to write a function using async/await
syntax.
Additionally, I am also thinking it would be nice to have another utility function with the following signature:
Result<T, E> => ResultAsyncT, E>
I guess the above would be called intoResultAsync
or something like that?
Curious to hear what folks think.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
launchdarkly-api - npm
This REST API is for custom integrations, data export, or automating your feature flag workflows. DO NOT use this client library to include ......
Read more >learning-zone/nodejs-basics: Node.js Basics ( v18.x ) - GitHub
js for server-side coding. V8 is the JavaScript engine i.e. it parses and executes JavaScript code. The DOM, and the other Web Platform...
Read more >GitLab Runner feature flags
Feature flag Default value Deprecated
FF_CMD_DISABLE_DELAYED_ERROR_LEVEL_EXPANSION false No
FF_NETWORK_PER_BUILD false No
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY false No
Read more >Changelog | Meteor API Docs
Node.js security update to 12.21.0; meteor create my-app --plan professional new flag plan to enable you to choose a plan from the deploy...
Read more >Kubernetes 1.23: Pod Security Graduates to Beta
kind create cluster --image kindest/node:v1.23.0 ... The best way to confirm the API's default enabled plugins is to check the Kubernetes ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released a
combine
utility function behind a@beta
flag on npm!Docs on combine: https://github.com/supermacro/neverthrow/releases/tag/v2.8.0-beta.0
Source code: https://github.com/supermacro/neverthrow/blob/master/src/utils.ts
Feedback always welcome!
I personally never use
Promise<Result>
in my code because if there’s aResult
inside a function, it means that I have control over what’s happening inside and can make that function return aResultAsync
. Also, once you have aPromise
, the caller will have toawait
it and you push the untyped error problem up the call chain. My principle is to transform thePromise
s intoResultAsync
at the lowest level (third-party api / io) and useResultAsync
everywhere in my code.For your example, in which I guess your point is to call both
getSingleSite
andgetSiteComments
simultaneously, I would have writtenMaybe we could add a utility equivalent to
Promise.all
.