NodeBufferInstance

A base implementation for the Node.js BufferInstance API, serving as a template for Buffer instances without specifying the backing ArrayBuffer value.

Inheritors

Properties

Link copied to clipboard
abstract val buffer: PolyglotValue

Returns the backing ArrayBuffer for this buffer instance. The byteOffset indicates the index of this backing value at which the view represented by this Buffer begins.

Link copied to clipboard
abstract val byteOffset: Int

The index in the backing buffer at which this view starts.

Link copied to clipboard
abstract val length: Int

The number of bytes exposed from the backing buffer, starting at byteOffset.

Functions

Link copied to clipboard
open override fun compare(target: PolyglotValue, targetStart: Int?, targetEnd: Int?, sourceStart: Int?, sourceEnd: Int?): Int

Compare this buffer with either another buffer instance or a Uint8Array, optionally using only delimited segments of both values.

Link copied to clipboard
open override fun copy(target: PolyglotValue, targetStart: Int?, sourceStart: Int?, sourceEnd: Int?): Int

Copies the contents of this buffer to a target, optionally starting at an offset and limiting the copied region from the source.

Link copied to clipboard
open override fun entries(): PolyglotValue

Returns an iterable value which yields, for every byte in the buffer, an array with the index as the first element and the byte as a second element.

Link copied to clipboard
open override fun fill(value: PolyglotValue, offset: Int?, end: Int?, encoding: String?): BufferInstance

Fill the buffer starting at offset and stopping at end with the given value. If the value is a string, it is converted to bytes using encoding (UTF-8 by default).

Link copied to clipboard
abstract operator fun get(index: Long): Any
Link copied to clipboard
open override fun getIterator(): Any
Link copied to clipboard
open override fun getMember(key: String?): Any
Link copied to clipboard
open override fun getMemberKeys(): Any
Link copied to clipboard
abstract fun getSize(): Long
Link copied to clipboard
open override fun hasMember(key: String?): Boolean
Link copied to clipboard
open override fun indexOf(value: PolyglotValue, byteOffset: Int?, encoding: String?): Int

Returns the byte index of the first occurrence of value in the buffer after byteOffset, or -1 if it is not found. The value may be a number (coerced into byte size), a string, another buffer, or a Uint8Array. The encoding will be used for string values if available.

Link copied to clipboard
open override fun keys(): PolyglotValue

Returns an iterable value which yields the buffer's keys (indices).

Link copied to clipboard
open override fun lastIndexOf(value: PolyglotValue, byteOffset: Int?, encoding: String?): Int

Returns the byte index of the last occurrence of value in the buffer after byteOffset, or -1 if it is not found. The value may be a number (coerced into byte size), a string, another buffer, or a Uint8Array. The encoding will be used for string values if available.

Link copied to clipboard
open override fun putMember(key: String?, value: Value?)
Link copied to clipboard
abstract fun readBigInt64BE(offset: Int?): Long

Read a 64-bit integer from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readBigInt64LE(offset: Int?): Long

Read a 64-bit integer from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
open fun readBigUInt64BE(offset: Int?): BigInt

Read a 64-bit unsigned integer from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
open fun readBigUInt64LE(offset: Int?): BigInt

Read a 64-bit unsigned integer from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readDoubleBE(offset: Int?): Double

Read a 64-bit double-precision floating point value from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readDoubleLE(offset: Int?): Double

Read a 64-bit double-precision floating point value from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readFloatBE(offset: Int?): Float

Read a 32-bit floating point value from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readFloatLE(offset: Int?): Float

Read a 32-bit floating point value from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readInt16BE(offset: Int?): Short

Read a 16-bit integer from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readInt16LE(offset: Int?): Short

Read a 16-bit integer from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readInt32BE(offset: Int?): Int

Read a 32-bit integer from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readInt32LE(offset: Int?): Int

Read a 32-bit integer from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun readInt8(offset: Int?): Byte

Read an 8-bit integer from the buffer, optionally at an offset.

Link copied to clipboard
abstract fun readIntBE(offset: Int, byteLength: Int): Long

Read an integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Big Endian byte order, at the given offset.

Link copied to clipboard
abstract fun readIntLE(offset: Int, byteLength: Int): Long

Read an integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Little Endian byte order, at the given offset.

Link copied to clipboard
open fun readUInt16BE(offset: Int?): Int

Read a 16-bit unsigned integer from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
open fun readUInt16LE(offset: Int?): Int

Read a 16-bit unsigned integer from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
open fun readUInt32BE(offset: Int?): Long

Read a 32-bit unsigned integer from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
open fun readUInt32LE(offset: Int?): Long

Read a 32-bit unsigned integer from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
open fun readUInt8(offset: Int?): Int

Read an 8-bit unsigned integer from the buffer, optionally at an offset.

Link copied to clipboard
abstract fun readUIntBE(offset: Int, byteLength: Int): Long

Read an unsigned integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Big Endian byte order, at the given offset.

Link copied to clipboard
abstract fun readUIntLE(offset: Int, byteLength: Int): Long

Read an unsigned integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Little Endian byte order, at the given offset.

Link copied to clipboard
open fun remove(index: Long): Boolean
Link copied to clipboard
open override fun removeMember(key: String?): Boolean
Link copied to clipboard
abstract operator fun set(index: Long, value: Value)
Link copied to clipboard
abstract fun subarray(start: Int? = null, end: Int? = null): BufferInstance

Returns a new Buffer instance as a view of this buffer's contents in the given range. Updates to this buffer's data are visible to the returned instance.

Link copied to clipboard
abstract fun swap16(): BufferInstance

Interpret this buffer as containing only 16-bit integers and swap their byte order in-place. If the buffer's byte length is not a multiple of 2, an error will be thrown.

Link copied to clipboard
abstract fun swap32(): BufferInstance

Interpret this buffer as containing only 32-bit integers and swap their byte order in-place. If the buffer's byte length is not a multiple of 4, an error will be thrown.

Link copied to clipboard
abstract fun swap64(): BufferInstance

Interpret this buffer as containing only 64-bit integers and swap their byte order in-place. If the buffer's byte length is not a multiple of 8, an error will be thrown.

Link copied to clipboard
open override fun toJSON(): PolyglotValue

Returns a JSON object representation of this buffer, with the data rendered into an array of byte values.

Link copied to clipboard
open override fun toString(encoding: String?, start: Int?, end: Int?): String

Decodes the buffer's data as a string using the given encoding.

Link copied to clipboard
open override fun values(): PolyglotValue

Returns an iterable value which yields the buffer's byte values.

Link copied to clipboard
abstract fun write(string: String, offset: Int? = null, length: Int? = null, encoding: String? = null): Int

Encode a string and write it into the buffer at the given offset, optionally truncating the resulting bytes to match a specific length.

Link copied to clipboard
abstract fun writeBigInt64BE(value: Long, offset: Int?): Int

Write an 64-bit signed integer to the buffer at an offset using Big Endian order.

Link copied to clipboard
abstract fun writeBigInt64LE(value: Long, offset: Int?): Int

Write an 64-bit signed integer to the buffer at an offset using Little Endian order.

Link copied to clipboard
open fun writeBigUInt64BE(value: Long, offset: Int?): Int

Write an 64-bit unsigned integer to the buffer at an offset using Big Endian order.

Link copied to clipboard
open fun writeBigUInt64LE(value: Long, offset: Int?): Int

Write an 64-bit unsigned integer to the buffer at an offset using Little Endian order.

Link copied to clipboard
abstract fun writeDoubleBE(value: Double, offset: Int?): Int

Write a 64-bit double-precision floating point value from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun writeDoubleLE(value: Double, offset: Int?): Int

Write a 64-bit double-precision floating point value from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun writeFloatBE(value: Float, offset: Int?): Int

Write a 32-bit floating point value from the buffer using the Big Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun writeFloatLE(value: Float, offset: Int?): Int

Write a 32-bit floating point value from the buffer using the Little Endian byte order, optionally at an offset.

Link copied to clipboard
abstract fun writeInt16BE(value: Short, offset: Int?): Int

Write an 16-bit signed integer to the buffer at an offset using Big Endian order.

Link copied to clipboard
abstract fun writeInt16LE(value: Short, offset: Int?): Int

Write an 16-bit signed integer to the buffer at an offset using Little Endian order.

Link copied to clipboard
abstract fun writeInt32BE(value: Int, offset: Int?): Int

Write an 32-bit signed integer to the buffer at an offset using Big Endian order.

Link copied to clipboard
abstract fun writeInt32LE(value: Int, offset: Int?): Int

Write an 32-bit signed integer to the buffer at an offset using Little Endian order.

Link copied to clipboard
abstract fun writeInt8(value: Byte, offset: Int?): Int

Write an 8-bit signed integer to the buffer at an offset.

Link copied to clipboard
abstract fun writeIntBE(value: Long, offset: Int, byteLength: Int): Int

WRite an integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Big Endian byte order, at the given offset.

Link copied to clipboard
abstract fun writeIntLE(value: Long, offset: Int, byteLength: Int): Int

Read an integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Little Endian byte order, at the given offset.

Link copied to clipboard
open fun writeUInt16BE(value: Int, offset: Int?): Int

Write an 16-bit unsigned integer to the buffer at an offset using Big Endian order.

Link copied to clipboard
open fun writeUInt16LE(value: Int, offset: Int?): Int

Write an 16-bit unsigned integer to the buffer at an offset using Little Endian order.

Link copied to clipboard
open fun writeUInt32BE(value: Long, offset: Int?): Int

Write an 32-bit unsigned integer to the buffer at an offset using Big Endian order.

Link copied to clipboard
open fun writeUInt32LE(value: Long, offset: Int?): Int

Write an 32-bit unsigned integer to the buffer at an offset using Little Endian order.

Link copied to clipboard
open fun writeUInt8(value: Int, offset: Int?): Int

Write an 8-bit unsigned integer to the buffer at an offset.

Link copied to clipboard
open fun writeUIntBE(value: Long, offset: Int, byteLength: Int): Int

Read an unsigned integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Big Endian byte order, at the given offset.

Link copied to clipboard
open fun writeUIntLE(value: Long, offset: Int, byteLength: Int): Int

Read an unsigned integer with the specified byteLength (in bytes, up to 6 bytes/48 bits) using the Little Endian byte order, at the given offset.