mirror of
https://github.com/Smaug123/gitea-repo-config
synced 2025-10-06 07:58:39 +00:00
21 lines
601 B
Forth
21 lines
601 B
Forth
namespace Gitea.Declarative
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal Array =
|
|
|
|
/// f takes a page number and a limit (i.e. a desired page size).
|
|
let getPaginated (f : int64 -> int64 -> 'a array Async) : 'a list Async =
|
|
let count = 30
|
|
|
|
let rec go (page : int) (acc : 'a array list) =
|
|
async {
|
|
let! result = f page count
|
|
|
|
if result.Length >= count then
|
|
return! go (page + 1) (result :: acc)
|
|
else
|
|
return (result :: acc) |> Seq.concat |> Seq.toList
|
|
}
|
|
|
|
go 1 []
|