File tree Expand file tree Collapse file tree
src/FSharp.Control.AsyncSeq Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1115,6 +1115,29 @@ module AsyncSeq =
11151115
11161116 let takeUntil signal source = takeUntilSignal signal source
11171117
1118+ let takeWhileInclusive ( f : 'a -> bool ) ( s : AsyncSeq < 'a >) : AsyncSeq < 'a > =
1119+ { new IAsyncEnumerable< 'a> with
1120+ member __.GetEnumerator () =
1121+ let en = s.GetEnumerator()
1122+ let fin = ref false
1123+ { new IAsyncEnumerator< 'a> with
1124+
1125+ member __.MoveNext () =
1126+ async {
1127+ if ! fin then return None
1128+ else
1129+ let! next = en.MoveNext()
1130+ match next with
1131+ | None -> return None
1132+ | Some a ->
1133+ if f a then return Some a
1134+ else
1135+ fin := true
1136+ return Some a
1137+ }
1138+
1139+ member __.Dispose () = en.Dispose() } }
1140+
11181141 let skipWhileAsync p ( source : AsyncSeq < 'T >) : AsyncSeq < _ > = asyncSeq {
11191142 use ie = source.GetEnumerator()
11201143 let! move = ie.MoveNext()
You can’t perform that action at this time.
0 commit comments