aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util/propertyutil.kt
blob: 795a0d2f61d6db8ffbe11bcb1846f70441dd3840 (plain)
1
2
3
4
5
6
7
8
9
package moe.nea.firmament.util

import kotlin.properties.ReadOnlyProperty

fun <T, V, M> ReadOnlyProperty<T, V>.map(mapper: (V) -> M): ReadOnlyProperty<T, M> {
    return ReadOnlyProperty { thisRef, property -> mapper(this@map.getValue(thisRef, property)) }
}