Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "buffer/to-json/docs/types/index.d"

Index

Functions

Functions

toJSON

  • Returns a JSON representation of a Buffer.

    throws

    first argument must be a Buffer

    Parameters

    • buffer: Buffer

      buffer to serialize

    Returns any

    JSON representation

    Example

    var array2buffer = require( `@stdlib/buffer/from-array` );
    
    var buf = array2buffer( [ 1, 2 ] );
    // returns <Buffer>
    
    var json = toJSON( buf );
    // returns { 'type': 'Buffer', 'data': [ 1, 2 ] }