diff --git a/src/commonMain/kotlin/com/infendro/bytearray/ByteArray.kt b/src/commonMain/kotlin/com/infendro/bytearray/ByteArray.kt index 7947d7f..cb33a69 100644 --- a/src/commonMain/kotlin/com/infendro/bytearray/ByteArray.kt +++ b/src/commonMain/kotlin/com/infendro/bytearray/ByteArray.kt @@ -77,7 +77,7 @@ fun ByteArray.toIntArray( return toList() .chunked(4) - .map { it.toInt(order) } + .map { it.toByteArray().toInt(order) } .toIntArray() } @@ -99,7 +99,7 @@ fun ByteArray.toLongArray( return toList() .chunked(8) - .map { it.toLong(order) } + .map { it.toByteArray().toLong(order) } .toLongArray() } @@ -121,7 +121,7 @@ fun ByteArray.toUIntArray( return toList() .chunked(4) - .map { it.toUInt(order) } + .map { it.toByteArray().toUInt(order) } .toUIntArray() } @@ -143,6 +143,6 @@ fun ByteArray.toULongArray( return toList() .chunked(8) - .map { it.toULong(order) } + .map { it.toByteArray().toULong(order) } .toULongArray() } diff --git a/src/commonMain/kotlin/com/infendro/bytearray/Collection.kt b/src/commonMain/kotlin/com/infendro/bytearray/Collection.kt index 893eacb..f760d4e 100644 --- a/src/commonMain/kotlin/com/infendro/bytearray/Collection.kt +++ b/src/commonMain/kotlin/com/infendro/bytearray/Collection.kt @@ -1,7 +1,5 @@ package com.infendro.bytearray -import com.infendro.bytearray.ByteOrder.BIG_ENDIAN - fun MutableCollection.addAll( bytes: ByteArray, ) = addAll(bytes.toList()) @@ -9,67 +7,3 @@ fun MutableCollection.addAll( fun MutableCollection.addAll( bytes: UByteArray, ) = addAll(bytes.toList()) - -fun Collection.toInt( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toInt(order) - -fun Collection.toInt( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toInt(order) - -fun Collection.toIntArray( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toIntArray(order) - -fun Collection.toIntArray( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toIntArray(order) - -fun Collection.toLong( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toLong(order) - -fun Collection.toLong( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toLong(order) - -fun Collection.toLongArray( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toLongArray(order) - -fun Collection.toLongArray( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toLongArray(order) - -fun Collection.toUInt( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toUInt(order) - -fun Collection.toUInt( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toUInt(order) - -fun Collection.toUIntArray( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toUIntArray(order) - -fun Collection.toUIntArray( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toUIntArray(order) - -fun Collection.toULong( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toULong(order) - -fun Collection.toULong( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toULong(order) - -fun Collection.toULongArray( - order: ByteOrder = BIG_ENDIAN, -) = toByteArray().toULongArray(order) - -fun Collection.toULongArray( - order: ByteOrder = BIG_ENDIAN, -) = toUByteArray().toULongArray(order) diff --git a/src/commonMain/kotlin/com/infendro/bytearray/UByteArray.kt b/src/commonMain/kotlin/com/infendro/bytearray/UByteArray.kt index 82acab0..de6f666 100644 --- a/src/commonMain/kotlin/com/infendro/bytearray/UByteArray.kt +++ b/src/commonMain/kotlin/com/infendro/bytearray/UByteArray.kt @@ -74,7 +74,7 @@ fun UByteArray.toIntArray( return toList() .chunked(4) - .map { it.toInt(order) } + .map { it.toUByteArray().toInt(order) } .toIntArray() } @@ -96,7 +96,7 @@ fun UByteArray.toLongArray( return toList() .chunked(8) - .map { it.toLong(order) } + .map { it.toUByteArray().toLong(order) } .toLongArray() } @@ -118,7 +118,7 @@ fun UByteArray.toUIntArray( return toList() .chunked(4) - .map { it.toUInt(order) } + .map { it.toUByteArray().toUInt(order) } .toUIntArray() } @@ -140,6 +140,6 @@ fun UByteArray.toULongArray( return toList() .chunked(8) - .map { it.toULong(order) } + .map { it.toUByteArray().toULong(order) } .toULongArray() }