mirror of
https://github.com/thangisme/notes.git
synced 2024-10-31 22:37:27 -04:00
1.5 KiB
1.5 KiB
is-buffer
Determine if an object is a Buffer
(including the browserify Buffer)
Why not use Buffer.isBuffer
?
This module lets you check if an object is a Buffer
without using Buffer.isBuffer
(which includes the whole buffer module in browserify).
It's future-proof and works in node too!
install
npm install is-buffer
usage
var isBuffer = require('is-buffer')
isBuffer(new Buffer(4)) // true
isBuffer(undefined) // false
isBuffer(null) // false
isBuffer('') // false
isBuffer(true) // false
isBuffer(false) // false
isBuffer(0) // false
isBuffer(1) // false
isBuffer(1.0) // false
isBuffer('string') // false
isBuffer({}) // false
isBuffer(function foo () {}) // false
license
MIT. Copyright (C) Feross Aboukhadijeh.