Packages

class Buffer extends Uint8Array

Annotations
@JSType() @native() @JSImport("buffer", "Buffer")
See also

https://nodejs.org/api/buffer.html

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Buffer
  2. Uint8Array
  3. TypedArray
  4. Iterable
  5. ArrayBufferView
  6. Object
  7. Any
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply(index: Int): Short

    The index operator [index] can be used to get and set the octet at position index in buf.

    The index operator [index] can be used to get and set the octet at position index in buf. The values refer to individual bytes, so the legal value range is between 0x00 and 0xFF (hex) or 0 and 255 (decimal).

    This operator is inherited from Uint8Array, so its behavior on out-of-bounds access is the same as Uint8Array - that is, getting returns undefined and setting does nothing.

    Note) In Scala.js, getting on out-of-bounds access will throw, since undefined can not be casted to Short.

    index

    the given index

    returns

    the value at the given index

    Definition Classes
    Buffer → TypedArray
    Annotations
    @JSBracketAccess()
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. val buffer: ArrayBuffer
    Definition Classes
    ArrayBufferView
  7. val byteLength: Int
    Definition Classes
    ArrayBufferView
  8. val byteOffset: Int
    Definition Classes
    ArrayBufferView
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  10. def compare(target: Uint8Array, targetStart: Int = js.native, targetEnd: Int = js.native, sourceStart: Int = js.native, sourceEnd: Int = js.native): Int

    Compares buf with target and returns a number indicating whether buf comes before, after, or is the same as target in sort order.

    Compares buf with target and returns a number indicating whether buf comes before, after, or is the same as target in sort order. Comparison is based on the actual sequence of bytes in each Buffer.

    target

    A Buffer with which to compare buf

    targetStart

    The offset within target at which to begin comparison. Default: 0

    targetEnd

    The offset with target at which to end comparison (not inclusive). Ignored when targetStart is undefined. Default: target.length

    sourceStart

    The offset within buf at which to begin comparison. Ignored when targetStart is undefined. Default: 0

    sourceEnd

    The offset within buf at which to end comparison (not inclusive). Ignored when targetStart is undefined. Default: buf.length

    returns

    0 is returned if target is the same as buf 1 is returned if target should come before buf when sorted. -1 is returned if target should come after buf when sorted.

    See also

    https://nodejs.org/api/buffer.html#buffer_buf_compare_target_targetstart_targetend_sourcestart_sourceend

  11. def copy(target: Buffer, targetStart: Int = js.native, sourceStart: Int = js.native, sourceEnd: Int = js.native): Int

    Copies data from a region of buf to a region in target even if the target memory region overlaps with buf.

    Copies data from a region of buf to a region in target even if the target memory region overlaps with buf.

    target

    A Buffer to copy into.

    targetStart

    The offset within target at which to begin copying to. Default: 0

    sourceStart

    The offset within buf at which to begin copying from. Ignored when targetStart is undefined. Default: 0

    sourceEnd

    The offset within buf at which to stop copying (not inclusive). Ignored when sourceStart is undefined. Default: buf.length

    returns

    The number of bytes copied.

    See also

    https://nodejs.org/api/buffer.html#buffer_buf_copy_target_targetstart_sourcestart_sourceend

  12. def entries(): Iterator[Array[Int]]

    Creates and returns an Iterator of [index, byte] pairs from the contents of buf.

    Creates and returns an Iterator of [index, byte] pairs from the contents of buf.

    See also

    https://nodejs.org/api/buffer.html#buffer_buf_entries

  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(otherBuffer: Uint8Array): Boolean

    Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise.

    Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise.

    otherBuffer

    A Buffer or Uint8Array with which to compare buf.

    returns

    true if both buf and otherBuffer have exactly the same bytes, false otherwise.

    See also

    https://nodejs.org/api/buffer.html#buffer_buf_equals_otherbuffer

  15. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  16. def fill(value: |[|[Uint8Array, Int], String], offset: Int = js.native, end: Int = js.native, encoding: String = js.native): Buffer.this.type

    Fills buf with the specified value.

    Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled. This is meant to be a small simplification to allow the creation and filling of a Buffer to be done on a single line.

    value

    The value to fill buf with

    offset

    Where to start filling buf. Default: 0

    end

    Where to stop filling buf (not inclusive). Default: buf.length

    encoding

    If value is a string, this is its encoding. Default: 'utf8'

    returns

    A reference to buf

    See also

    https://nodejs.org/api/buffer.html#buffer_buf_fill_value_offset_end_encoding

  17. def get(index: Int): Short
    Definition Classes
    TypedArray
    Annotations
    @JSBracketAccess()
  18. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  19. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  20. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  21. def includes(value: |[|[Buffer, Int], String], byteOffset: Int = js.native, encoding: String = js.native): Boolean

    Equivalent to buf.indexOf() !== -1.

    Equivalent to buf.indexOf() !== -1.

    value

    What to search for

    byteOffset

    Where to begin searching in buf. Default: 0

    encoding

    If value is a string, this is its encoding. Default: 'utf8'

    returns

    true if value was found in buf, false otherwise

    Example:
    1. buf.includes(value[, byteOffset][, encoding])
  22. def indexOf(value: |[|[Buffer, Int], String], byteOffset: Int = js.native, encoding: String = js.native): Int

    Returns the index of the first occurrence of value in buf or -1 if buf does not contain value

    Returns the index of the first occurrence of value in buf or -1 if buf does not contain value

    value

    What to search for

    byteOffset

    Where to begin searching in buf. Default: 0

    encoding

    If value is a string, this is its encoding. Default: 'utf8'

    returns

    The index of the first occurrence of value in buf or -1 if buf does not contain value

    Example:
    1. buf.indexOf(value[, byteOffset][, encoding])
  23. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  24. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  25. def jsIterator(): Iterator[Short]
    Definition Classes
    TypedArray → Iterable
    Annotations
    @JSName(scala.scalajs.js.Symbol.iterator)
  26. def keys(): Iterator[Int]

    Creates and returns an iterator of buf keys (indices).

    Creates and returns an iterator of buf keys (indices).

    returns

    an Iterator

    Example:
    1. buf.keys()

  27. def lastIndexOf(value: |[|[Buffer, Int], String], byteOffset: Int = js.native, encoding: String = js.native): Int

    Identical to buf.indexOf(), except buf is searched from back to front instead of front to back.

    Identical to buf.indexOf(), except buf is searched from back to front instead of front to back.

    value

    What to search for

    byteOffset

    Where to begin searching in buf. Default: 0

    encoding

    If value is a string, this is its encoding. Default: 'utf8'

    returns

    The index of the last occurrence of value in buf or -1 if buf does not contain value

    Example:
    1. buf.lastIndexOf(value[, byteOffset][, encoding])
  28. val length: Int

    Returns the amount of memory allocated for buf in bytes.

    Returns the amount of memory allocated for buf in bytes. Note that this does not necessarily reflect the amount of "usable" data within buf.

    returns

    the amount of memory allocated for buf in bytes.

    Definition Classes
    Buffer → TypedArray
    Example:
    1. buf.length

  29. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  30. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  31. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  32. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  33. def readDoubleBE(offset: Int, noAssert: Boolean = js.native): Double

    Reads a 64-bit double from buf at the specified offset with specified endian format (readDoubleBE() returns big endian, readDoubleLE() returns little endian).

    Reads a 64-bit double from buf at the specified offset with specified endian format (readDoubleBE() returns big endian, readDoubleLE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 8

    noAssert

    Skip offset validation? Default: false

    returns

    a Double value

    Example:
    1. buf.readDoubleBE(offset[, noAssert])
  34. def readDoubleLE(offset: Int, noAssert: Boolean = js.native): Double

    Reads a 64-bit double from buf at the specified offset with specified endian format (readDoubleBE() returns big endian, readDoubleLE() returns little endian).

    Reads a 64-bit double from buf at the specified offset with specified endian format (readDoubleBE() returns big endian, readDoubleLE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 8

    noAssert

    Skip offset validation? Default: false

    returns

    a Double value

    Example:
    1. buf.readDoubleBE(offset[, noAssert])
  35. def readFloatBE(offset: Int, noAssert: Boolean = js.native): Double

    Reads a 32-bit float from buf at the specified offset with specified endian format (readFloatBE() returns big endian, readFloatLE() returns little endian).

    Reads a 32-bit float from buf at the specified offset with specified endian format (readFloatBE() returns big endian, readFloatLE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip offset validation? Default: false

    returns

    a Double value

    Example:
    1. buf.readFloatBE(offset[, noAssert])
  36. def readFloatLE(offset: Int, noAssert: Boolean = js.native): Double

    Reads a 32-bit float from buf at the specified offset with specified endian format (readFloatBE() returns big endian, readFloatLE() returns little endian).

    Reads a 32-bit float from buf at the specified offset with specified endian format (readFloatBE() returns big endian, readFloatLE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip offset validation? Default: false

    returns

    a Double value

    Example:
    1. buf.readFloatLE(offset[, noAssert])
  37. def readInt16BE(offset: Int, noAssert: Boolean = js.native): Int

    Reads a signed 16-bit integer from buf at the specified offset with the specified endian format (readInt16BE() returns big endian, readInt16LE() returns little endian).

    Reads a signed 16-bit integer from buf at the specified offset with the specified endian format (readInt16BE() returns big endian, readInt16LE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    Integers read from a Buffer are interpreted as two's complement signed values.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 2

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readInt16BE(offset[, noAssert])
  38. def readInt16LE(offset: Int, noAssert: Boolean = js.native): Int

    Reads a signed 16-bit integer from buf at the specified offset with the specified endian format (readInt16BE() returns big endian, readInt16LE() returns little endian).

    Reads a signed 16-bit integer from buf at the specified offset with the specified endian format (readInt16BE() returns big endian, readInt16LE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    Integers read from a Buffer are interpreted as two's complement signed values.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 2

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readInt16LE(offset[, noAssert])
  39. def readInt32BE(offset: Int, noAssert: Boolean = js.native): Int

    Reads a signed 32-bit integer from buf at the specified offset with the specified endian format (readInt32BE() returns big endian, readInt32LE() returns little endian).

    Reads a signed 32-bit integer from buf at the specified offset with the specified endian format (readInt32BE() returns big endian, readInt32LE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    Integers read from a Buffer are interpreted as two's complement signed values.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readInt32BE(offset[, noAssert])
  40. def readInt32LE(offset: Int, noAssert: Boolean = js.native): Int

    Reads a signed 32-bit integer from buf at the specified offset with the specified endian format (readInt32BE() returns big endian, readInt32LE() returns little endian).

    Reads a signed 32-bit integer from buf at the specified offset with the specified endian format (readInt32BE() returns big endian, readInt32LE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    Integers read from a Buffer are interpreted as two's complement signed values.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readInt32LE(offset[, noAssert])
  41. def readInt8(offset: Int, noAssert: Boolean = js.native): Int

    Reads a signed 8-bit integer from buf at the specified offset.

    Reads a signed 8-bit integer from buf at the specified offset.

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    Integers read from a Buffer are interpreted as two's complement signed values.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 1

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readInt8(offset[, noAssert])
  42. def readIntBE(offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as a two's complement signed value.

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as a two's complement signed value. Supports up to 48 bits of accuracy.

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to read. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip offset and byteLength validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readIntBE(offset, byteLength[, noAssert])
  43. def readIntLE(offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as a two's complement signed value.

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as a two's complement signed value. Supports up to 48 bits of accuracy.

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to read. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip offset and byteLength validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readIntLE(offset, byteLength[, noAssert])
  44. def readUInt16BE(offset: Int, noAssert: Boolean = js.native): Int

    Reads an unsigned 16-bit integer from buf at the specified offset with specified endian format (readUInt16BE() returns big endian, readUInt16LE() returns little endian).

    Reads an unsigned 16-bit integer from buf at the specified offset with specified endian format (readUInt16BE() returns big endian, readUInt16LE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 2

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readUInt16BE(offset[, noAssert])
  45. def readUInt16LE(offset: Int, noAssert: Boolean = js.native): Int

    Reads an unsigned 16-bit integer from buf at the specified offset with specified endian format (readUInt16BE() returns big endian, readUInt16LE() returns little endian).

    Reads an unsigned 16-bit integer from buf at the specified offset with specified endian format (readUInt16BE() returns big endian, readUInt16LE() returns little endian).

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 2

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readUInt16LE(offset[, noAssert])
  46. def readUInt32BE(offset: Int, noAssert: Boolean = js.native): Int

    Reads an unsigned 32-bit integer from buf at the specified offset with specified endian format (readUInt32BE() returns big endian, readUInt32LE() returns little endian).

    Reads an unsigned 32-bit integer from buf at the specified offset with specified endian format (readUInt32BE() returns big endian, readUInt32LE() returns little endian). * Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readUInt32BE(offset[, noAssert])
  47. def readUInt32LE(offset: Int, noAssert: Boolean = js.native): Int

    Reads an unsigned 32-bit integer from buf at the specified offset with specified endian format (readUInt32BE() returns big endian, readUInt32LE() returns little endian).

    Reads an unsigned 32-bit integer from buf at the specified offset with specified endian format (readUInt32BE() returns big endian, readUInt32LE() returns little endian). * Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readUInt32LE(offset[, noAssert])
  48. def readUInt8(offset: Int, noAssert: Boolean = js.native): Int

    Reads an unsigned 8-bit integer from buf at the specified offset.

    Reads an unsigned 8-bit integer from buf at the specified offset. Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - 1

    noAssert

    Skip offset validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readUInt8(offset[, noAssert])
  49. def readUIntBE(offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned integer.

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned integer. Supports up to 48 bits of accuracy.

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to read. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip offset and byteLength validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readUIntBE(offset, byteLength[, noAssert])
  50. def readUIntLE(offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned integer.

    Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned integer. Supports up to 48 bits of accuracy.

    Setting noAssert to true allows offset to be beyond the end of buf, but the result should be considered undefined behavior.

    offset

    Where to start reading. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to read. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip offset and byteLength validation? Default: false

    returns

    the integer value

    Example:
    1. buf.readUIntLE(offset, byteLength[, noAssert])
  51. def set(array: Array[_ <: Short], offset: Int): Unit
    Definition Classes
    TypedArray
  52. def set(array: Array[_ <: Short]): Unit
    Definition Classes
    TypedArray
  53. def set(typedArray: Uint8Array, offset: Int): Unit
    Definition Classes
    TypedArray
  54. def set(typedArray: Uint8Array): Unit
    Definition Classes
    TypedArray
  55. def set(index: Int, value: Short): Unit
    Definition Classes
    TypedArray
    Annotations
    @JSBracketAccess()
  56. def slice(start: Int = js.native, end: Int = js.native): Buffer.this.type

    Returns a new Buffer that references the same memory as the original, but offset and cropped by the start and end indices.

    Returns a new Buffer that references the same memory as the original, but offset and cropped by the start and end indices.

    Note that modifying the new Buffer slice will modify the memory in the original Buffer because the allocated memory of the two objects overlap.

    start

    Where the new Buffer will start. Default: 0

    end

    Where the new Buffer will end (not inclusive). Default: buf.length

    returns

    a Buffer

    Example:
    1. buf.slice([start[, end]])
  57. def subarray(begin: Int, end: Int): Uint8Array
    Definition Classes
    TypedArray
  58. def swap16(): Buffer.this.type

    Interprets buf as an array of unsigned 16-bit integers and swaps the byte-order in-place.

    Interprets buf as an array of unsigned 16-bit integers and swaps the byte-order in-place. Throws a RangeError if buf.length is not a multiple of 2.

    returns

    A reference to buf

    Example:
    1. buf.swap16()

  59. def swap32(): Buffer.this.type

    Interprets buf as an array of unsigned 32-bit integers and swaps the byte-order in-place.

    Interprets buf as an array of unsigned 32-bit integers and swaps the byte-order in-place. Throws a RangeError if buf.length is not a multiple of 4.

    returns

    A reference to buf

    Example:
    1. buf.swap32()

  60. def swap64(): Buffer.this.type

    Interprets buf as an array of unsigned 64-bit numbers and swaps the byte-order in-place.

    Interprets buf as an array of unsigned 64-bit numbers and swaps the byte-order in-place. Throws a RangeError if buf.length is not a multiple of 8.

    returns

    A reference to buf

    Example:
    1. buf.swap64()

  61. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  62. def toJSON(): String

    Returns a JSON representation of buf.

    Returns a JSON representation of buf. JSON.stringify() implicitly calls this function when stringifying a Buffer instance.

    returns

    a JSON representation of buf.

    Example:
    1. buf.toJSON()

  63. def toLocaleString(): String
    Definition Classes
    Object
  64. def toString(encoding: String, start: Int = js.native, end: Int = js.native): String

    Decodes buf to a string according to the specified character encoding in encoding.

    Decodes buf to a string according to the specified character encoding in encoding. start and end may be passed to decode only a subset of buf.

    encoding

    The character encoding to decode to. Default: 'utf8'

    start

    The byte offset to start decoding at. Default: 0

    end

    The byte offset to stop decoding at (not inclusive). Default: buf.length

    returns

    a string according to the specified character encoding in encoding.

    Example:
    1. buf.toString([encoding[, start[, end]]])
  65. def toString(): String
    Definition Classes
    AnyRef → Any
  66. def transcode(source: Buffer, fromEnc: String, toEnc: String): Buffer

    Re-encodes the given Buffer instance from one character encoding to another.

    Re-encodes the given Buffer instance from one character encoding to another. Returns a new Buffer instance. Throws if the fromEnc or toEnc specify invalid character encodings or if conversion from fromEnc to toEnc is not permitted.

    source

    A Buffer instance

    fromEnc

    The current encoding

    toEnc

    To target encoding

    returns

    a new Buffer

  67. def update(index: Int, value: Int): Unit

    index

    the given index

    value

    the value to replace the existing value at the given index

    Annotations
    @JSBracketAccess()
    See also

    apply()

  68. def update(index: Int, value: Short): Unit
    Definition Classes
    TypedArray
    Annotations
    @JSBracketAccess()
  69. def valueOf(): Any
    Definition Classes
    Object
  70. def values(): Iterator[Int]

    Creates and returns an iterator for buf values (bytes).

    Creates and returns an iterator for buf values (bytes). This function is called automatically when a Buffer is used in a for..of statement.

    returns

    an iterator for buf values (bytes)

    Example:
    1. buf.values()

  71. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  72. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  73. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  74. def write(string: String, offset: Int = js.native, length: Int = js.native, encoding: String = js.native): Int

    Writes string to buf at offset according to the character encoding in encoding.

    Writes string to buf at offset according to the character encoding in encoding. The length parameter is the number of bytes to write. If buf did not contain enough space to fit the entire string, only a partial amount of string will be written. However, partially encoded characters will not be written.

    string

    String to be written to buf

    offset

    Where to start writing string. Default: 0

    length

    How many bytes to write. Default: buf.length - offset

    encoding

    The character encoding of string. Default: 'utf8'

    returns

    the Number of bytes written

    Example:
    1. buf.write(string[, offset[, length]][, encoding])
  75. def writeDoubleBE(value: Double, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeDoubleBE() writes big endian, writeDoubleLE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeDoubleBE() writes big endian, writeDoubleLE() writes little endian). value should be a valid 64-bit double. Behavior is undefined when value is anything other than a 64-bit double.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 8

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeDoubleBE(value, offset[, noAssert])
  76. def writeDoubleLE(value: Double, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeDoubleBE() writes big endian, writeDoubleLE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeDoubleBE() writes big endian, writeDoubleLE() writes little endian). value should be a valid 64-bit double. Behavior is undefined when value is anything other than a 64-bit double.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 8

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeDoubleLE(value, offset[, noAssert])
  77. def writeFloatBE(value: Float, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeFloatBE() writes big endian, writeFloatLE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeFloatBE() writes big endian, writeFloatLE() writes little endian). value should be a valid 32-bit float. Behavior is undefined when value is anything other than a 32-bit float.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeFloatBE(value, offset[, noAssert])
  78. def writeFloatLE(value: Float, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeFloatBE() writes big endian, writeFloatLE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeFloatBE() writes big endian, writeFloatLE() writes little endian). value should be a valid 32-bit float. Behavior is undefined when value is anything other than a 32-bit float.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeFloatLE(value, offset[, noAssert])
  79. def writeInt16BE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeInt16BE() writes big endian, writeInt16LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeInt16BE() writes big endian, writeInt16LE() writes little endian). value should be a valid signed 16-bit integer. Behavior is undefined when value is anything other than a signed 16-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value is interpreted and written as a two's complement signed integer.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 2

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeInt16BE(value, offset[, noAssert])
  80. def writeInt16LE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeInt16BE() writes big endian, writeInt16LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeInt16BE() writes big endian, writeInt16LE() writes little endian). value should be a valid signed 16-bit integer. Behavior is undefined when value is anything other than a signed 16-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value is interpreted and written as a two's complement signed integer.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 2

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeInt16BE(value, offset[, noAssert])
  81. def writeInt32BE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeInt32BE() writes big endian, writeInt32LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeInt32BE() writes big endian, writeInt32LE() writes little endian). value should be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value is interpreted and written as a two's complement signed integer.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeInt32BE(value, offset[, noAssert])
  82. def writeInt32LE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeInt32BE() writes big endian, writeInt32LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeInt32BE() writes big endian, writeInt32LE() writes little endian). value should be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value is interpreted and written as a two's complement signed integer.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeInt32BE(value, offset[, noAssert])
  83. def writeInt8(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset.

    Writes value to buf at the specified offset. value should be a valid signed 8-bit integer. Behavior is undefined when value is anything other than a signed 8-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value is interpreted and written as a two's complement signed integer.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 1

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeInt8(value, offset[, noAssert])
  84. def writeIntBE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Writes byteLength bytes of value to buf at the specified offset.

    Writes byteLength bytes of value to buf at the specified offset. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than a signed integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to write. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip value, offset, and byteLength validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeIntBE(value, offset, byteLength[, noAssert])
  85. def writeIntLE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Writes byteLength bytes of value to buf at the specified offset.

    Writes byteLength bytes of value to buf at the specified offset. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than a signed integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to write. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip value, offset, and byteLength validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeIntLE(value, offset, byteLength[, noAssert])
  86. def writeUInt16BE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeUInt16BE() writes big endian, writeUInt16LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeUInt16BE() writes big endian, writeUInt16LE() writes little endian). value should be a valid unsigned 16-bit integer. Behavior is undefined when value is anything other than an unsigned 16-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Number to be written to buf

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeUInt16BE(value, offset[, noAssert])
  87. def writeUInt16LE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeUInt16BE() writes big endian, writeUInt16LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeUInt16BE() writes big endian, writeUInt16LE() writes little endian). value should be a valid unsigned 16-bit integer. Behavior is undefined when value is anything other than an unsigned 16-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Number to be written to buf

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeUInt16BE(value, offset[, noAssert])
  88. def writeUInt32BE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeUInt32BE() writes big endian, writeUInt32LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeUInt32BE() writes big endian, writeUInt32LE() writes little endian). value should be a valid unsigned 32-bit integer. Behavior is undefined when value is anything other than an unsigned 32-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeUInt32BE(value, offset[, noAssert])
  89. def writeUInt32LE(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset with specified endian format (writeUInt32BE() writes big endian, writeUInt32LE() writes little endian).

    Writes value to buf at the specified offset with specified endian format (writeUInt32BE() writes big endian, writeUInt32LE() writes little endian). value should be a valid unsigned 32-bit integer. Behavior is undefined when value is anything other than an unsigned 32-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 4

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeUInt32LE(value, offset[, noAssert])
  90. def writeUInt8(value: Int, offset: Int, noAssert: Boolean = js.native): Int

    Writes value to buf at the specified offset.

    Writes value to buf at the specified offset. value should be a valid unsigned 8-bit integer. Behavior is undefined when value is anything other than an unsigned 8-bit integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - 1

    noAssert

    Skip value and offset validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeUInt8(value, offset[, noAssert])
  91. def writeUIntBE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Writes byteLength bytes of value to buf at the specified offset.

    Writes byteLength bytes of value to buf at the specified offset. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than an unsigned integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to write. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip value, offset, and byteLength validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeUIntBE(value, offset, byteLength[, noAssert])
  92. def writeUIntLE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean = js.native): Int

    Writes byteLength bytes of value to buf at the specified offset.

    Writes byteLength bytes of value to buf at the specified offset. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than an unsigned integer.

    Setting noAssert to true allows the encoded form of value to extend beyond the end of buf, but the result should be considered undefined behavior.

    value

    Number to be written to buf

    offset

    Where to start writing. Must satisfy: 0 <= offset <= buf.length - byteLength

    byteLength

    How many bytes to write. Must satisfy: 0 < byteLength <= 6

    noAssert

    Skip value, offset, and byteLength validation? Default: false

    returns

    the offset plus the number of bytes written

    Example:
    1. buf.writeUIntLE(value, offset, byteLength[, noAssert])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from Uint8Array

Inherited from TypedArray[Short, Uint8Array]

Inherited from Iterable[Short]

Inherited from ArrayBufferView

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped