Companion

external object Companion(source)

Properties

Link copied to clipboard
external var poolSize: Double

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
external fun alloc(size: Number): Buffer<ArrayBuffer>
external fun alloc(size: Number, fill: Uint8Array<*> = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<ArrayBuffer>
external fun alloc(size: Number, fill: Double = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<ArrayBuffer>
external fun alloc(size: Number, fill: String = definedExternally, encoding: BufferEncoding = definedExternally): Buffer<ArrayBuffer>

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

Link copied to clipboard
external fun allocUnsafe(size: Number): Buffer<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

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
external fun byteLength(string: ArrayBufferLike, encoding: BufferEncoding = definedExternally): Double
external fun byteLength(string: ArrayBufferView<*>, encoding: BufferEncoding = definedExternally): Double
external fun byteLength(string: String, 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
external fun compare(buf1: Uint8Array<*>, buf2: 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
external fun concat(list: ReadonlyArray<Uint8Array<*>>, totalLength: Number = definedExternally): Buffer<ArrayBuffer>

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

Link copied to clipboard
external fun copyBytesFrom(view: TypedArray<*, *, *, *>, offset: Number = definedExternally, length: Number = definedExternally): Buffer<ArrayBuffer>

Copies the underlying memory of view into a new Buffer.

Link copied to clipboard
external fun from(array: ArrayLike<Double>): Buffer<ArrayBuffer>

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

external fun from(arrayOrString: Any): Buffer<ArrayBuffer>

external fun from(string: String, encoding: BufferEncoding = definedExternally): Buffer<ArrayBuffer>

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

external fun <TArrayBuffer : 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
external fun isBuffer(obj: Any?): Boolean

Returns true if obj is a Buffer, false otherwise.

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

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

Link copied to clipboard
external fun of(vararg items: Double): Buffer<ArrayBuffer>

Creates a new Buffer using the passed {data}