summaryrefslogtreecommitdiff
path: root/u/types/fn/optional.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-07-20 13:03:39 -0700
committerElizabeth Hunt <me@liz.coffee>2025-07-20 13:03:39 -0700
commitdc4ac7742690f8f2bd759d57108ac4455e717fe9 (patch)
treef138ba41dd44bf703087eaa8ec43a22fe842923d /u/types/fn/optional.ts
parentdccb99505e92685ba8ade7c3be84555f2b539a47 (diff)
downloadci-dc4ac7742690f8f2bd759d57108ac4455e717fe9.tar.gz
ci-dc4ac7742690f8f2bd759d57108ac4455e717fe9.zip
Mount src directory from path on host running worker container
Diffstat (limited to 'u/types/fn/optional.ts')
-rw-r--r--u/types/fn/optional.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/u/types/fn/optional.ts b/u/types/fn/optional.ts
index 3396a45..504e496 100644
--- a/u/types/fn/optional.ts
+++ b/u/types/fn/optional.ts
@@ -1,4 +1,4 @@
-import { type Mapper, type Supplier, Tagged, isTagged } from '@emprespresso/pengueno';
+import { type Mapper, Predicate, type Supplier, Tagged, isTagged } from '@emprespresso/pengueno';
export type MaybeGiven<T> = T | undefined | null;
@@ -9,7 +9,7 @@ export class IOptionalEmptyError extends Error {}
export interface IOptional<t, T extends NonNullable<t> = NonNullable<t>> extends Tagged<IOptionalTag>, Iterable<T> {
readonly move: <_T>(t: MaybeGiven<_T>) => IOptional<_T>;
readonly map: <_T>(mapper: Mapper<T, MaybeGiven<_T>>) => IOptional<_T>;
- readonly filter: (mapper: Mapper<T, boolean>) => IOptional<T>;
+ readonly filter: (mapper: Predicate<T>) => IOptional<T>;
readonly flatMap: <_T>(mapper: Mapper<T, MaybeGiven<IOptional<_T>>>) => IOptional<_T>;
readonly orSome: (supplier: Supplier<MaybeGiven<t>>) => IOptional<T>;
readonly get: Supplier<T>;
@@ -48,11 +48,11 @@ export class Optional<t, T extends NonNullable<t> = NonNullable<t>> extends _Tag
}
public get(): T {
- if (isNone(this.self)) throw new IOptionalEmptyError('empty value');
+ if (isNone(this.self)) throw new IOptionalEmptyError('called get() on None optional');
return this.self.value;
}
- public filter(mapper: Mapper<T, boolean>): IOptional<T> {
+ public filter(mapper: Predicate<T>): IOptional<T> {
if (isNone(this.self) || !mapper(this.self.value)) return Optional.none();
return Optional.some(this.self.value);
}