average

fun <T : Number> Flux<T>.average(): Mono<Double>

Extension to compute the Double average of all values emitted by a Flux of Number and return it as a Mono of Double.

Note that since Double are more precise, some seemingly rounded Floats (e.g. 1.6f) may convert to Doubles with more decimals (eg. 1.600000023841858), producing sometimes unexpected averages.

Author

Simon Baslé

Since

1.0.0


fun <T> Flux<T>.average(mapper: (T) -> Number): Mono<Double>

Extension to map arbitrary values in a Flux to Numbers and return the average of these Numbers as a Mono of Double.

Note that since Double are more precise than Float, some seemingly rounded Floats (e.g. 1.6f) may convert to Doubles with more decimals (eg. 1.600000023841858), producing sometimes unexpected results.

Author

Simon Baslé

Since

1.0.0

Parameters

mapper

a lambda converting values to Number