// Fallback: Return this instance of Buffer
buf = this
buf.length = length
+ buf._isBuffer = true
}
var i
}
Buffer.isBuffer = function (b) {
- return b && b._isBuffer
+ return (b != null && b._isBuffer) || false
}
Buffer.byteLength = function (str, encoding) {
--- /dev/null
+var B = require('../index.js').Buffer
+var test = require('tape')
+
+test('Buffer.isBuffer', function (t) {
+ t.plan(3)
+ t.equal(B.isBuffer(new B('hey', 'utf8')), true)
+ t.equal(B.isBuffer(new B([1, 2, 3], 'utf8')), true)
+ t.equal(B.isBuffer('hey'), false)
+ t.end()
+})