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: Symbol not found for ArrayBuffer>
fun alloc(size: Number, fill: ERROR CLASS: Symbol not found for Uint8Array<*> = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>
fun alloc(size: Number, fill: Double = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>
fun alloc(size: Number, fill: String = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>

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: Symbol not found for ArrayBuffer>

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: Symbol not found for ArrayBuffer>

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: Symbol not found for ArrayBuffer, encoding: BufferEncoding = definedExternally): Double
fun byteLength(string: ERROR CLASS: Symbol not found for SharedArrayBuffer, encoding: BufferEncoding = definedExternally): Double
fun byteLength(string: ERROR CLASS: Symbol not found for js.buffer.ArrayBufferView<*>, 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: Symbol not found for Uint8Array<*>, buf2: ERROR CLASS: Symbol not found for Uint8Array<*>): 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: Symbol not found for js.array.ReadonlyArray<ERROR CLASS: Symbol not found for Uint8Array<*>>, totalLength: Number = definedExternally): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>

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: Symbol not found for js.typedarrays.TypedArray<*, *, *, *>, offset: Number = definedExternally, length: Number = definedExternally): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>

Copies the underlying memory of view into a new Buffer.

Link copied to clipboard
fun from(array: ERROR CLASS: Symbol not found for ArrayLike<kotlin/Double>): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>

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(arrayOrString: Any): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>

fun from(string: String, encoding: BufferEncoding = definedExternally): Buffer<ERROR CLASS: Symbol not found for ArrayBuffer>

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

fun <TArrayBuffer : ERROR CLASS: Symbol not found for ArrayBufferLike> from(arrayBuffer: TArrayBuffer, byteOffset: Number = definedExternally, length: Number = definedExternally): Buffer<TArrayBuffer>

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: Symbol not found for ArrayBuffer>

Creates a new Buffer using the passed {data}