Skip to content

Instantly share code, notes, and snippets.

@Foso
Created June 24, 2020 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Foso/f254410ba99722101b000e03181c4f45 to your computer and use it in GitHub Desktop.
Save Foso/f254410ba99722101b000e03181c4f45 to your computer and use it in GitHub Desktop.
KotlinJs get entries from Dict<T>
fun entriesOf(jsObject: dynamic): List<Pair<String, Any?>> =
(js("Object.entries") as (dynamic) -> Array<Array<Any?>>)
.invoke(jsObject)
.map { entry -> entry[0] as String to entry[1] }
fun mapEntriesOf(jsObject: dynamic): Map<String, Any?> =
entriesOf(jsObject).toMap()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment