From d32a4d5d431edfa3d71401da1e9d5442013b3852 Mon Sep 17 00:00:00 2001 From: Wayne Maurer Date: Tue, 5 Jan 2021 23:08:01 +0100 Subject: [PATCH] add Refinement overload to findFirst --- src/Lens.ts | 10 +++++++--- src/Optional.ts | 10 +++++++--- src/Prism.ts | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Lens.ts b/src/Lens.ts index ab4d603..4210250 100644 --- a/src/Lens.ts +++ b/src/Lens.ts @@ -235,9 +235,13 @@ export function traverse(T: Traversable1): (sta: Lens(predicate: Predicate) => (sa: Lens>) => Optional = - /*#__PURE__*/ - flow(_.findFirst, composeOptional) +export function findFirst( + refinement: Refinement +): (sa: Lens>) => Optional +export function findFirst(predicate: Predicate): (sa: Lens>) => Optional +export function findFirst(predicate: Predicate): (sa: Lens>) => Optional { + return flow(_.findFirst, composeOptional)(predicate) +} // ------------------------------------------------------------------------------------- // pipeables diff --git a/src/Optional.ts b/src/Optional.ts index 704bd66..0f9ad37 100644 --- a/src/Optional.ts +++ b/src/Optional.ts @@ -222,9 +222,13 @@ export function traverse(T: Traversable1): (sta: Option * @category combinators * @since 2.3.2 */ -export const findFirst: (predicate: Predicate) => (sa: Optional>) => Optional = - /*#__PURE__*/ - flow(_.findFirst, compose) +export function findFirst( + refinement: Refinement +): (sa: Optional>) => Optional +export function findFirst(predicate: Predicate): (sa: Optional>) => Optional +export function findFirst(predicate: Predicate): (sa: Optional>) => Optional { + return flow(_.findFirst, compose)(predicate) +} // ------------------------------------------------------------------------------------- // pipeables diff --git a/src/Prism.ts b/src/Prism.ts index 1526051..26f7bd6 100644 --- a/src/Prism.ts +++ b/src/Prism.ts @@ -258,9 +258,13 @@ export function traverse(T: Traversable1): (sta: Prism< * @category combinators * @since 2.3.2 */ -export const findFirst: (predicate: Predicate) => (sa: Prism>) => Optional = - /*#__PURE__*/ - flow(_.findFirst, composeOptional) +export function findFirst( + refinement: Refinement +): (sa: Prism>) => Optional +export function findFirst(predicate: Predicate): (sa: Prism>) => Optional +export function findFirst(predicate: Predicate): (sa: Prism>) => Optional { + return flow(_.findFirst, composeOptional)(predicate) +} // ------------------------------------------------------------------------------------- // pipeables