Companion

Properties

Link copied to clipboard

This is the size (in bytes) of pre-allocated internal Buffer instances used for pooling. This value may be modified.

Functions

Link copied to clipboard
fun alloc(size: Number): Buffer<<Error class: unknown class>>
fun alloc(    size: Number,     fill: <Error class: unknown class><out <Error class: unknown class>> = definedExternally,     encoding: BufferEncoding = definedExternally): Buffer<<Error class: unknown class>>
fun alloc(size: Number, fill: Double = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<<Error class: unknown class>>
fun alloc(size: Number, fill: String = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<<Error class: unknown class>>

Allocates a new Buffer of size bytes. If fill is undefined, theBuffer will be zero-filled.

Link copied to clipboard
fun allocUnsafe(size: Number): Buffer<<Error class: unknown class>>

Allocates a new Buffer of size bytes. If size is larger than {@link constants.MAX_LENGTH} or smaller than 0, ERR_OUT_OF_RANGE is thrown.

Link copied to clipboard
fun allocUnsafeSlow(size: Number): Buffer<<Error class: unknown class>>

Allocates a new Buffer of size bytes. If size is larger than {@link constants.MAX_LENGTH} or smaller than 0, ERR_OUT_OF_RANGE is thrown. A zero-length Buffer is created if size is 0.

Link copied to clipboard
fun byteLength(string: <Error class: unknown class>, encoding: BufferEncoding = definedExternally): Double
fun byteLength(string: <Error class: unknown class>, encoding: BufferEncoding = definedExternally): Double
fun byteLength(string: <Error class: unknown class><out <Error class: unknown class>>, encoding: BufferEncoding = definedExternally): Double
fun byteLength(string: String, encoding: BufferEncoding = definedExternally): Double
fun byteLength(string: Buffer<*>, encoding: BufferEncoding = definedExternally): Double

Returns the byte length of a string when encoded using encoding. This is not the same as String.prototype.length, which does not account for the encoding that is used to convert the string into bytes.

Link copied to clipboard
fun compare(    buf1: <Error class: unknown class><out <Error class: unknown class>>,     buf2: <Error class: unknown class><out <Error class: unknown class>>): Int

Compares buf1 to buf2, typically for the purpose of sorting arrays of Buffer instances. This is equivalent to calling buf1.compare(buf2).

Link copied to clipboard
fun concat(    list: <Error class: unknown class><<Error class: unknown class><out <Error class: unknown class>>>,     totalLength: Number = definedExternally): Buffer<<Error class: unknown class>>

Returns a new Buffer which is the result of concatenating all the Buffer instances in the list together.

Link copied to clipboard
fun copyBytesFrom(    view: <Error class: unknown class><out <Error class: unknown class>, out <Error class: unknown class>, out <Error class: unknown class>, out <Error class: unknown class>>,     offset: Number = definedExternally,     length: Number = definedExternally): Buffer<<Error class: unknown class>>

Copies the underlying memory of view into a new Buffer.

Link copied to clipboard
fun from(array: WithImplicitCoercion<<Error class: unknown class><Double>>): Buffer<<Error class: unknown class>>

Allocates a new Buffer using an array of bytes in the range 0255. Array entries outside that range will be truncated to fit into it.

fun from(string: WithImplicitCoercion<String>, encoding: BufferEncoding = definedExternally): Buffer<<Error class: unknown class>>

Creates a new Buffer containing string. The encoding parameter identifies the character encoding to be used when converting string into bytes.

fun <TArrayBuffer : WithImplicitCoercion<<Error class: unknown class>>> from(    arrayBuffer: TArrayBuffer,     byteOffset: Number = definedExternally,     length: Number = definedExternally): Buffer<<Error class: unknown class>>

This creates a view of the ArrayBuffer without copying the underlying memory. For example, when passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray's underlying ArrayBuffer.

Link copied to clipboard
fun isBuffer(obj: Any?): Boolean

Returns true if obj is a Buffer, false otherwise.

Link copied to clipboard
fun isEncoding(encoding: String): Boolean

Returns true if encoding is the name of a supported character encoding, or false otherwise.

Link copied to clipboard
fun of(vararg items: Double): Buffer<<Error class: unknown class>>

Creates a new Buffer using the passed {data}