Skip to content

Commit

Permalink
feat: prepend & append
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Dec 11, 2024
1 parent c89637a commit a65f56f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/moe/matsuri/nb4a/utils/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ object Util {
val currentMap = (to[k] as Map<*, *>).toMutableMap()
currentMap += v
to[k] = currentMap
} else if (v is List<*>) {
if (k.startsWith("+")) { // prepend
val dstKey = k.removePrefix("+")
var currentList = (to[dstKey] as List<*>).toMutableList()
currentList = (v + currentList).toMutableList()
to[dstKey] = currentList
} else if (k.endsWith("+")) { // append
val dstKey = k.removeSuffix("+")
var currentList = (to[dstKey] as List<*>).toMutableList()
currentList = (currentList + v).toMutableList()
to[dstKey] = currentList
} else {
to[k] = v
}
} else {
to[k] = v
}
Expand Down

0 comments on commit a65f56f

Please # to comment.