Skip to content

Commit

Permalink
Don't enforce Readonly type on the user
Browse files Browse the repository at this point in the history
FossilOrigin-Name: cec693fd489a0d58b01543c2f32919e960585b9f36cd4a07836cb5a55c2535c8
  • Loading branch information
marv committed Jul 6, 2022
1 parent 37fe88b commit ff61e3c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { match } from "./match.ts";

export class Matcher<T> {
constructor(protected _value: Readonly<Option<T>>) {}
constructor(protected _value: Option<T>) {}

/**
* Allows to resolve inner value with given callbacks
Expand Down Expand Up @@ -140,7 +140,7 @@ export class Matcher<T> {
*
* @param defaultValue Value to return if Matcher value is nil
*/
unwrapOr(defaultValue: T): Some<Readonly<T>> {
unwrapOr(defaultValue: T): Some<T> {
if (isNone(this._value)) {
return defaultValue;
}
Expand All @@ -154,15 +154,15 @@ export class Matcher<T> {
* This is not considered safe, you should consider using `.ok()` to work with
* the value
*/
unwrap(): Some<Readonly<T>> | never {
unwrap(): Some<T> | never {
if (isNone(this._value)) {
throw new UnsafeOperationError(UNWRAP_ERROR_MSG);
}

return this._value;
}

expect(msg: string): Some<Readonly<T>> | never {
expect(msg: string): Some<T> | never {
if (isNone(this._value)) {
throw new UnsafeOperationError(msg);
}
Expand All @@ -179,6 +179,6 @@ export class Matcher<T> {
}

toString() {
return (this._value ?? "null").toString();
return (this._value ?? "null") + '';
}
}

0 comments on commit ff61e3c

Please sign in to comment.