fix valueSequence

This commit is contained in:
Alexander Nozik 2023-12-28 22:14:15 +03:00
parent f9e7d0098f
commit 6e20fc3929
3 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,7 @@
### Fixed
- Partially fixed a bug with `MutableMeta` observable wrappers.
- `valueSequence` now include root value. So `meta.update` works properly.
### Security

View File

@ -8,7 +8,7 @@ plugins {
allprojects {
group = "space.kscience"
version = "0.7.2-dev-1"
version = "0.7.2-dev-2"
}
subprojects {

View File

@ -188,10 +188,12 @@ public operator fun <M : TypedMeta<M>> M?.get(key: String): M? = this?.get(key.p
/**
* Get a sequence of [Name]-[Value] pairs using top-down traversal of the tree
* Get a sequence of [Name]-[Value] pairs using top-down traversal of the tree.
* The sequence includes root value with empty name
*/
public fun Meta.valueSequence(): Sequence<Pair<Name, Value>> = sequence {
items.forEach { (key, item) ->
value?.let { yield(Name.EMPTY to it) }
item.value?.let { itemValue ->
yield(key.asName() to itemValue)
}