Skip to content

Commit f8eac76

Browse files
elizarovqwwdfsad
authored andcommitted
Rename transform parameters for consistency with stdlib
transformer -> transform
1 parent 6e81083 commit f8eac76

File tree

1 file changed

+11
-9
lines changed
  • kotlinx-coroutines-core/common/src/flow/operators

1 file changed

+11
-9
lines changed

kotlinx-coroutines-core/common/src/flow/operators/Transform.kt

+11-9
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import kotlin.jvm.*
1212
import kotlinx.coroutines.flow.unsafeFlow as flow
1313

1414
/**
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.
1717
*
1818
* This operator is useless by itself, but can be used as a building block of user-specific operators:
1919
* ```
@@ -26,10 +26,10 @@ import kotlinx.coroutines.flow.unsafeFlow as flow
2626
* ```
2727
*/
2828
@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> {
3030
return flow {
3131
collect { value ->
32-
transformer(value)
32+
transform(value)
3333
}
3434
}
3535
}
@@ -70,17 +70,19 @@ public fun <T: Any> Flow<T?>.filterNotNull(): Flow<T> = flow<T> {
7070
}
7171

7272
/**
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.
7474
*/
7575
@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+
}
7779

7880
/**
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.
8082
*/
8183
@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
8486
emit(transformed)
8587
}
8688

0 commit comments

Comments
 (0)