Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"build": "npm run clean && npm run build:ts && npm run build:copy",
"build:ts": "tsc -p tsconfig.json && tsc -p tsconfig.json -m esnext --outDir dist/esm/ -d false -declarationMap false",
"build:ts": "npx tsc -p tsconfig.json && npx tsc -p tsconfig.json -m esnext --outDir dist/esm/ -d false -declarationMap false",
"build:copy": "copyfiles README.md LICENSE src/package.json dist --flat && copyfiles src/rxjs-operators/package.json dist --up 1",
"clean": "rm -rf dist",
"test": "jest",
Expand Down
10 changes: 9 additions & 1 deletion src/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class NoneImpl implements BaseOption<never> {
return this;
}

or<T2>(other: Option<T2>): Option<T2> {
return other;
}

andThen<T2>(op: unknown): None {
return this;
}
Expand Down Expand Up @@ -151,6 +155,10 @@ class SomeImpl<T> implements BaseOption<T> {
return mapper(this.val);
}

or(other: Option<T>): Option<T> {
return this;
}

toResult<E>(error: E): Ok<T> {
return Ok(this.val);
}
Expand Down Expand Up @@ -213,7 +221,7 @@ export namespace Option {
if (option.some) {
return option as Some<OptionSomeTypes<T>[number]>;
} else {
return option as None;
continue;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ interface BaseResult<T, E> extends Iterable<T extends Iterable<infer U> ? U : ne
expect(msg: string): T;

/**
* Returns the contained `Ok` value, if does not exist. Throws an error if it does.
* Returns the contained `Err` value, if does not exist. Throws an error if it does.
* @param msg the message to throw if Ok value.
*/
expectErr(msg: string): T;
expectErr(msg: string): E;

/**
* Returns the contained `Ok` value.
* Because this function may throw, its use is generally discouraged.
Expand Down