Class

io.scalajs.nodejs.buffer

SlowBuffer

Related Doc: package buffer

Permalink

class SlowBuffer extends Buffer

Returns an un-pooled Buffer.

In order to avoid the garbage collection overhead of creating many individually allocated Buffer instances, by default allocations under 4KB are sliced from a single larger allocated object. This approach improves both performance and memory usage since v8 does not need to track and cleanup as many Persistent objects.

In the case where a developer may need to retain a small chunk of memory from a pool for an indeterminate amount of time, it may be appropriate to create an un-pooled Buffer instance using SlowBuffer then copy out the relevant bits.

Annotations
@RawJSType() @deprecated @native() @JSImport( "buffer" , "SlowBuffer" )
Deprecated

(Since version 6.0.0) Use Buffer.allocUnsafeSlow() instead.

See also

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

Linear Supertypes
Buffer, Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SlowBuffer
  2. Buffer
  3. Object
  4. Any
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SlowBuffer(size: Int)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply(index: Int): Int

    Permalink

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

    index

    the given index

    returns

    the value at the given index

    Definition Classes
    Buffer
    Annotations
    @JSBracketAccess()
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def compare(target: Buffer, targetStart: Int = js.native, targetEnd: Int = js.native, sourceStart: Int = js.native, sourceEnd: Int = js.native): Int

    Permalink

    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 to compare to

    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.

    Definition Classes
    Buffer
    Example:
    1. buf.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]])
  8. def copy(target: Buffer, targetStart: Int = js.native, sourceStart: Int = js.native, sourceEnd: Int = js.native): Int

    Permalink

    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.

    Definition Classes
    Buffer
    Example:
    1. buf.copy(target[, targetStart[, sourceStart[, sourceEnd]]])
  9. def entries(): Iterator[Array[Int]]

    Permalink

    Creates and returns an iterator of [index, byte] pairs from the Buffer contents.

    Creates and returns an iterator of [index, byte] pairs from the Buffer contents.

    returns

    an Iterator

    Definition Classes
    Buffer
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(otherBuffer: Buffer): Boolean

    Permalink

    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 to compare to

    returns

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

    Definition Classes
    Buffer
    Example:
    1. buf.equals(otherBuffer)

  12. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  13. def fill(value: |[|[Buffer, Int], String], offset: Int = js.native, end: Int = js.native, encoding: String = js.native): SlowBuffer.this.type

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.fill(value[, offset[, end]][, encoding])
  14. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  16. def hasOwnProperty(v: String): Boolean

    Permalink
    Definition Classes
    Object
  17. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  18. def includes(value: |[|[Buffer, Int], String], byteOffset: Int = js.native, encoding: String = js.native): Boolean

    Permalink

    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

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

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.indexOf(value[, byteOffset][, encoding])
  20. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  21. def isPrototypeOf(v: Object): Boolean

    Permalink
    Definition Classes
    Object
  22. def kMaxLength: Int

    Permalink

    The largest size allowed for a single Buffer instance.

    The largest size allowed for a single Buffer instance. On 32-bit architectures, this value is (230)-1 (~1GB). On 64-bit architectures, this value is (231)-1 (~2GB). Note that this is a property on the buffer module returned by require('buffer'), not on the Buffer global or a Buffer instance.

    returns

    the largest size allowed

    Definition Classes
    Buffer
  23. def keys(): Iterator[Int]

    Permalink

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

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

    returns

    an Iterator

    Definition Classes
    Buffer
    Example:
    1. buf.keys()

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

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.lastIndexOf(value[, byteOffset][, encoding])
  25. def length: Int

    Permalink

    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
    Example:
    1. buf.length

  26. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  29. def propertyIsEnumerable(v: String): Boolean

    Permalink
    Definition Classes
    Object
  30. def readDoubleBE(offset: Int, noAssert: Boolean = js.native): Double

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.readUIntLE(offset, byteLength[, noAssert])
  48. def slice(start: Int = js.native, end: Int = js.native): SlowBuffer.this.type

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.slice([start[, end]])
  49. def swap16(): SlowBuffer.this.type

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.swap16()

  50. def swap32(): SlowBuffer.this.type

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.swap32()

  51. def swap64(): SlowBuffer.this.type

    Permalink

    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

    Definition Classes
    Buffer
    Example:
    1. buf.swap64()

  52. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  53. def toJSON(): String

    Permalink

    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.

    Definition Classes
    Buffer
    Example:
    1. buf.toJSON()

  54. def toLocaleString(): String

    Permalink
    Definition Classes
    Object
  55. def toString(encoding: String = js.native, start: Int = js.native, end: Int = js.native): String

    Permalink

    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.

    Definition Classes
    Buffer
    Example:
    1. buf.toString([encoding[, start[, end]]])
  56. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  57. def transcode(source: Buffer, fromEnc: String, toEnc: String): Buffer

    Permalink

    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

    Definition Classes
    Buffer
  58. def update(index: Int, value: Int): Unit

    Permalink

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

    index

    the given index

    Definition Classes
    Buffer
    Annotations
    @JSBracketAccess()
  59. def valueOf(): Any

    Permalink
    Definition Classes
    Object
  60. def values(): Iterator[Int]

    Permalink

    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)

    Definition Classes
    Buffer
    Example:
    1. buf.values()

  61. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  62. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  63. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  64. def write(string: String, offset: Int = js.native, length: Int = js.native, encoding: String = js.native): Int

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

    Permalink

    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

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

Inherited from Buffer

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped