@@ -6,33 +6,36 @@ public struct Connection<Node: Sendable>: Sendable {
66 public let pageInfo : PageInfo
77}
88
9- public extension Connection where Node: Identifiable , Node. ID: LosslessStringConvertible {
10- static func id( _ cursor: String ) -> Node . ID ? {
9+ extension Connection where Node: Identifiable , Node. ID: LosslessStringConvertible {
10+ public static func id( _ cursor: String ) -> Node . ID ? {
1111 cursor. base64Decoded ( ) . flatMap { Node . ID ( $0) }
1212 }
1313
14- static func cursor( _ node: Node ) -> String {
14+ public static func cursor( _ node: Node ) -> String {
1515 node. id. description. base64Encoded ( ) !
1616 }
1717}
1818
19- public extension Sequence where Element: Sendable , Element: Identifiable ,
20- Element. ID: LosslessStringConvertible {
21- func connection( from arguments: Paginatable ) throws -> Connection < Element > {
19+ extension Sequence
20+ where
21+ Element: Sendable , Element: Identifiable ,
22+ Element. ID: LosslessStringConvertible
23+ {
24+ public func connection( from arguments: Paginatable ) throws -> Connection < Element > {
2225 try connection ( from: arguments, makeCursor: Connection< Element> . cursor)
2326 }
2427
25- func connection( from arguments: ForwardPaginatable ) throws -> Connection < Element > {
28+ public func connection( from arguments: ForwardPaginatable ) throws -> Connection < Element > {
2629 try connection ( from: arguments, makeCursor: Connection< Element> . cursor)
2730 }
2831
29- func connection( from arguments: BackwardPaginatable ) throws -> Connection < Element > {
32+ public func connection( from arguments: BackwardPaginatable ) throws -> Connection < Element > {
3033 try connection ( from: arguments, makeCursor: Connection< Element> . cursor)
3134 }
3235}
3336
34- public extension Sequence where Element: Sendable {
35- func connection(
37+ extension Sequence where Element: Sendable {
38+ public func connection(
3639 from arguments: Paginatable ,
3740 makeCursor: @escaping ( Element ) throws -> String
3841 ) throws -> Connection < Element > {
@@ -43,7 +46,7 @@ public extension Sequence where Element: Sendable {
4346 )
4447 }
4548
46- func connection(
49+ public func connection(
4750 from arguments: ForwardPaginatable ,
4851 makeCursor: @escaping ( Element ) throws -> String
4952 ) throws -> Connection < Element > {
@@ -54,7 +57,7 @@ public extension Sequence where Element: Sendable {
5457 )
5558 }
5659
57- func connection(
60+ public func connection(
5861 from arguments: BackwardPaginatable ,
5962 makeCursor: @escaping ( Element ) throws -> String
6063 ) throws -> Connection < Element > {
@@ -96,19 +99,16 @@ func slicingCursor<Node>(
9699) -> ArraySlice < Edge < Node > > {
97100 var edges = ArraySlice ( edges)
98101
99- if
100- let after = arguments. after,
101- let afterIndex = edges
102- . firstIndex ( where: { $0. cursor == after } ) ?
103- . advanced ( by: 1 )
102+ if let after = arguments. after,
103+ let afterIndex =
104+ edges. firstIndex ( where: { $0. cursor == after } ) ? . advanced ( by: 1 )
104105 {
105106 edges = edges [ afterIndex... ]
106107 }
107108
108- if
109- let before = arguments. before,
110- let beforeIndex = edges
111- . firstIndex ( where: { $0. cursor == before } )
109+ if let before = arguments. before,
110+ let beforeIndex =
111+ edges. firstIndex ( where: { $0. cursor == before } )
112112 {
113113 edges = edges [ ..< beforeIndex]
114114 }
0 commit comments