Skip to content

Latest commit

 

History

History

is-buffer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

isBuffer

Test if a value is a Buffer object.

Usage

var isBuffer = require( '@stdlib/utils/is-buffer' );

isBuffer( value )

Tests if a value is a Buffer object.

var value = new Buffer( [1,2,3,4] );

var bool = isBuffer( value );
// returns true

Notes

  • The implementation supports both [Node.js][node-buffer] and [browser][browser-buffer] (polyfill) `Buffer` objects.
    

Examples

var isBuffer = require( '@stdlib/utils/is-buffer' );

var bool = isBuffer( new Buffer( [1,2,3,4] ) );
// returns true

bool = isBuffer( new Buffer( 'beep' ) );
// returns true

bool = isBuffer( [] );
// returns false

bool = isBuffer( {} );
// returns false

bool = isBuffer( new Int8Array() );
// returns false

bool = isBuffer( function foo(){} );
// returns false

bool = isBuffer( null );
// returns false

bool = isBuffer( undefined );
// returns false

bool = isBuffer( 'beep' );
// returns false

bool = isBuffer( 5 );
// returns false