You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
proposal: @std/result, a plain-object Result<T, E> with tryCatch #7305
Is your feature request related to a problem? Please describe.
Everyone hand-rolls the same Result type. JSR has 30+ @*/result packages. Theo Browne's tryCatch gist has 877 stars and 133 forks, each fork with a slightly different shape.
Describe the solution you'd like
A small, unstable @std/result. Plain objects, no classes, structuredClone and JSON safe:
Field names follow the TC39 try operator (ok / value / error), so this is the future shape, not a competing one. On top: ok, err, isOk, isErr, tryCatch, map, mapErr, andThen, unwrapOr, match. That's the whole package.
No generators, no do-notation, no fluent chains. Those belong in neverthrow and Effect.
#525 turned down the Go tuple in 2019 as non-idiomatic. Agreed. A discriminated union narrows, a tuple doesn't.
Happy to open a PR if there's appetite.
Describe alternatives you've considered
neverthrow, Effect, better-result: class-based, bigger, and std shouldn't bless one vendor.
Wait for the try operator: Stage 0, no champion.
Keep hand-rolling: the status quo, and the reason for this issue.
Activity