Skip to content

refactor(async-result): convert class to functional pattern#236

Merged
AliiiBenn merged 1 commit intomainfrom
fix/async-result-functional
Mar 27, 2026
Merged

refactor(async-result): convert class to functional pattern#236
AliiiBenn merged 1 commit intomainfrom
fix/async-result-functional

Conversation

@AliiiBenn
Copy link
Copy Markdown
Member

Summary

  • Convert AsyncResult from a class to a functional pattern using factory functions and frozen objects
  • This brings AsyncResult in line with Result, Maybe, and Try which all use frozen object patterns
  • All 492 tests pass, maintaining full backward compatibility

Changes

  • AsyncResult is now a callable factory function (AsyncResultFactory) that returns objects implementing AsyncResultInstance
  • Instance methods (map, tap, flatMap, etc.) are attached to the returned objects
  • Static methods (ok, err, fromPromise, fromValue, fromError) are attached to the factory function
  • Thenable behavior preserved via then/catch/finally methods

Test plan

  • All 492 tests pass
  • TypeScript compilation successful
  • Build successful
  • Lint passes (only pre-existing warnings)

Closes #227

🤖 Generated with Claude Code

AsyncResult is now implemented as a callable factory function returning
frozen objects, consistent with Result, Maybe, and Try patterns.

Changes:
- AsyncResult is now a callable factory function with static methods
- Instance methods (map, tap, flatMap, etc.) are attached to objects
- Thenable behavior maintained via then/catch/finally methods
- All existing tests pass, full backward compatibility preserved

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
core-web Ready Ready Preview, Comment Mar 27, 2026 3:18pm

@AliiiBenn AliiiBenn merged commit 8281fe1 into main Mar 27, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncResult should not be a class

1 participant