aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util/propertyutil.kt
blob: 7fee8045f7068dde976609395ebd833bddb80e9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
 * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

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)) }
}