WIP fix dynamic meta

This commit is contained in:
Alexander Nozik 2021-07-30 12:00:18 +03:00
parent c8bd3390cb
commit b387b21554

View File

@ -53,13 +53,23 @@ public class DynamicMeta(internal val obj: dynamic) : Meta {
}
override val items: Map<NameToken, Meta>
get() = keys().flatMap<String, Pair<NameToken, Meta>> { key ->
get() = if (isPrimitive(obj)) {
emptyMap()
} else if (isArray(obj)) {
if((obj as Array<Any?>).all { isPrimitive(it) }){
emptyMap()
} else{
TODO()
}
} else keys().flatMap<String, Pair<NameToken, Meta>> { key ->
val value = obj[key] ?: return@flatMap emptyList()
when {
isArray(value) -> {
val array = value as Array<Any?>
if (array.all { isPrimitive(it) }) {
emptyList()
//primitive value
//emptyList()
listOf(NameToken(key) to DynamicMeta(value))
} else {
array.mapIndexedNotNull { index, it ->
val item = DynamicMeta(it)
@ -67,9 +77,6 @@ public class DynamicMeta(internal val obj: dynamic) : Meta {
}
}
}
isPrimitive(obj) -> {
emptyList()
}
else -> {
val item = DynamicMeta(value)
listOf(NameToken(key) to item)