Skip to content

Commit 184019f

Browse files
authored
Change pullback generic names (#154)
* Change pullback generic names * Update Snapshotting.swift * Update Snapshotting.swift
1 parent 85a2e21 commit 184019f

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Sources/SnapshotTesting/Snapshotting.swift

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,40 @@ public struct Snapshotting<Value, Format> {
4646
}
4747
}
4848

49-
/// Transforms a strategy on `Value`s into a strategy on `A`s through a function `(A) -> Async<Value>`.
49+
/// Transforms a strategy on `Value`s into a strategy on `NewValue`s through a function `(NewValue) -> Async<Value>`.
5050
///
5151
/// - Parameters:
52-
/// - transform: A transform function from `A` into `Async<Value>`.
52+
/// - transform: A transform function from `NewValue` into `Async<Value>`.
5353
/// - otherValue: A value to be transformed.
54-
public func asyncPullback<A>(_ transform: @escaping (_ otherValue: A) -> Async<Value>) -> Snapshotting<A, Format> {
55-
return Snapshotting<A, Format>(
56-
pathExtension: self.pathExtension,
57-
diffing: self.diffing
58-
) { a0 in
59-
return .init { callback in
60-
transform(a0).run { a in
61-
self.snapshot(a).run { b in
62-
callback(b)
54+
public func asyncPullback<NewValue>(_ transform: @escaping (_ otherValue: NewValue) -> Async<Value>)
55+
-> Snapshotting<NewValue, Format> {
56+
57+
return Snapshotting<NewValue, Format>(
58+
pathExtension: self.pathExtension,
59+
diffing: self.diffing
60+
) { newValue in
61+
return .init { callback in
62+
transform(newValue).run { value in
63+
self.snapshot(value).run { snapshot in
64+
callback(snapshot)
65+
}
6366
}
6467
}
6568
}
66-
}
6769
}
6870

69-
/// Transforms a strategy on `Value`s into a strategy on `A`s through a function `(A) -> Value`.
71+
/// Transforms a strategy on `Value`s into a strategy on `NewValue`s through a function `(NewValue) -> Value`.
7072
///
7173
/// - Parameters:
72-
/// - transform: A transform function from `A` into `Value`.
74+
/// - transform: A transform function from `NewValue` into `Value`.
7375
/// - otherValue: A value to be transformed.
74-
public func pullback<A>(_ transform: @escaping (_ otherValue: A) -> Value) -> Snapshotting<A, Format> {
75-
return self.asyncPullback { Async(value: transform($0)) }
76+
public func pullback<NewValue>(_ transform: @escaping (_ otherValue: NewValue) -> Value) -> Snapshotting<NewValue, Format> {
77+
return self.asyncPullback { newValue in Async(value: transform(newValue)) }
7678
}
7779
}
7880

7981
/// A snapshot strategy where the type being snapshot is also a diffable type.
80-
public typealias SimplySnapshotting<A> = Snapshotting<A, A>
82+
public typealias SimplySnapshotting<Format> = Snapshotting<Format, Format>
8183

8284
extension Snapshotting where Value == Format {
8385
public init(pathExtension: String?, diffing: Diffing<Format>) {

0 commit comments

Comments
 (0)