Skip to content

Commit

Permalink
feat: Add contains
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina committed Aug 14, 2022
1 parent 3bab4c5 commit db692ca
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export const mapOrElse =
return fn();
};

export const contains =
<T>(x: T) =>
(opt: Option<T>) =>
mapOr(false)((t) => t === x)(opt);

export const optResToResOpt = <E, T>(optRes: Option<Result<E, T>>): Result<E, Option<T>> => {
if (isNone(optRes)) {
return ok(none());
Expand Down

0 comments on commit db692ca

Please sign in to comment.