Huge refactor to add better structure to the project. Separating features with their associated view and model structure. This should be better organization and will allow us to improve the overall architecture in the future. I forsee many more improvements that can follow this change. e.g. MVVM Arch As well as cleaning up duplicate, unused, functionality. Many files have global functions that can also be moved or be renamed. damus/ ├── Features/ │ ├── <Feature>/ │ │ ├── Views/ │ │ └── Models/ ├── Shared/ │ ├── Components/ │ ├── Media/ │ ├── Buttons/ │ ├── Extensions/ │ ├── Empty Views/ │ ├── ErrorHandling/ │ ├── Modifiers/ │ └── Utilities/ ├── Core/ │ ├── Nostr/ │ ├── NIPs/ │ ├── DIPs/ │ ├── Types/ │ ├── Networking/ │ └── Storage/ Signed-off-by: ericholguin <ericholguin@apache.org>
27 lines
747 B
Swift
27 lines
747 B
Swift
//
|
||
// Array.swift
|
||
// damus
|
||
//
|
||
// Created by Daniel D’Aquino on 2024-05-10.
|
||
//
|
||
|
||
import Foundation
|
||
|
||
extension Array {
|
||
/// Splits the array into chunks of the specified size.
|
||
/// - Parameter size: The maximum size of each chunk.
|
||
/// - Returns: An array of arrays, where each contained array is a chunk of the original array with up to `size` elements.
|
||
func chunked(into size: Int) -> [[Element]] {
|
||
guard size > 0 else { return [self] }
|
||
return stride(from: 0, to: count, by: size).map {
|
||
Array(self[$0..<Swift.min($0 + size, count)])
|
||
}
|
||
}
|
||
}
|
||
|
||
extension Array where Element: Equatable {
|
||
mutating func removeAll(equalTo item: Element) {
|
||
self.removeAll(where: { $0 == item })
|
||
}
|
||
}
|