Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "buffer/from-arraybuffer/docs/types/index.d"

Index

Functions

Functions

Export assignment fromArrayBuffer

  • fromArrayBuffer(buf: ArrayBuffer, byteOffset?: undefined | number, length?: undefined | number): Buffer
  • Allocates a buffer from an ArrayBuffer.

    Notes

    The behavior of this function varies across Node.js versions due to changes in the underlying Node.js APIs:

    • <6.0.0: if provided an empty ArrayBuffer, the function returns an empty Buffer which is not an ArrayBuffer view.
    • otherwise, the function returns a view of an ArrayBuffer without copying the underlying memory.
    throws

    second argument must be a nonnegative integer

    throws

    second argument must not exceed number of bytes in input ArrayBuffer

    throws

    last argument must be a nonnegative integer

    throws

    last argument must not exceed number of bytes in input ArrayBuffer

    Parameters

    • buf: ArrayBuffer

      ArrayBuffer instance

    • Optional byteOffset: undefined | number

      index specifying the location of the first buffer byte (default: 0)

    • Optional length: undefined | number

      number of buffer bytes (default: buf.byteLength)

    Returns Buffer

    new Buffer instance

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    var ab = new ArrayBuffer( 10 );
    
    var buf = fromArrayBuffer( ab );
    // returns <Buffer>

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    var ab = new ArrayBuffer( 10 );
    
    var buf = fromArrayBuffer( ab, 2, 4 );
    // returns <Buffer>