refactor and simplify functions
This commit is contained in:
@@ -39,24 +39,24 @@ fun ByteArray.padStart(
|
||||
length: Int,
|
||||
padByte: Byte,
|
||||
): ByteArray {
|
||||
return buildList {
|
||||
repeat(length - this@padStart.size) {
|
||||
add(padByte)
|
||||
}
|
||||
addAll(this@padStart)
|
||||
}.toByteArray()
|
||||
val bytes = mutableListOf<Byte>()
|
||||
repeat(length - size) {
|
||||
bytes += padByte
|
||||
}
|
||||
bytes += this.toList()
|
||||
return bytes.toByteArray()
|
||||
}
|
||||
|
||||
fun ByteArray.padEnd(
|
||||
length: Int,
|
||||
padByte: Byte,
|
||||
): ByteArray {
|
||||
return buildList {
|
||||
addAll(this@padEnd)
|
||||
repeat(length - this@padEnd.size) {
|
||||
add(padByte)
|
||||
}
|
||||
}.toByteArray()
|
||||
val bytes = mutableListOf<Byte>()
|
||||
bytes += this.toList()
|
||||
repeat(length - size) {
|
||||
bytes += padByte
|
||||
}
|
||||
return bytes.toByteArray()
|
||||
}
|
||||
|
||||
fun ByteArray.toInt(
|
||||
|
||||
Reference in New Issue
Block a user