is-buffer
Determine if an object is a Buffer
(incl. browser buffers).
Why not use Buffer.isBuffer
?
If you just want to check if an object is a Buffer
without require('buffer') (which bundles the entire buffer module in browserify), then use this module. It's future-proof and works in node too!
install
npm install is-buffer
usage
var isBuffer = require('is-buffer')
isBuffer(new Buffer(4))
isBuffer(undefined)
isBuffer(null)
isBuffer('')
isBuffer(true)
isBuffer(false)
isBuffer(0)
isBuffer(1)
isBuffer(1.0)
isBuffer('string')
isBuffer({})
isBuffer(function foo () {})
license
MIT. Copyright (C) Feross Aboukhadijeh.