Skip to content

Commit

Permalink
Do not freeze returned values
Browse files Browse the repository at this point in the history
FossilOrigin-Name: e58d2d667861170182f20effe84863edecfd2a7b2c9ecad57d5b90faf83e2653
  • Loading branch information
iMarv committed Apr 29, 2021
1 parent bb6c65e commit dbedd74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions mod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ Rhum.testPlan("option", () => {
});
});

Rhum.testSuite("match", () => {
Rhum.testCase("should freeze value", () => {
const val = match("testi");

Rhum.asserts.assert(Object.isFrozen(val.unwrap()));
});
});

Rhum.testSuite("toOption", () => {
Rhum.testCase("should return value", () => {
const original: Option<string> = "testi";
Expand Down
4 changes: 2 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function isNone(value: Option<unknown>): value is None {
* @param maybe Value that is possibly null or undefined
*/
export function match<T>(maybe: Option<T>): Matcher<T> {
return new Matcher(Object.freeze(maybe));
return new Matcher(maybe);
}

interface isSomeArg<T, R> {
Expand Down Expand Up @@ -123,7 +123,7 @@ export class Matcher<T> {
*/
unwrapOr(defaultValue: T): Some<Readonly<T>> {
if (isNone(this._value)) {
return Object.freeze(defaultValue);
return defaultValue;
}

return this._value;
Expand Down

0 comments on commit dbedd74

Please sign in to comment.