mirror of
https://github.com/yattee/yattee.git
synced 2026-08-26 08:52:32 +00:00
Chunk stateless feed requests to support more than 500 subscriptions (#967)
This commit is contained in:
committed by
GitHub
parent
c41016185c
commit
d46002e99a
17
Yattee/Extensions/Array+Chunked.swift
Normal file
17
Yattee/Extensions/Array+Chunked.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Array+Chunked.swift
|
||||
// Yattee
|
||||
//
|
||||
// Splitting arrays into fixed-size chunks.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Array {
|
||||
/// Splits the array into chunks of the specified size.
|
||||
func chunked(into size: Int) -> [[Element]] {
|
||||
stride(from: 0, to: count, by: size).map {
|
||||
Array(self[$0..<Swift.min($0 + size, count)])
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user