class Buffer extends Uint8Array
- Annotations
- @JSType() @native() @JSImport("buffer", "Buffer")
- See also
- Alphabetic
- By Inheritance
- Buffer
- Uint8Array
- TypedArray
- Iterable
- ArrayBufferView
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Buffer()
- Attributes
- protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(index: Int): Short
The index operator
[index]
can be used to get and set the octet at positionindex
inbuf
.The index operator
[index]
can be used to get and set the octet at positionindex
inbuf
. The values refer to individual bytes, so the legal value range is between0x00
and0xFF
(hex) or0
and255
(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 toShort
.- index
the given index
- returns
the value at the given index
- Definition Classes
- Buffer → TypedArray
- Annotations
- @JSBracketAccess()
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- val buffer: ArrayBuffer
- Definition Classes
- ArrayBufferView
- val byteLength: Int
- Definition Classes
- ArrayBufferView
- val byteOffset: Int
- Definition Classes
- ArrayBufferView
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def compare(target: Uint8Array): Int
- def compare(target: Uint8Array, targetStart: Int): Int
- def compare(target: Uint8Array, targetStart: Int, targetEnd: Int): Int
- def compare(target: Uint8Array, targetStart: Int, targetEnd: Int, sourceStart: Int): Int
- def compare(target: Uint8Array, targetStart: Int, targetEnd: Int, sourceStart: Int, sourceEnd: Int): Int
Compares
buf
withtarget
and returns a number indicating whetherbuf
comes before, after, or is the same astarget
in sort order.Compares
buf
withtarget
and returns a number indicating whetherbuf
comes before, after, or is the same astarget
in sort order. Comparison is based on the actual sequence of bytes in eachBuffer
.- 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.
- def copy(target: Buffer): Int
- def copy(target: Buffer, targetStart: Int): Int
- def copy(target: Buffer, targetStart: Int, sourceStart: Int): Int
- def copy(target: Buffer, targetStart: Int, sourceStart: Int, sourceEnd: Int): Int
Copies data from a region of
buf
to a region intarget
even if thetarget
memory region overlaps withbuf
.Copies data from a region of
buf
to a region intarget
even if thetarget
memory region overlaps withbuf
.- 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.
- def entries(): Iterator[Array[Int]]
Creates and returns an Iterator of
[index, byte]
pairs from the contents ofbuf
.Creates and returns an Iterator of
[index, byte]
pairs from the contents ofbuf
. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- 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
orUint8Array
with which to comparebuf
.- returns
true if both buf and otherBuffer have exactly the same bytes, false otherwise.
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def fill(value: String): Buffer.this.type
- def fill(value: String, encoding: String): Buffer.this.type
- def fill(value: String, offset: Int): Buffer.this.type
- def fill(value: String, offset: Int, encoding: String): Buffer.this.type
- def fill(value: String, offset: Int, end: Int): Buffer.this.type
- def fill(value: String, offset: Int, end: Int, encoding: String): Buffer.this.type
- def fill(value: Int): Buffer.this.type
- def fill(value: Int, offset: Int): Buffer.this.type
- def fill(value: Int, offset: Int, end: Int): Buffer.this.type
- def fill(value: Uint8Array): Buffer.this.type
- def fill(value: Uint8Array, offset: Int): Buffer.this.type
- def fill(value: Uint8Array, offset: Int, end: Int): Buffer.this.type
- def fill(value: Short): Unit
- Definition Classes
- TypedArray
- def fill(value: Short, start: Int): Unit
- Definition Classes
- TypedArray
- def fill(value: Short, start: Int, end: Int): Unit
- Definition Classes
- TypedArray
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def get(index: Int): Short
- Definition Classes
- TypedArray
- Annotations
- @JSBracketAccess()
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def includes(value: String): Boolean
- def includes(value: String, encoding: String): Boolean
- def includes(value: String, byteOffset: Int): Boolean
- def includes(value: String, byteOffset: Int, encoding: String): Boolean
- def includes(value: Int): Boolean
- def includes(value: Int, byteOffset: Int): Boolean
- def includes(value: Buffer): Boolean
- def includes(value: Buffer, byteOffset: Int): Boolean
- def indexOf(value: String): Int
- def indexOf(value: String, encoding: String): Int
- def indexOf(value: String, byteOffset: Int): Int
- def indexOf(value: String, byteOffset: Int, encoding: String): Int
- def indexOf(value: Int): Int
- def indexOf(value: Int, byteOffset: Int): Int
- def indexOf(value: Buffer): Int
- def indexOf(value: Buffer, byteOffset: Int): Int
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
- def jsIterator(): Iterator[Short]
- Definition Classes
- TypedArray → Iterable
- Annotations
- @JSName(scala.scalajs.js.Symbol.iterator)
- 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
buf.keys()
Example: - def lastIndexOf(value: String): Int
- def lastIndexOf(value: String, encoding: String): Int
- def lastIndexOf(value: String, byteOffset: Int): Int
- def lastIndexOf(value: String, byteOffset: Int, encoding: String): Int
- def lastIndexOf(value: Int): Int
- def lastIndexOf(value: Int, byteOffset: Int): Int
- def lastIndexOf(value: Buffer): Int
- def lastIndexOf(value: Buffer, byteOffset: Int): Int
- 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
buf.length
Example: - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
- def readBigInt64BE(): BigInt
- def readBigInt64BE(offset: Int): BigInt
- def readBigUInt64LE(): BigInt
- def readBigUInt64LE(offset: Int): BigInt
- def readDoubleBE(offset: Int): Double
- 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
buf.readDoubleBE(offset[, noAssert])
Example: - def readDoubleLE(offset: Int): Double
- 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
buf.readDoubleBE(offset[, noAssert])
Example: - def readFloatBE(offset: Int): Double
- 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
buf.readFloatBE(offset[, noAssert])
Example: - def readFloatLE(offset: Int): Double
- 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
buf.readFloatLE(offset[, noAssert])
Example: - def readInt16BE(offset: Int): Int
- 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
buf.readInt16BE(offset[, noAssert])
Example: - def readInt16LE(offset: Int): Int
- 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
buf.readInt16LE(offset[, noAssert])
Example: - def readInt32BE(offset: Int): Int
- 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
buf.readInt32BE(offset[, noAssert])
Example: - def readInt32LE(offset: Int): Int
- 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
buf.readInt32LE(offset[, noAssert])
Example: - def readInt8(offset: Int): Int
- 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
buf.readInt8(offset[, noAssert])
Example: - def readIntBE(offset: Int, byteLength: Int): Int
- 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
buf.readIntBE(offset, byteLength[, noAssert])
Example: - def readIntLE(offset: Int, byteLength: Int): Int
- 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
buf.readIntLE(offset, byteLength[, noAssert])
Example: - def readUInt16BE(offset: Int): Int
- 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
buf.readUInt16BE(offset[, noAssert])
Example: - def readUInt16LE(offset: Int): Int
- 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
buf.readUInt16LE(offset[, noAssert])
Example: - def readUInt32BE(offset: Int): Int
- 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
buf.readUInt32BE(offset[, noAssert])
Example: - def readUInt32LE(offset: Int): Int
- 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
buf.readUInt32LE(offset[, noAssert])
Example: - def readUInt8(offset: Int): Int
- 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
buf.readUInt8(offset[, noAssert])
Example: - def readUIntBE(offset: Int, byteLength: Int): Int
- 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
buf.readUIntBE(offset, byteLength[, noAssert])
Example: - def readUIntLE(offset: Int, byteLength: Int): Int
- 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
buf.readUIntLE(offset, byteLength[, noAssert])
Example: - def set(array: Array[_ <: Short], offset: Int): Unit
- Definition Classes
- TypedArray
- def set(array: Array[_ <: Short]): Unit
- Definition Classes
- TypedArray
- def set(typedArray: Uint8Array, offset: Int): Unit
- Definition Classes
- TypedArray
- def set(typedArray: Uint8Array): Unit
- Definition Classes
- TypedArray
- def set(index: Int, value: Short): Unit
- Definition Classes
- TypedArray
- Annotations
- @JSBracketAccess()
- def slice(): Buffer.this.type
- def slice(start: Int): Buffer.this.type
- 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
buf.slice([start[, end]])
Example: - def subarray(begin: Int, end: Int): Uint8Array
- Definition Classes
- TypedArray
- 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
buf.swap16()
Example: - 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
buf.swap32()
Example: - 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
buf.swap64()
Example: - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- 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.
buf.toJSON()
Example: - def toLocaleString(): String
- Definition Classes
- Object
- def toString(encoding: String): String
- def toString(encoding: String, start: Int): String
- 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.
buf.toString([encoding[, start[, end]]])
Example: - def toString(): String
- Definition Classes
- AnyRef → Any
- 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
- 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()
- def update(index: Int, value: Short): Unit
- Definition Classes
- TypedArray
- Annotations
- @JSBracketAccess()
- def valueOf(): Any
- Definition Classes
- Object
- 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)
buf.values()
Example: - final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def write(string: String): Int
- def write(string: String, offset: Int): Int
- def write(string: String, offset: Int, encoding: String): Int
- def write(string: String, offset: Int, length: Int): Int
- 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
buf.write(string[, offset[, length]][, encoding])
Example: - def writeBigInt64BE(value: BigInt): Int
- def writeBigInt64BE(value: BigInt, offset: Int): Int
- def writeBigInt64LE(value: BigInt): Int
- def writeBigInt64LE(value: BigInt, offset: Int): Int
- def writeDoubleBE(value: Double, offset: Int): Int
- 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
buf.writeDoubleBE(value, offset[, noAssert])
Example: - def writeDoubleLE(value: Double, offset: Int): Int
- 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
buf.writeDoubleLE(value, offset[, noAssert])
Example: - def writeFloatBE(value: Float, offset: Int): Int
- 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
buf.writeFloatBE(value, offset[, noAssert])
Example: - def writeFloatLE(value: Float, offset: Int): Int
- 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
buf.writeFloatLE(value, offset[, noAssert])
Example: - def writeInt16BE(value: Int, offset: Int): Int
- 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
buf.writeInt16BE(value, offset[, noAssert])
Example: - def writeInt16LE(value: Int, offset: Int): Int
- 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
buf.writeInt16BE(value, offset[, noAssert])
Example: - def writeInt32BE(value: Int, offset: Int): Int
- 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
buf.writeInt32BE(value, offset[, noAssert])
Example: - def writeInt32LE(value: Int, offset: Int): Int
- 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
buf.writeInt32BE(value, offset[, noAssert])
Example: - def writeInt8(value: Int, offset: Int): Int
- 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
buf.writeInt8(value, offset[, noAssert])
Example: - def writeIntBE(value: Int, offset: Int, byteLength: Int): Int
- 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
buf.writeIntBE(value, offset, byteLength[, noAssert])
Example: - def writeIntLE(value: Int, offset: Int, byteLength: Int): Int
- 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
buf.writeIntLE(value, offset, byteLength[, noAssert])
Example: - def writeUInt16BE(value: Int, offset: Int): Int
- 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
buf.writeUInt16BE(value, offset[, noAssert])
Example: - def writeUInt16LE(value: Int, offset: Int): Int
- 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
buf.writeUInt16BE(value, offset[, noAssert])
Example: - def writeUInt32BE(value: Int, offset: Int): Int
- 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
buf.writeUInt32BE(value, offset[, noAssert])
Example: - def writeUInt32LE(value: Int, offset: Int): Int
- 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
buf.writeUInt32LE(value, offset[, noAssert])
Example: - def writeUInt8(value: Int, offset: Int): Int
- 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
buf.writeUInt8(value, offset[, noAssert])
Example: - def writeUIntBE(value: Int, offset: Int, byteLength: Int): Int
- 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
buf.writeUIntBE(value, offset, byteLength[, noAssert])
Example: - def writeUIntLE(value: Int, offset: Int, byteLength: Int): Int
- 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
buf.writeUIntLE(value, offset, byteLength[, noAssert])
Example: