Skip to content

WIP: Improve Result class - #555

Open
tshemsedinov wants to merge 1 commit into
masterfrom
result
Open

tshemsedinov wants to merge 1 commit into
masterfrom
result

Conversation

@tshemsedinov

Copy link
Copy Markdown
Member

No description provided.

@tshemsedinov tshemsedinov changed the title Improve Result class WIP: Improve Result class Jul 16, 2026

@tshemsedinov tshemsedinov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update tests according to code changes

class FrameParser {
static parse(buffer) {
if (buffer.length < 2) return Result.empty();
if (buffer.length < 2) return Result.ok(null);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is null by default so do not need to pass null, here and in all places like this

Comment on lines +185 to 187
return Result.fail(
new ParseError(PARSE_ERR_CODES.PROTOCOL_ERROR_COMMON, 'Protocol error'),
);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use intermediate identifiers

Comment thread lib/websocket/result.js
Comment on lines +18 to 20
static fail(error) {
return new Result(null, error);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need an error by default

Comment thread lib/websocket/result.js

static async fromAsync(fn) {
try {
return Result.ok(await fn());

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await at separate line

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.

1 participant