Buffer

sealed external class Buffer<TArrayBuffer>(source)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun compare(    target: <Error class: unknown class><out <Error class: unknown class>>,     targetStart: Number = definedExternally,     targetEnd: Number = definedExternally,     sourceStart: Number = definedExternally,     sourceEnd: Number = definedExternally): Int

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

Link copied to clipboard
fun copy(    target: <Error class: unknown class><out <Error class: unknown class>>,     targetStart: Number = definedExternally,     sourceStart: Number = definedExternally,     sourceEnd: Number = definedExternally): Double

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

Link copied to clipboard
operator override fun equals(otherBuffer: <Error class: unknown class><out <Error class: unknown class>>): Boolean

Returns true if both buf and otherBuffer have exactly the same bytes,false otherwise. Equivalent to buf.compare(otherBuffer) === 0.

Link copied to clipboard
fun fill(    value: <Error class: unknown class><out <Error class: unknown class>>,     offset: Number = definedExternally,     end: Number = definedExternally,     encoding: BufferEncoding = definedExternally)
fun fill(value: Double, offset: Number = definedExternally, end: Number = definedExternally, encoding: BufferEncoding = definedExternally)
fun fill(value: String, offset: Number = definedExternally, end: Number = definedExternally, encoding: BufferEncoding = definedExternally)

Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled:

Link copied to clipboard
fun includes(value: Double, byteOffset: Number = definedExternally, encoding: BufferEncoding = definedExternally): Boolean
fun includes(value: String, byteOffset: Number = definedExternally, encoding: BufferEncoding = definedExternally): Boolean
fun includes(value: Buffer<*>, byteOffset: Number = definedExternally, encoding: BufferEncoding = definedExternally): Boolean

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

Link copied to clipboard
fun indexOf(    value: <Error class: unknown class><out <Error class: unknown class>>,     byteOffset: Number = definedExternally,     encoding: BufferEncoding = definedExternally): Double
fun indexOf(value: Double, byteOffset: Number = definedExternally, encoding: BufferEncoding = definedExternally): Double
fun indexOf(value: String, byteOffset: Number = definedExternally, encoding: BufferEncoding = definedExternally): Double

If value is:

Link copied to clipboard
fun lastIndexOf(    value: <Error class: unknown class><out <Error class: unknown class>>,     byteOffset: Number = definedExternally,     encoding: BufferEncoding = definedExternally): Double
fun lastIndexOf(value: Double, byteOffset: Number = definedExternally, encoding: BufferEncoding = definedExternally): Double
fun lastIndexOf(value: String, byteOffset: Number = definedExternally, encoding: BufferEncoding = definedExternally): Double

Identical to buf.indexOf(), except the last occurrence of value is found rather than the first occurrence.

Link copied to clipboard
fun readBigInt64BE(offset: Number = definedExternally): <Error class: unknown class>

Reads a signed, big-endian 64-bit integer from buf at the specified offset.

Link copied to clipboard
fun readBigInt64LE(offset: Number = definedExternally): <Error class: unknown class>

Reads a signed, little-endian 64-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readBigUInt64BE(offset: Number = definedExternally): <Error class: unknown class>

Reads an unsigned, big-endian 64-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readBigUint64BE(offset: Number = definedExternally): <Error class: unknown class>
Link copied to clipboard
fun readBigUInt64LE(offset: Number = definedExternally): <Error class: unknown class>

Reads an unsigned, little-endian 64-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readBigUint64LE(offset: Number = definedExternally): <Error class: unknown class>
Link copied to clipboard
fun readDoubleBE(offset: Number = definedExternally): Double

Reads a 64-bit, big-endian double from buf at the specified offset.

Link copied to clipboard
fun readDoubleLE(offset: Number = definedExternally): Double

Reads a 64-bit, little-endian double from buf at the specified offset.

Link copied to clipboard
fun readFloatBE(offset: Number = definedExternally): Double

Reads a 32-bit, big-endian float from buf at the specified offset.

Link copied to clipboard
fun readFloatLE(offset: Number = definedExternally): Double

Reads a 32-bit, little-endian float from buf at the specified offset.

Link copied to clipboard
fun readInt16BE(offset: Number = definedExternally): Double

Reads a signed, big-endian 16-bit integer from buf at the specified offset.

Link copied to clipboard
fun readInt16LE(offset: Number = definedExternally): Double

Reads a signed, little-endian 16-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readInt32BE(offset: Number = definedExternally): Double

Reads a signed, big-endian 32-bit integer from buf at the specified offset.

Link copied to clipboard
fun readInt32LE(offset: Number = definedExternally): Double

Reads a signed, little-endian 32-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readInt8(offset: Number = definedExternally): Double

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

Link copied to clipboard
fun readIntBE(offset: Number, byteLength: Number): Double

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

Link copied to clipboard
fun readIntLE(offset: Number, byteLength: Number): Double

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

Link copied to clipboard
fun readUInt16BE(offset: Number = definedExternally): Double

Reads an unsigned, big-endian 16-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readUint16BE(offset: Number = definedExternally): Double
Link copied to clipboard
fun readUInt16LE(offset: Number = definedExternally): Double

Reads an unsigned, little-endian 16-bit integer from buf at the specified offset.

Link copied to clipboard
fun readUint16LE(offset: Number = definedExternally): Double
Link copied to clipboard
fun readUInt32BE(offset: Number = definedExternally): Double

Reads an unsigned, big-endian 32-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readUint32BE(offset: Number = definedExternally): Double
Link copied to clipboard
fun readUInt32LE(offset: Number = definedExternally): Double

Reads an unsigned, little-endian 32-bit integer from buf at the specifiedoffset.

Link copied to clipboard
fun readUint32LE(offset: Number = definedExternally): Double
Link copied to clipboard
fun readUInt8(offset: Number = definedExternally): Double

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

Link copied to clipboard
fun readUint8(offset: Number = definedExternally): Double
Link copied to clipboard
fun readUIntBE(offset: Number, byteLength: Number): Double

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

Link copied to clipboard
fun readUintBE(offset: Number, byteLength: Number): Double
Link copied to clipboard
fun readUIntLE(offset: Number, byteLength: Number): Double

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

Link copied to clipboard
fun readUintLE(offset: Number, byteLength: Number): Double
Link copied to clipboard
fun slice(start: Number = definedExternally, end: Number = definedExternally): Buffer<<Error class: unknown class>>

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

Link copied to clipboard
fun subarray(start: Number = definedExternally, end: Number = definedExternally): Buffer<TArrayBuffer>

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

Link copied to clipboard
fun swap16()

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

Link copied to clipboard
fun swap32()

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

Link copied to clipboard
fun swap64()

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

Link copied to clipboard

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

Link copied to clipboard
fun toString(encoding: BufferEncoding = definedExternally, start: Number = definedExternally, end: Number = definedExternally): String

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

Link copied to clipboard
fun write(string: String, encoding: BufferEncoding = definedExternally): Double

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

fun write(string: String, offset: Number, encoding: BufferEncoding = definedExternally): Double
fun write(string: String, offset: Number, length: Number, encoding: BufferEncoding = definedExternally): Double
Link copied to clipboard
fun writeBigInt64BE(value: <Error class: unknown class>, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian.

Link copied to clipboard
fun writeBigInt64LE(value: <Error class: unknown class>, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian.

Link copied to clipboard
fun writeBigUInt64BE(value: <Error class: unknown class>, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian.

Link copied to clipboard
fun writeBigUint64BE(value: <Error class: unknown class>, offset: Number = definedExternally): Double
Link copied to clipboard
fun writeBigUInt64LE(value: <Error class: unknown class>, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian

Link copied to clipboard
fun writeBigUint64LE(value: <Error class: unknown class>, offset: Number = definedExternally): Double
Link copied to clipboard
fun writeDoubleBE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian. The value must be a JavaScript number. Behavior is undefined when value is anything other than a JavaScript number.

Link copied to clipboard
fun writeDoubleLE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian. The value must be a JavaScript number. Behavior is undefined when value is anything other than a JavaScript number.

Link copied to clipboard
fun writeFloatBE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian. Behavior is undefined when value is anything other than a JavaScript number.

Link copied to clipboard
fun writeFloatLE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian. Behavior is undefined when value is anything other than a JavaScript number.

Link copied to clipboard
fun writeInt16BE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian. The value must be a valid signed 16-bit integer. Behavior is undefined when value is anything other than a signed 16-bit integer.

Link copied to clipboard
fun writeInt16LE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian. The value must be a valid signed 16-bit integer. Behavior is undefined when value is anything other than a signed 16-bit integer.

Link copied to clipboard
fun writeInt32BE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian. The value must be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

Link copied to clipboard
fun writeInt32LE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian. The value must be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

Link copied to clipboard
fun writeInt8(value: Number, offset: Number = definedExternally): Double

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

Link copied to clipboard
fun writeIntBE(value: Number, offset: Number, byteLength: Number): Double

Writes byteLength bytes of value to buf at the specified offsetas big-endian. Supports up to 48 bits of accuracy. Behavior is undefined whenvalue is anything other than a signed integer.

Link copied to clipboard
fun writeIntLE(value: Number, offset: Number, byteLength: Number): Double

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

Link copied to clipboard
fun writeUInt16BE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian. The value must be a valid unsigned 16-bit integer. Behavior is undefined when valueis anything other than an unsigned 16-bit integer.

Link copied to clipboard
fun writeUint16BE(value: Number, offset: Number = definedExternally): Double
Link copied to clipboard
fun writeUInt16LE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian. The value must be a valid unsigned 16-bit integer. Behavior is undefined when value is anything other than an unsigned 16-bit integer.

Link copied to clipboard
fun writeUint16LE(value: Number, offset: Number = definedExternally): Double
Link copied to clipboard
fun writeUInt32BE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as big-endian. The value must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.

Link copied to clipboard
fun writeUint32BE(value: Number, offset: Number = definedExternally): Double
Link copied to clipboard
fun writeUInt32LE(value: Number, offset: Number = definedExternally): Double

Writes value to buf at the specified offset as little-endian. The value must be a valid unsigned 32-bit integer. Behavior is undefined when value is anything other than an unsigned 32-bit integer.

Link copied to clipboard
fun writeUint32LE(value: Number, offset: Number = definedExternally): Double
Link copied to clipboard
fun writeUInt8(value: Number, offset: Number = definedExternally): Double

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

Link copied to clipboard
fun writeUint8(value: Number, offset: Number = definedExternally): Double
Link copied to clipboard
fun writeUIntBE(value: Number, offset: Number, byteLength: Number): Double

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

Link copied to clipboard
fun writeUintBE(value: Number, offset: Number, byteLength: Number): Double
Link copied to clipboard
fun writeUIntLE(value: Number, offset: Number, byteLength: Number): Double

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

Link copied to clipboard
fun writeUintLE(value: Number, offset: Number, byteLength: Number): Double