Object/Class

io.scalajs.nodejs.buffer

Buffer

Related Docs: class Buffer | package buffer

Permalink

object Buffer extends Object

Annotations
@native() @JSName( "Buffer" )
Linear Supertypes
Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Buffer
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val INSPECT_MAX_BYTES: Int

    Permalink

    Returns the maximum number of bytes that will be returned when buf.inspect() is called.

    Returns the maximum number of bytes that will be returned when buf.inspect() is called. This can be overridden by user modules. See util.inspect() for more details on buf.inspect() behavior.

    Note that this is a property on the buffer module returned by require('buffer'), not on the Buffer global or a Buffer instance.

  5. def alloc(size: Int, fill: |[|[Buffer, Int], String] = js.native, encoding: String = js.native): Buffer

    Permalink

    Allocates a new Buffer of size bytes.

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

    size

    The desired length of the new Buffer

    fill

    A value to pre-fill the new Buffer with. Default: 0

    encoding

    If fill is a string, this is its encoding. Default: 'utf8'

    returns

    a new Buffer

    Example:
    1. Buffer.alloc(size[, fill[, encoding]])
  6. def allocUnsafe(size: Int): Buffer

    Permalink

    Calling Buffer.alloc(size) can be significantly slower than the alternative Buffer.allocUnsafe(size) but ensures that the newly created Buffer instance contents will never contain sensitive data.

    Calling Buffer.alloc(size) can be significantly slower than the alternative Buffer.allocUnsafe(size) but ensures that the newly created Buffer instance contents will never contain sensitive data.

    size

    the allocated size.

    Example:
    1. Buffer.allocUnsafe(size)

  7. def allocUnsafeSlow(size: Int): Buffer

    Permalink

    Allocates a new non-zero-filled and non-pooled Buffer of size bytes.

    Allocates a new non-zero-filled and non-pooled Buffer of size bytes. The size must be less than or equal to the value of require('buffer').kMaxLength (on 64-bit architectures, kMaxLength is

    (2^31)-1).

    Otherwise, a RangeError is thrown. A zero-length Buffer will be created if a size less than or equal to 0 is specified.

    The underlying memory for Buffer instances created in this way is not initialized. The contents of the newly created Buffer are unknown and may contain sensitive data. Use buf.fill(0) to initialize such Buffer instances to zeroes.

    When using Buffer.allocUnsafe() to allocate new Buffer instances, allocations under 4KB are, by default, sliced from a single pre-allocated Buffer. This allows applications to avoid the garbage collection overhead of creating many individually allocated Buffers. This approach improves both performance and memory usage by eliminating the need to track and cleanup as many Persistent objects.

    However, in the case where a developer may need to retain a small chunk of memory from a pool for an indeterminate amount of time, it may be appropriate to create an un-pooled Buffer instance using Buffer.allocUnsafeSlow() then copy out the relevant bits. (2^31)-1). }}} is thrown. A zero-length Buffer will be created if a size less than or equal to 0 is specified.

    The underlying memory for Buffer instances created in this way is not initialized. The contents of the newly created Buffer are unknown and may contain sensitive data. Use buf.fill(0) to initialize such Buffer instances to zeroes.

    When using Buffer.allocUnsafe() to allocate new Buffer instances, allocations under 4KB are, by default, sliced from a single pre-allocated Buffer. This allows applications to avoid the garbage collection overhead of creating many individually allocated Buffers. This approach improves both performance and memory usage by eliminating the need to track and cleanup as many Persistent objects.

    However, in the case where a developer may need to retain a small chunk of memory from a pool for an indeterminate amount of time, it may be appropriate to create an un-pooled Buffer instance using Buffer.allocUnsafeSlow() then copy out the relevant bits.

    size

    the allocated size.

    Example:
    1. Buffer.allocUnsafeSlow(size)

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def byteLength(string: Any, encoding: String = "utf8"): Int

    Permalink

    Returns the actual byte length of a string.

    Returns the actual byte length of a string. This is not the same as String.prototype.length since that returns the number of characters in a string.

    string

    <String> | <Buffer> | <TypedArray> | <DataView> | <ArrayBuffer>

    encoding

    the optional encoding (default "utf8")

    Example:
    1. Buffer.byteLength(string[, encoding])

  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def compare(buf1: Buffer, buf2: Buffer): Int

    Permalink

    Compares buf1 to buf2 typically for the purpose of sorting arrays of Buffers.

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

  12. def concat(list: Array[Buffer]): Buffer

    Permalink

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

    Returns a new Buffer which is the result of concatenating all the Buffers in the list together. If the list has no items, or if the totalLength is 0, then a new zero-length Buffer is returned. If totalLength is not provided, it is calculated from the Buffers in the list. This, however, adds an additional loop to the function, so it is faster to provide the length explicitly.

    list

    the list of Buffer objects to concat

    Example:
    1. Buffer.concat(list[, totalLength])

  13. def concat(list: Array[Buffer], totalLength: Int): Buffer

    Permalink

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

    Returns a new Buffer which is the result of concatenating all the Buffers in the list together. If the list has no items, or if the totalLength is 0, then a new zero-length Buffer is returned. If totalLength is not provided, it is calculated from the Buffers in the list. This, however, adds an additional loop to the function, so it is faster to provide the length explicitly.

    list

    the list of Buffer objects to concat

    totalLength

    the optional total length

    Example:
    1. Buffer.concat(list[, totalLength])

  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def from(str: String, encoding: String = js.native): Buffer

    Permalink

    Creates a new Buffer containing the given JavaScript string str.

    Creates a new Buffer containing the given JavaScript string str. If provided, the encoding parameter identifies the strings character encoding.

    str

    the source string

    encoding

    the given encoding

    returns

    a new Buffer

  18. def from(array: Array[Int]): Buffer

    Permalink

    Allocates a new Buffer using an array of octets.

    Allocates a new Buffer using an array of octets.

    Example:
    1. Buffer.from(array)

  19. def from(arrayBuffer: ArrayBuffer): Buffer

    Permalink

    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.

    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.

    Example:
    1. Buffer.from(arrayBuffer[, byteOffset[, length]])
  20. def from(arrayBuffer: ArrayBuffer, byteOffset: Int): Buffer

    Permalink

    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.

    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.

    Example:
    1. Buffer.from(arrayBuffer[, byteOffset[, length]])
  21. def from(arrayBuffer: ArrayBuffer, byteOffset: Int, length: Int): Buffer

    Permalink

    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.

    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.

    Example:
    1. Buffer.from(arrayBuffer[, byteOffset[, length]])
  22. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  23. def hasOwnProperty(v: String): Boolean

    Permalink
    Definition Classes
    Object
  24. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  25. def isBuffer(obj: Any): Boolean

    Permalink

    Returns true if obj is a Buffer, false otherwise.

    Returns true if obj is a Buffer, false otherwise.

    obj

    the given object

    returns

    true if obj is a Buffer, false otherwise.

  26. def isEncoding(encoding: String): Boolean

    Permalink

    Returns true if encoding contains a supported character encoding, or false otherwise.

    Returns true if encoding contains a supported character encoding, or false otherwise.

    encoding

    A character encoding name to check

    returns

    true if encoding contains a supported character encoding, or false otherwise.

  27. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  28. def isPrototypeOf(v: Object): Boolean

    Permalink
    Definition Classes
    Object
  29. val kMaxLength: Int

    Permalink

    On 32-bit architectures, this value is (230)-1 (~1GB). On 64-bit architectures, this value is (231)-1 (~2GB).F Note that this is a property on the buffer module returned by require('buffer'), not on the Buffer global or a Buffer instance.

  30. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  31. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  33. var poolSize: Int

    Permalink

    This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling.

    This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.

  34. def propertyIsEnumerable(v: String): Boolean

    Permalink
    Definition Classes
    Object
  35. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  36. def toLocaleString(): String

    Permalink
    Definition Classes
    Object
  37. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  38. def transcode(source: Buffer, fromEnc: String, toEnc: String): Buffer

    Permalink

    Re-encodes the given Buffer instance from one character encoding to another.

    Re-encodes the given Buffer instance from one character encoding to another. Returns a new Buffer instance.

    Throws if the fromEnc or toEnc specify invalid character encodings or if conversion from fromEnc to toEnc is not permitted.

    The transcoding process will use substitution characters if a given byte sequence cannot be adequately represented in the target encoding.

    source

    A Buffer instance

    fromEnc

    The current encoding

    toEnc

    To target encoding

    returns

    a new Buffer instance.

  39. def valueOf(): Any

    Permalink
    Definition Classes
    Object
  40. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped