[Wasm] jsFun itoa32 for wasmJs
diff --git a/libraries/stdlib/wasm/internal/kotlin/wasm/internal/Number2String.kt b/libraries/stdlib/wasm/internal/kotlin/wasm/internal/Number2String.kt index 86c061c..e4fd653 100644 --- a/libraries/stdlib/wasm/internal/kotlin/wasm/internal/Number2String.kt +++ b/libraries/stdlib/wasm/internal/kotlin/wasm/internal/Number2String.kt
@@ -44,15 +44,18 @@ return (CharCodes._0.code + input).toChar() } -internal fun itoa32(inputValue: Int): String { - if (inputValue == 0) return "0" +internal expect fun itoa32(inputValue: Int): String +//= js("inputValue.toString()") - val isNegative = inputValue < 0 - val absValue = if (isNegative) -inputValue else inputValue - val absValueString = utoa32(absValue.toUInt()) - - return if (isNegative) "-$absValueString" else absValueString -} +//{ +// if (inputValue == 0) return "0" +// +// val isNegative = inputValue < 0 +// val absValue = if (isNegative) -inputValue else inputValue +// val absValueString = utoa32(absValue.toUInt()) +// +// return if (isNegative) "-$absValueString" else absValueString +//} internal fun utoa32(inputValue: UInt): String { if (inputValue == 0U) return "0"
diff --git a/libraries/stdlib/wasm/js/internal/Number2String.kt b/libraries/stdlib/wasm/js/internal/Number2String.kt new file mode 100644 index 0000000..4307d81 --- /dev/null +++ b/libraries/stdlib/wasm/js/internal/Number2String.kt
@@ -0,0 +1,9 @@ +/* + * Copyright 2010-2025 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.wasm.internal + +@OptIn(ExperimentalWasmJsInterop::class) +internal actual fun itoa32(inputValue: Int): String = js("inputValue.toString()") \ No newline at end of file
diff --git a/libraries/stdlib/wasm/wasi/internal/Number2String.kt b/libraries/stdlib/wasm/wasi/internal/Number2String.kt new file mode 100644 index 0000000..883fee1 --- /dev/null +++ b/libraries/stdlib/wasm/wasi/internal/Number2String.kt
@@ -0,0 +1,16 @@ +/* + * Copyright 2010-2025 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.wasm.internal + +internal actual fun itoa32(inputValue: Int): String { + if (inputValue == 0) return "0" + + val isNegative = inputValue < 0 + val absValue = if (isNegative) -inputValue else inputValue + val absValueString = utoa32(absValue.toUInt()) + + return if (isNegative) "-$absValueString" else absValueString +} \ No newline at end of file