Created
June 13, 2023 08:11
-
-
Save davidlhw/7632d48267f511013ec435711c0343bf to your computer and use it in GitHub Desktop.
A simple wrapper to handle IAsyncEnumerable in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type System.Collections.Generic.IAsyncEnumerable<'T> with | |
member this.AsTask () = task { | |
let mutable nxt = true | |
let output = ResizeArray() | |
let enumerator = this.GetAsyncEnumerator() | |
while nxt do | |
let! next = enumerator.MoveNextAsync() | |
nxt <- next | |
if nxt then output.Add enumerator.Current | |
return output.ToArray() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment