From 6e20fc39299aeeb0af58691edd4c2a2a36b2e69e Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 28 Dec 2023 22:14:15 +0300 Subject: [PATCH] fix valueSequence --- CHANGELOG.md | 1 + build.gradle.kts | 2 +- .../commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cc1c21d..8e2861e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Fixed - Partially fixed a bug with `MutableMeta` observable wrappers. +- `valueSequence` now include root value. So `meta.update` works properly. ### Security diff --git a/build.gradle.kts b/build.gradle.kts index 1fa05824..33be577c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { allprojects { group = "space.kscience" - version = "0.7.2-dev-1" + version = "0.7.2-dev-2" } subprojects { diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt index 979c8782..5cf53c75 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt @@ -188,10 +188,12 @@ public operator fun > 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> = sequence { items.forEach { (key, item) -> + value?.let { yield(Name.EMPTY to it) } item.value?.let { itemValue -> yield(key.asName() to itemValue) }