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

Instance Constructors

  1. new Buffer()
    Attributes
    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()
  10. def compare(target: Uint8Array): Int
  11. def compare(target: Uint8Array, targetStart: Int): Int
  12. def compare(target: Uint8Array, targetStart: Int, targetEnd: Int): Int
  13. def compare(target: Uint8Array, targetStart: Int, targetEnd: Int, sourceStart: Int): Int
  14. def compare(target: Uint8Array, targetStart: Int, targetEnd: Int, sourceStart: Int, sourceEnd: Int): 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

  15. def copy(target: Buffer): Int
  16. def copy(target: Buffer, targetStart: Int): Int
  17. def copy(target: Buffer, targetStart: Int, sourceStart: Int): Int
  18. def copy(target: Buffer, targetStart: Int, sourceStart: Int, sourceEnd: Int): 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

  19. 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

  20. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. 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

  22. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  23. def fill(value: String): Buffer.this.type
  24. def fill(value: String, encoding: String): Buffer.this.type
  25. def fill(value: String, offset: Int): Buffer.this.type
  26. def fill(value: String, offset: Int, encoding: String): Buffer.this.type
  27. def fill(value: String, offset: Int, end: Int): Buffer.this.type
  28. def fill(value: String, offset: Int, end: Int, encoding: String): Buffer.this.type
  29. def fill(value: Int): Buffer.this.type
  30. def fill(value: Int, offset: Int): Buffer.this.type
  31. def fill(value: Int, offset: Int, end: Int): Buffer.this.type
  32. def fill(value: Uint8Array): Buffer.this.type
  33. def fill(value: Uint8Array, offset: Int): Buffer.this.type
  34. def fill(value: Uint8Array, offset: Int, end: Int): Buffer.this.type
  35. def fill(value: Short): Unit
    Definition Classes
    TypedArray
  36. def fill(value: Short, start: Int): Unit
    Definition Classes
    TypedArray
  37. def fill(value: Short, start: Int, end: Int): Unit
    Definition Classes
    TypedArray
  38. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  39. def get(index: Int): Short
    Definition Classes
    TypedArray
    Annotations
    @JSBracketAccess()
  40. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  41. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  42. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  43. def includes(value: String): Boolean
  44. def includes(value: String, encoding: String): Boolean
  45. def includes(value: String, byteOffset: Int): Boolean
  46. def includes(value: String, byteOffset: Int, encoding: String): Boolean
  47. def includes(value: Int): Boolean
  48. def includes(value: Int, byteOffset: Int): Boolean
  49. def includes(value: Buffer): Boolean
  50. def includes(value: Buffer, byteOffset: Int): Boolean
  51. def indexOf(value: String): Int
  52. def indexOf(value: String, encoding: String): Int
  53. def indexOf(value: String, byteOffset: Int): Int
  54. def indexOf(value: String, byteOffset: Int, encoding: String): Int
  55. def indexOf(value: Int): Int
  56. def indexOf(value: Int, byteOffset: Int): Int
  57. def indexOf(value: Buffer): Int
  58. def indexOf(value: Buffer, byteOffset: Int): Int
  59. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  60. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  61. def jsIterator(): Iterator[Short]
    Definition Classes
    TypedArray → Iterable
    Annotations
    @JSName(scala.scalajs.js.Symbol.iterator)
  62. 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()

  63. def lastIndexOf(value: String): Int
  64. def lastIndexOf(value: String, encoding: String): Int
  65. def lastIndexOf(value: String, byteOffset: Int): Int
  66. def lastIndexOf(value: String, byteOffset: Int, encoding: String): Int
  67. def lastIndexOf(value: Int): Int
  68. def lastIndexOf(value: Int, byteOffset: Int): Int
  69. def lastIndexOf(value: Buffer): Int
  70. def lastIndexOf(value: Buffer, byteOffset: Int): Int
  71. 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

  72. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  73. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  74. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  75. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  76. def readBigInt64BE(): BigInt
  77. def readBigInt64BE(offset: Int): BigInt
  78. def readBigUInt64LE(): BigInt
  79. def readBigUInt64LE(offset: Int): BigInt
  80. def readDoubleBE(offset: Int): Double
  81. def readDoubleBE(offset: Int, noAssert: Boolean): 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])
  82. def readDoubleLE(offset: Int): Double
  83. def readDoubleLE(offset: Int, noAssert: Boolean): 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])
  84. def readFloatBE(offset: Int): Double
  85. def readFloatBE(offset: Int, noAssert: Boolean): 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])
  86. def readFloatLE(offset: Int): Double
  87. def readFloatLE(offset: Int, noAssert: Boolean): 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])
  88. def readInt16BE(offset: Int): Int
  89. def readInt16BE(offset: Int, noAssert: Boolean): 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])
  90. def readInt16LE(offset: Int): Int
  91. def readInt16LE(offset: Int, noAssert: Boolean): 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])
  92. def readInt32BE(offset: Int): Int
  93. def readInt32BE(offset: Int, noAssert: Boolean): 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])
  94. def readInt32LE(offset: Int): Int
  95. def readInt32LE(offset: Int, noAssert: Boolean): 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])
  96. def readInt8(offset: Int): Int
  97. def readInt8(offset: Int, noAssert: Boolean): 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])
  98. def readIntBE(offset: Int, byteLength: Int): Int
  99. def readIntBE(offset: Int, byteLength: Int, noAssert: Boolean): 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])
  100. def readIntLE(offset: Int, byteLength: Int): Int
  101. def readIntLE(offset: Int, byteLength: Int, noAssert: Boolean): 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])
  102. def readUInt16BE(offset: Int): Int
  103. def readUInt16BE(offset: Int, noAssert: Boolean): 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])
  104. def readUInt16LE(offset: Int): Int
  105. def readUInt16LE(offset: Int, noAssert: Boolean): 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])
  106. def readUInt32BE(offset: Int): Int
  107. def readUInt32BE(offset: Int, noAssert: Boolean): 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])
  108. def readUInt32LE(offset: Int): Int
  109. def readUInt32LE(offset: Int, noAssert: Boolean): 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])
  110. def readUInt8(offset: Int): Int
  111. def readUInt8(offset: Int, noAssert: Boolean): 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])
  112. def readUIntBE(offset: Int, byteLength: Int): Int
  113. def readUIntBE(offset: Int, byteLength: Int, noAssert: Boolean): 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])
  114. def readUIntLE(offset: Int, byteLength: Int): Int
  115. def readUIntLE(offset: Int, byteLength: Int, noAssert: Boolean): 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])
  116. def set(array: Array[_ <: Short], offset: Int): Unit
    Definition Classes
    TypedArray
  117. def set(array: Array[_ <: Short]): Unit
    Definition Classes
    TypedArray
  118. def set(typedArray: Uint8Array, offset: Int): Unit
    Definition Classes
    TypedArray
  119. def set(typedArray: Uint8Array): Unit
    Definition Classes
    TypedArray
  120. def set(index: Int, value: Short): Unit
    Definition Classes
    TypedArray
    Annotations
    @JSBracketAccess()
  121. def slice(): Buffer.this.type
  122. def slice(start: Int): Buffer.this.type
  123. def slice(start: Int, end: Int): 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]])
  124. def subarray(begin: Int, end: Int): Uint8Array
    Definition Classes
    TypedArray
  125. 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()

  126. 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()

  127. 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()

  128. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  129. 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()

  130. def toLocaleString(): String
    Definition Classes
    Object
  131. def toString(encoding: String): String
  132. def toString(encoding: String, start: Int): String
  133. def toString(encoding: String, start: Int, end: Int): 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]]])
  134. def toString(): String
    Definition Classes
    AnyRef → Any
  135. 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

  136. 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()

  137. def update(index: Int, value: Short): Unit
    Definition Classes
    TypedArray
    Annotations
    @JSBracketAccess()
  138. def valueOf(): Any
    Definition Classes
    Object
  139. 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()

  140. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  141. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  142. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  143. def write(string: String): Int
  144. def write(string: String, offset: Int): Int
  145. def write(string: String, offset: Int, encoding: String): Int
  146. def write(string: String, offset: Int, length: Int): Int
  147. def write(string: String, offset: Int, length: Int, encoding: String): 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])
  148. def writeBigInt64BE(value: BigInt): Int
  149. def writeBigInt64BE(value: BigInt, offset: Int): Int
  150. def writeBigInt64LE(value: BigInt): Int
  151. def writeBigInt64LE(value: BigInt, offset: Int): Int
  152. def writeDoubleBE(value: Double, offset: Int): Int
  153. def writeDoubleBE(value: Double, offset: Int, noAssert: Boolean): 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])
  154. def writeDoubleLE(value: Double, offset: Int): Int
  155. def writeDoubleLE(value: Double, offset: Int, noAssert: Boolean): 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])
  156. def writeFloatBE(value: Float, offset: Int): Int
  157. def writeFloatBE(value: Float, offset: Int, noAssert: Boolean): 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])
  158. def writeFloatLE(value: Float, offset: Int): Int
  159. def writeFloatLE(value: Float, offset: Int, noAssert: Boolean): 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])
  160. def writeInt16BE(value: Int, offset: Int): Int
  161. def writeInt16BE(value: Int, offset: Int, noAssert: Boolean): 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])
  162. def writeInt16LE(value: Int, offset: Int): Int
  163. def writeInt16LE(value: Int, offset: Int, noAssert: Boolean): 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])
  164. def writeInt32BE(value: Int, offset: Int): Int
  165. def writeInt32BE(value: Int, offset: Int, noAssert: Boolean): 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])
  166. def writeInt32LE(value: Int, offset: Int): Int
  167. def writeInt32LE(value: Int, offset: Int, noAssert: Boolean): 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])
  168. def writeInt8(value: Int, offset: Int): Int
  169. def writeInt8(value: Int, offset: Int, noAssert: Boolean): 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])
  170. def writeIntBE(value: Int, offset: Int, byteLength: Int): Int
  171. def writeIntBE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean): 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])
  172. def writeIntLE(value: Int, offset: Int, byteLength: Int): Int
  173. def writeIntLE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean): 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])
  174. def writeUInt16BE(value: Int, offset: Int): Int
  175. def writeUInt16BE(value: Int, offset: Int, noAssert: Boolean): 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])
  176. def writeUInt16LE(value: Int, offset: Int): Int
  177. def writeUInt16LE(value: Int, offset: Int, noAssert: Boolean): 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])
  178. def writeUInt32BE(value: Int, offset: Int): Int
  179. def writeUInt32BE(value: Int, offset: Int, noAssert: Boolean): 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])
  180. def writeUInt32LE(value: Int, offset: Int): Int
  181. def writeUInt32LE(value: Int, offset: Int, noAssert: Boolean): 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])
  182. def writeUInt8(value: Int, offset: Int): Int
  183. def writeUInt8(value: Int, offset: Int, noAssert: Boolean): 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])
  184. def writeUIntBE(value: Int, offset: Int, byteLength: Int): Int
  185. def writeUIntBE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean): 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])
  186. def writeUIntLE(value: Int, offset: Int, byteLength: Int): Int
  187. def writeUIntLE(value: Int, offset: Int, byteLength: Int, noAssert: Boolean): 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])

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