@@ -12,8 +12,8 @@ import kotlin.jvm.*
12
12
import kotlinx.coroutines.flow.unsafeFlow as flow
13
13
14
14
/* *
15
- * Applies [transformer ] function to each value of the given flow.
16
- * [transformer ] is a generic function that may transform emitted element, skip it or emit it multiple times.
15
+ * Applies [transform ] function to each value of the given flow.
16
+ * [transform ] is a generic function that may transform emitted element, skip it or emit it multiple times.
17
17
*
18
18
* This operator is useless by itself, but can be used as a building block of user-specific operators:
19
19
* ```
@@ -26,10 +26,10 @@ import kotlinx.coroutines.flow.unsafeFlow as flow
26
26
* ```
27
27
*/
28
28
@FlowPreview
29
- public fun <T , R > Flow<T>.transform (@BuilderInference transformer : suspend FlowCollector <R >.(value: T ) -> Unit ): Flow <R > {
29
+ public fun <T , R > Flow<T>.transform (@BuilderInference transform : suspend FlowCollector <R >.(value: T ) -> Unit ): Flow <R > {
30
30
return flow {
31
31
collect { value ->
32
- transformer (value)
32
+ transform (value)
33
33
}
34
34
}
35
35
}
@@ -70,17 +70,19 @@ public fun <T: Any> Flow<T?>.filterNotNull(): Flow<T> = flow<T> {
70
70
}
71
71
72
72
/* *
73
- * Returns a flow containing the results of applying the given [transformer ] function to each value of the original flow.
73
+ * Returns a flow containing the results of applying the given [transform ] function to each value of the original flow.
74
74
*/
75
75
@FlowPreview
76
- public fun <T , R > Flow<T>.map (transformer : suspend (value: T ) -> R ): Flow <R > = transform { value -> emit(transformer(value)) }
76
+ public fun <T , R > Flow<T>.map (transform : suspend (value: T ) -> R ): Flow <R > = transform { value ->
77
+ emit(transform(value))
78
+ }
77
79
78
80
/* *
79
- * Returns a flow that contains only non-null results of applying the given [transformer ] function to each value of the original flow.
81
+ * Returns a flow that contains only non-null results of applying the given [transform ] function to each value of the original flow.
80
82
*/
81
83
@FlowPreview
82
- public fun <T , R : Any > Flow<T>.mapNotNull (transformer : suspend (value: T ) -> R ? ): Flow <R > = transform { value ->
83
- val transformed = transformer (value) ? : return @transform
84
+ public fun <T , R : Any > Flow<T>.mapNotNull (transform : suspend (value: T ) -> R ? ): Flow <R > = transform { value ->
85
+ val transformed = transform (value) ? : return @transform
84
86
emit(transformed)
85
87
}
86
88
0 commit comments