Skip to content

Commit 3677d0f

Browse files
committed
Optimize Result
1 parent 2090e80 commit 3677d0f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

JavaScript/5-result.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ class Result {
77
}
88

99
static create(input) {
10-
if (input instanceof globalThis.Error) {
11-
return new Result({ value: undefined, error: input });
12-
}
13-
return new Result({ value: input, error: undefined });
10+
return new Result(
11+
input instanceof globalThis.Error
12+
? { value: undefined, error: input }
13+
: { value: input, error: undefined },
14+
);
1415
}
1516

1617
static fromValue(value) {

0 commit comments

Comments
 (0)