1.3.2 release #7
@@ -19,27 +19,10 @@ jobs:
|
|||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
key: gradle-${{ hashFiles('**/libs.versions.toml') }}
|
key: gradle-${{ hashFiles('**/libs.versions.toml') }}
|
||||||
restore-keys: gradle-
|
restore-keys: gradle
|
||||||
path: |
|
path: |
|
||||||
~/.gradle/caches/
|
~/.gradle/caches/
|
||||||
~/.gradle/wrapper/
|
~/.gradle/wrapper/
|
||||||
|
|
||||||
- name: Cache Konan
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: konan-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: konan-
|
|
||||||
path: |
|
|
||||||
~/.konan/
|
|
||||||
|
|
||||||
- name: Cache Node
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: node-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: node-
|
|
||||||
path: |
|
|
||||||
~/.gradle/nodejs
|
|
||||||
~/.gradle/yarn
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: ./gradlew allTests
|
run: ./gradlew jvmTest
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commonMain.dependencies {
|
commonMain.dependencies {
|
||||||
implementation("com.infendro:bytes:1.3.1")
|
implementation("com.infendro:bytes:1.3.2")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.infendro.plugin.token
|
|||||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||||
|
|
||||||
group = "com.infendro"
|
group = "com.infendro"
|
||||||
version = "1.3.1"
|
version = "1.3.2"
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.infendro)
|
alias(libs.plugins.infendro)
|
||||||
|
|||||||
@@ -9,12 +9,16 @@ fun ByteArray.toInt(startIndex: Int = 0, order: ByteOrder = BIG_ENDIAN): Int {
|
|||||||
|
|
||||||
return when (order) {
|
return when (order) {
|
||||||
BIG_ENDIAN -> {
|
BIG_ENDIAN -> {
|
||||||
(this[startIndex].toInt() shl 24) or (this[startIndex + 1].toInt() shl 16) or
|
((this[startIndex].toInt() and 0xFF) shl 24) or
|
||||||
(this[startIndex + 2].toInt() shl 8) or this[startIndex + 3].toInt()
|
((this[startIndex + 1].toInt() and 0xFF) shl 16) or
|
||||||
|
((this[startIndex + 2].toInt() and 0xFF) shl 8) or
|
||||||
|
(this[startIndex + 3].toInt() and 0xFF)
|
||||||
}
|
}
|
||||||
LITTLE_ENDIAN -> {
|
LITTLE_ENDIAN -> {
|
||||||
this[startIndex].toInt() or (this[startIndex + 1].toInt() shl 8) or
|
(this[startIndex].toInt() and 0xFF) or
|
||||||
(this[startIndex + 2].toInt() shl 16) or (this[startIndex + 3].toInt() shl 24)
|
((this[startIndex + 1].toInt() and 0xFF) shl 8) or
|
||||||
|
((this[startIndex + 2].toInt() and 0xFF) shl 16) or
|
||||||
|
((this[startIndex + 3].toInt() and 0xFF) shl 24)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,16 +37,24 @@ fun ByteArray.toLong(startIndex: Int = 0, order: ByteOrder = BIG_ENDIAN): Long {
|
|||||||
|
|
||||||
return when (order) {
|
return when (order) {
|
||||||
BIG_ENDIAN -> {
|
BIG_ENDIAN -> {
|
||||||
(this[startIndex].toLong() shl 56) or (this[startIndex + 1].toLong() shl 48) or
|
((this[startIndex].toLong() and 0xFFL) shl 56) or
|
||||||
(this[startIndex + 2].toLong() shl 40) or (this[startIndex + 3].toLong() shl 32) or
|
((this[startIndex + 1].toLong() and 0xFFL) shl 48) or
|
||||||
(this[startIndex + 4].toLong() shl 24) or (this[startIndex + 5].toLong() shl 16) or
|
((this[startIndex + 2].toLong() and 0xFFL) shl 40) or
|
||||||
(this[startIndex + 6].toLong() shl 8) or this[startIndex + 7].toLong()
|
((this[startIndex + 3].toLong() and 0xFFL) shl 32) or
|
||||||
|
((this[startIndex + 4].toLong() and 0xFFL) shl 24) or
|
||||||
|
((this[startIndex + 5].toLong() and 0xFFL) shl 16) or
|
||||||
|
((this[startIndex + 6].toLong() and 0xFFL) shl 8) or
|
||||||
|
(this[startIndex + 7].toLong() and 0xFFL)
|
||||||
}
|
}
|
||||||
LITTLE_ENDIAN -> {
|
LITTLE_ENDIAN -> {
|
||||||
this[startIndex].toLong() or (this[startIndex + 1].toLong() shl 8) or
|
(this[startIndex].toLong() and 0xFFL) or
|
||||||
(this[startIndex + 2].toLong() shl 16) or (this[startIndex + 3].toLong() shl 24) or
|
((this[startIndex + 1].toLong() and 0xFFL) shl 8) or
|
||||||
(this[startIndex + 4].toLong() shl 32) or (this[startIndex + 5].toLong() shl 40) or
|
((this[startIndex + 2].toLong() and 0xFFL) shl 16) or
|
||||||
(this[startIndex + 6].toLong() shl 48) or (this[startIndex + 7].toLong() shl 56)
|
((this[startIndex + 3].toLong() and 0xFFL) shl 24) or
|
||||||
|
((this[startIndex + 4].toLong() and 0xFFL) shl 32) or
|
||||||
|
((this[startIndex + 5].toLong() and 0xFFL) shl 40) or
|
||||||
|
((this[startIndex + 6].toLong() and 0xFFL) shl 48) or
|
||||||
|
((this[startIndex + 7].toLong() and 0xFFL) shl 56)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,20 @@ fun ByteArray.copyInto(
|
|||||||
repeat(length / 4) { i ->
|
repeat(length / 4) { i ->
|
||||||
val offset = startIndex + (i * 4)
|
val offset = startIndex + (i * 4)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
(this[offset].toInt() shl 24) or (this[offset + 1].toInt() shl 16) or
|
((this[offset].toInt() and 0xFF) shl 24) or
|
||||||
(this[offset + 2].toInt() shl 8) or this[offset + 3].toInt()
|
((this[offset + 1].toInt() and 0xFF) shl 16) or
|
||||||
|
((this[offset + 2].toInt() and 0xFF) shl 8) or
|
||||||
|
(this[offset + 3].toInt() and 0xFF)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LITTLE_ENDIAN -> {
|
LITTLE_ENDIAN -> {
|
||||||
repeat(length / 4) { i ->
|
repeat(length / 4) { i ->
|
||||||
val offset = startIndex + (i * 4)
|
val offset = startIndex + (i * 4)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
this[offset].toInt() or (this[offset + 1].toInt() shl 8) or
|
(this[offset].toInt() and 0xFF) or
|
||||||
(this[offset + 2].toInt() shl 16) or (this[offset + 3].toInt() shl 24)
|
((this[offset + 1].toInt() and 0xFF) shl 8) or
|
||||||
|
((this[offset + 2].toInt() and 0xFF) shl 16) or
|
||||||
|
((this[offset + 3].toInt() and 0xFF) shl 24)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,20 +65,28 @@ fun ByteArray.copyInto(
|
|||||||
repeat(length / 8) { i ->
|
repeat(length / 8) { i ->
|
||||||
val offset = startIndex + (i * 8)
|
val offset = startIndex + (i * 8)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
(this[offset].toLong() shl 56) or (this[offset + 1].toLong() shl 48) or
|
((this[offset].toLong() and 0xFFL) shl 56) or
|
||||||
(this[offset + 2].toLong() shl 40) or (this[offset + 3].toLong() shl 32) or
|
((this[offset + 1].toLong() and 0xFFL) shl 48) or
|
||||||
(this[offset + 4].toLong() shl 24) or (this[offset + 5].toLong() shl 16) or
|
((this[offset + 2].toLong() and 0xFFL) shl 40) or
|
||||||
(this[offset + 6].toLong() shl 8) or this[offset + 7].toLong()
|
((this[offset + 3].toLong() and 0xFFL) shl 32) or
|
||||||
|
((this[offset + 4].toLong() and 0xFFL) shl 24) or
|
||||||
|
((this[offset + 5].toLong() and 0xFFL) shl 16) or
|
||||||
|
((this[offset + 6].toLong() and 0xFFL) shl 8) or
|
||||||
|
(this[offset + 7].toLong() and 0xFFL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LITTLE_ENDIAN -> {
|
LITTLE_ENDIAN -> {
|
||||||
repeat(length / 8) { i ->
|
repeat(length / 8) { i ->
|
||||||
val offset = startIndex + (i * 8)
|
val offset = startIndex + (i * 8)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
this[offset].toLong() or (this[offset + 1].toLong() shl 8) or
|
(this[offset].toLong() and 0xFFL) or
|
||||||
(this[offset + 2].toLong() shl 16) or (this[offset + 3].toLong() shl 24) or
|
((this[offset + 1].toLong() and 0xFFL) shl 8) or
|
||||||
(this[offset + 4].toLong() shl 32) or (this[offset + 5].toLong() shl 40) or
|
((this[offset + 2].toLong() and 0xFFL) shl 16) or
|
||||||
(this[offset + 6].toLong() shl 48) or (this[offset + 7].toLong() shl 56)
|
((this[offset + 3].toLong() and 0xFFL) shl 24) or
|
||||||
|
((this[offset + 4].toLong() and 0xFFL) shl 32) or
|
||||||
|
((this[offset + 5].toLong() and 0xFFL) shl 40) or
|
||||||
|
((this[offset + 6].toLong() and 0xFFL) shl 48) or
|
||||||
|
((this[offset + 7].toLong() and 0xFFL) shl 56)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,25 +5,6 @@ import kotlin.experimental.inv
|
|||||||
import kotlin.experimental.or
|
import kotlin.experimental.or
|
||||||
import kotlin.experimental.xor
|
import kotlin.experimental.xor
|
||||||
|
|
||||||
fun ByteArray.invInto(
|
|
||||||
destination: ByteArray,
|
|
||||||
destinationOffset: Int = 0,
|
|
||||||
startIndex: Int = 0,
|
|
||||||
endIndex: Int = size,
|
|
||||||
) {
|
|
||||||
val length = endIndex - startIndex
|
|
||||||
require(length >= 0)
|
|
||||||
require(startIndex in 0..(size - length))
|
|
||||||
require(destinationOffset in 0..(destination.size - length))
|
|
||||||
|
|
||||||
repeat(length) { i ->
|
|
||||||
destination[destinationOffset + i] = this[startIndex + i].inv()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ByteArray.inv() =
|
|
||||||
ByteArray(size).also { invInto(it) }
|
|
||||||
|
|
||||||
private inline fun ByteArray.combineInto(
|
private inline fun ByteArray.combineInto(
|
||||||
that: ByteArray,
|
that: ByteArray,
|
||||||
destination: ByteArray,
|
destination: ByteArray,
|
||||||
@@ -53,6 +34,25 @@ private inline fun ByteArray.combine(
|
|||||||
return ByteArray(size).also { combineInto(that, it, combine = combine) }
|
return ByteArray(size).also { combineInto(that, it, combine = combine) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ByteArray.invInto(
|
||||||
|
destination: ByteArray,
|
||||||
|
destinationOffset: Int = 0,
|
||||||
|
startIndex: Int = 0,
|
||||||
|
endIndex: Int = size,
|
||||||
|
) {
|
||||||
|
val length = endIndex - startIndex
|
||||||
|
require(length >= 0)
|
||||||
|
require(startIndex in 0..(size - length))
|
||||||
|
require(destinationOffset in 0..(destination.size - length))
|
||||||
|
|
||||||
|
repeat(length) { i ->
|
||||||
|
destination[destinationOffset + i] = this[startIndex + i].inv()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ByteArray.inv(): ByteArray =
|
||||||
|
ByteArray(size).also { invInto(it) }
|
||||||
|
|
||||||
fun ByteArray.andInto(
|
fun ByteArray.andInto(
|
||||||
that: ByteArray,
|
that: ByteArray,
|
||||||
destination: ByteArray,
|
destination: ByteArray,
|
||||||
@@ -62,7 +62,7 @@ fun ByteArray.andInto(
|
|||||||
thatStartIndex: Int = 0,
|
thatStartIndex: Int = 0,
|
||||||
) = combineInto(that, destination, destinationOffset, startIndex, endIndex, thatStartIndex) { a, b -> a and b }
|
) = combineInto(that, destination, destinationOffset, startIndex, endIndex, thatStartIndex) { a, b -> a and b }
|
||||||
|
|
||||||
infix fun ByteArray.and(that: ByteArray) =
|
infix fun ByteArray.and(that: ByteArray): ByteArray =
|
||||||
combine(that) { a, b -> a and b }
|
combine(that) { a, b -> a and b }
|
||||||
|
|
||||||
fun ByteArray.orInto(
|
fun ByteArray.orInto(
|
||||||
@@ -74,7 +74,7 @@ fun ByteArray.orInto(
|
|||||||
thatStartIndex: Int = 0,
|
thatStartIndex: Int = 0,
|
||||||
) = combineInto(that, destination, destinationOffset, startIndex, endIndex, thatStartIndex) { a, b -> a or b }
|
) = combineInto(that, destination, destinationOffset, startIndex, endIndex, thatStartIndex) { a, b -> a or b }
|
||||||
|
|
||||||
infix fun ByteArray.or(that: ByteArray) =
|
infix fun ByteArray.or(that: ByteArray): ByteArray =
|
||||||
combine(that) { a, b -> a or b }
|
combine(that) { a, b -> a or b }
|
||||||
|
|
||||||
fun ByteArray.xorInto(
|
fun ByteArray.xorInto(
|
||||||
@@ -86,5 +86,5 @@ fun ByteArray.xorInto(
|
|||||||
thatStartIndex: Int = 0,
|
thatStartIndex: Int = 0,
|
||||||
) = combineInto(that, destination, destinationOffset, startIndex, endIndex, thatStartIndex) { a, b -> a xor b }
|
) = combineInto(that, destination, destinationOffset, startIndex, endIndex, thatStartIndex) { a, b -> a xor b }
|
||||||
|
|
||||||
infix fun ByteArray.xor(that: ByteArray) =
|
infix fun ByteArray.xor(that: ByteArray): ByteArray =
|
||||||
combine(that) { a, b -> a xor b }
|
combine(that) { a, b -> a xor b }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.int
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun Int.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun Int.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(4).also { copyInto(it, order = order) }
|
ByteArray(4).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun Int.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun Int.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(4).also { copyInto(it, order = order) }
|
UByteArray(4).also { copyInto(it, order = order) }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.intarray
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun IntArray.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun IntArray.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(size * 4).also { copyInto(it, order = order) }
|
ByteArray(size * 4).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun IntArray.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun IntArray.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(size * 4).also { copyInto(it, order = order) }
|
UByteArray(size * 4).also { copyInto(it, order = order) }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.long
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun Long.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun Long.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(8).also { copyInto(it, order = order) }
|
ByteArray(8).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun Long.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun Long.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(8).also { copyInto(it, order = order) }
|
UByteArray(8).also { copyInto(it, order = order) }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.longarray
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun LongArray.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun LongArray.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(size * 8).also { copyInto(it, order = order) }
|
ByteArray(size * 8).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun LongArray.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun LongArray.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(size * 8).also { copyInto(it, order = order) }
|
UByteArray(size * 8).also { copyInto(it, order = order) }
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fun UByteArray.invInto(
|
|||||||
endIndex: Int = size,
|
endIndex: Int = size,
|
||||||
) = asByteArray().invInto(destination.asByteArray(), destinationOffset, startIndex, endIndex)
|
) = asByteArray().invInto(destination.asByteArray(), destinationOffset, startIndex, endIndex)
|
||||||
|
|
||||||
fun UByteArray.inv() =
|
fun UByteArray.inv(): UByteArray =
|
||||||
UByteArray(size).also { invInto(it) }
|
UByteArray(size).also { invInto(it) }
|
||||||
|
|
||||||
fun UByteArray.andInto(
|
fun UByteArray.andInto(
|
||||||
@@ -31,7 +31,7 @@ fun UByteArray.andInto(
|
|||||||
thatStartIndex,
|
thatStartIndex,
|
||||||
)
|
)
|
||||||
|
|
||||||
infix fun UByteArray.and(that: UByteArray) =
|
infix fun UByteArray.and(that: UByteArray): UByteArray =
|
||||||
UByteArray(size).also { andInto(that, it) }
|
UByteArray(size).also { andInto(that, it) }
|
||||||
|
|
||||||
fun UByteArray.orInto(
|
fun UByteArray.orInto(
|
||||||
@@ -50,7 +50,7 @@ fun UByteArray.orInto(
|
|||||||
thatStartIndex,
|
thatStartIndex,
|
||||||
)
|
)
|
||||||
|
|
||||||
infix fun UByteArray.or(that: UByteArray) =
|
infix fun UByteArray.or(that: UByteArray): UByteArray =
|
||||||
UByteArray(size).also { orInto(that, it) }
|
UByteArray(size).also { orInto(that, it) }
|
||||||
|
|
||||||
fun UByteArray.xorInto(
|
fun UByteArray.xorInto(
|
||||||
@@ -69,5 +69,5 @@ fun UByteArray.xorInto(
|
|||||||
thatStartIndex,
|
thatStartIndex,
|
||||||
)
|
)
|
||||||
|
|
||||||
infix fun UByteArray.xor(that: UByteArray) =
|
infix fun UByteArray.xor(that: UByteArray): UByteArray =
|
||||||
UByteArray(size).also { xorInto(that, it) }
|
UByteArray(size).also { xorInto(that, it) }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.uint
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun UInt.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun UInt.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(4).also { copyInto(it, order = order) }
|
ByteArray(4).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun UInt.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun UInt.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(4).also { copyInto(it, order = order) }
|
UByteArray(4).also { copyInto(it, order = order) }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.uintarray
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun UIntArray.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun UIntArray.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(size * 4).also { copyInto(it, order = order) }
|
ByteArray(size * 4).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun UIntArray.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun UIntArray.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(size * 4).also { copyInto(it, order = order) }
|
UByteArray(size * 4).also { copyInto(it, order = order) }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.ulong
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun ULong.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun ULong.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(8).also { copyInto(it, order = order) }
|
ByteArray(8).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun ULong.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun ULong.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(8).also { copyInto(it, order = order) }
|
UByteArray(8).also { copyInto(it, order = order) }
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.infendro.bytes.ulongarray
|
|||||||
import com.infendro.bytes.ByteOrder
|
import com.infendro.bytes.ByteOrder
|
||||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||||
|
|
||||||
fun ULongArray.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun ULongArray.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
|
||||||
ByteArray(size * 8).also { copyInto(it, order = order) }
|
ByteArray(size * 8).also { copyInto(it, order = order) }
|
||||||
|
|
||||||
fun ULongArray.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
fun ULongArray.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
|
||||||
UByteArray(size * 8).also { copyInto(it, order = order) }
|
UByteArray(size * 8).also { copyInto(it, order = order) }
|
||||||
|
|||||||
Reference in New Issue
Block a user