Convert various arguments into a ByteArray.
This package is part of the datkt.bytes
package.
$ npm install @datkt/bytes-from
import datkt.bytes.bytesFrom
fun main(args: Array<String>) {
run { val bytes = bytesFrom(0xa, 0xb, 0xc, 0xd) } // or
run { val bytes = bytesFrom(arrayOf(0xa, 0xb, 0xc, 0xd)) } // or
run { val bytes = bytesFrom("hello") } // or
run { val bytes = bytesFrom(32) }
}
Converts a variadic array of Number
to a ByteArray
val bytes = bytesFrom(0xfe, 0xed, 0xbe, 0xef)
val bytes = bytesFrom(*arrayOf(0xfe, 0xed, 0xbe, 0xef))
Converts a ByteArray
to a new ByteArray
val bytes = bytesFrom(bytesFrom(0xfe, 0xed, 0xbe, 0xef))
Converts an Array
of Number
to a ByteArray
val bytes = bytesFrom(arrayOf(0xfe, 0xed, 0xbe, 0xef))
Converts a String
to a ByteArray
val bytes = bytesFrom("feedbeef")
Converts a Number
to a ByteArray
val bytes = bytesFrom(16)
Converts a Char
to a ByteArray
val bytes = bytesFrom('a')
Converts an Any?
to an empty ByteArray
val bytes = bytesFrom()
val bytes = bytesFrom(null)
val bytes = bytesFrom(fun() { })
val bytes = bytesFrom(true)
- Kotlin/Native and the
konanc
command line program.
MIT