All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hnau.emitter.extensions.byte.EmitterByteWithByteExtensions.kt Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package org.hnau.emitter.extensions.byte

import org.hnau.base.extensions.number.and
import org.hnau.base.extensions.number.or
import org.hnau.base.extensions.number.xor
import org.hnau.emitter.Emitter
import org.hnau.emitter.extensions.map
import org.hnau.emitter.observing.push.lateinit.combineWith


fun Emitter.toByte() = map(Byte::toByte)

operator fun Emitter.plus(other: Emitter) = combineWith(other, Byte::plus)
operator fun Emitter.minus(other: Emitter) = combineWith(other, Byte::minus)
operator fun Emitter.times(other: Emitter) = combineWith(other, Byte::times)
operator fun Emitter.div(other: Emitter) = combineWith(other, Byte::div)
operator fun Emitter.rem(other: Emitter) = combineWith(other, Byte::rem)
operator fun Emitter.rangeTo(other: Emitter) = combineWith(other, Byte::rangeTo)

operator fun Emitter.plus(other: Byte) = map { it + other }
operator fun Emitter.minus(other: Byte) = map { it - other }
operator fun Emitter.times(other: Byte) = map { it * other }
operator fun Emitter.div(other: Byte) = map { it / other }
operator fun Emitter.rem(other: Byte) = map { it % other }
operator fun Emitter.rangeTo(other: Byte) = map { it..other }

operator fun Byte.plus(other: Emitter) = other.map { this + it }
operator fun Byte.minus(other: Emitter) = other.map { this - it }
operator fun Byte.times(other: Emitter) = other.map { this * it }
operator fun Byte.div(other: Emitter) = other.map { this / it }
operator fun Byte.rem(other: Emitter) = other.map { this % it }
operator fun Byte.rangeTo(other: Emitter) = other.map { this..it }

infix fun Emitter.and(other: Emitter) = combineWith(other, Byte::and)
infix fun Emitter.or(other: Emitter) = combineWith(other, Byte::or)
infix fun Emitter.xor(other: Emitter) = combineWith(other, Byte::xor)
infix fun Emitter.and(other: Byte) = map { it and other }
infix fun Emitter.or(other: Byte) = map { it or other }
infix fun Emitter.xor(other: Byte) = map { it xor other }
infix fun Byte.and(other: Emitter) = other.map { this and it }
infix fun Byte.or(other: Emitter) = other.map { this or it }
infix fun Byte.xor(other: Emitter) = other.map { this xor it }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy