byteunits icon indicating copy to clipboard operation
byteunits copied to clipboard

Kotlin Multiplatform support

Open vanniktech opened this issue 3 years ago • 3 comments

Formatting support could be extension functions on JVM/Android. I don't have an idea how to do it on native though

vanniktech avatar Jun 26 '22 22:06 vanniktech

Happy to do this if I can find the time.

Probably want to do this in some typical steps (which each might have a few PRs):

  • Gradle
  • GitHub Actions
  • Kotlin JVM only
  • Kotlin MPP

I'm happy to accept PRs for this stuff. The smaller and more focused the easier it is for me to review and smash the merge button.

JakeWharton avatar Jun 28 '22 19:06 JakeWharton

Regarding formatting, what's your desired API?

Should we have fun format(bytes: Long, pattern: String): String in commonMain and then use DecimalFormat(pattern) via expect/actual all the way for all targets?

And:

@JvmOverloads fun format(
      bytes: Long,
      format: NumberFormat = DecimalFormat(DEFAULT_FORMAT_PATTERN),
    ): String {

only as an extension function in jvmMain?

vanniktech avatar Jul 12 '22 18:07 vanniktech

Hmm. It would be really nice to maintain binary compatibility so we may have to do an expect/actual dance on the enums so as to be able to hang it directly on the types. It certainly sucks for maintaining, but it'll make consumer's lives easier.

JakeWharton avatar Jul 14 '22 02:07 JakeWharton