Nonviolent Pirate Mobster

    @datkt/bytes-from

    1.0.4 • Public • Published

    bytes-from

    Convert various arguments into a ByteArray. This package is part of the datkt.bytes package.

    Installation

    $ npm install @datkt/bytes-from

    Usage

    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) }
    }

    API

    bytesFrom(vararg bytes: Number): ByteArray

    Converts a variadic array of Number to a ByteArray

    val bytes = bytesFrom(0xfe, 0xed, 0xbe, 0xef)
    val bytes = bytesFrom(*arrayOf(0xfe, 0xed, 0xbe, 0xef))

    bytesFrom(bytes: ByteArray): ByteArray

    Converts a ByteArray to a new ByteArray

    val bytes = bytesFrom(bytesFrom(0xfe, 0xed, 0xbe, 0xef))

    bytesFrom(bytes: Array<out Number>): ByteArray

    Converts an Array of Number to a ByteArray

    val bytes = bytesFrom(arrayOf(0xfe, 0xed, 0xbe, 0xef))

    bytesFrom(bytes: String): ByteArray

    Converts a String to a ByteArray

    val bytes = bytesFrom("feedbeef")

    bytesFrom(size: Number): ByteArray

    Converts a Number to a ByteArray

    val bytes = bytesFrom(16)

    bytesFrom(size: Char): ByteArray

    Converts a Char to a ByteArray

    val bytes = bytesFrom('a')

    bytesFrom(bytes: Any? = null): ByteArray

    Converts an Any? to an empty ByteArray

    val bytes = bytesFrom()
    val bytes = bytesFrom(null)
    val bytes = bytesFrom(fun() {  })
    val bytes = bytesFrom(true)

    Prerequisites

    See Also

    License

    MIT

    Install

    npm i @datkt/bytes-from

    DownloadsWeekly Downloads

    2

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    8.24 kB

    Total Files

    10

    Last publish

    Collaborators

    • vipyne
    • werle