Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-buffer

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-buffer - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

28

index.js

@@ -1,17 +0,21 @@

/**
* Determine if an object is Buffer
/*!
* Determine if an object is a Buffer
*
* Author: Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* License: MIT
*
* `npm install is-buffer`
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
// The _isBuffer check is for Safari 5-7 support, because it's missing
// Object.prototype.constructor. Remove this eventually
module.exports = function (obj) {
return !!(obj != null &&
(obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor)
(obj.constructor &&
typeof obj.constructor.isBuffer === 'function' &&
obj.constructor.isBuffer(obj))
))
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
}
function isBuffer (obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
// For Node v0.10 support. Remove this eventually.
function isSlowBuffer (obj) {
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
}
{
"name": "is-buffer",
"description": "Determine if an object is Buffer",
"version": "1.1.3",
"description": "Determine if an object is a Buffer",
"version": "1.1.4",
"author": {

@@ -15,9 +15,6 @@ "name": "Feross Aboukhadijeh",

"devDependencies": {
"standard": "^6.0.5",
"standard": "^7.0.0",
"tape": "^4.0.0",
"zuul": "^3.0.0"
},
"engines": {
"node": ">=0.12"
},
"keywords": [

@@ -24,0 +21,0 @@ "buffer",

# is-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][npm-url]
#### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (incl. [browser Buffers](https://github.com/feross/buffer))
#### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (including the [browserify Buffer](https://github.com/feross/buffer))

@@ -5,0 +5,0 @@ [![saucelabs][saucelabs-image]][saucelabs-url]

@@ -0,1 +1,2 @@

var buffer = require('buffer')
var isBuffer = require('../')

@@ -5,17 +6,21 @@ var test = require('tape')

test('is-buffer', function (t) {
t.ok(isBuffer(new Buffer(4)), 'new Buffer(4)')
t.equal(isBuffer(new Buffer(4)), true, 'new Buffer(4)')
t.equal(isBuffer(buffer.SlowBuffer(100)), true, 'SlowBuffer(100)')
t.notOk(isBuffer(undefined), 'undefined')
t.notOk(isBuffer(null), 'null')
t.notOk(isBuffer(''), 'empty string')
t.notOk(isBuffer(true), 'true')
t.notOk(isBuffer(false), 'false')
t.notOk(isBuffer(0), '0')
t.notOk(isBuffer(1), '1')
t.notOk(isBuffer(1.0), '1.0')
t.notOk(isBuffer('string'), 'string')
t.notOk(isBuffer({}), '{}')
t.notOk(isBuffer(function foo () {}), 'function foo () {}')
t.equal(isBuffer(undefined), false, 'undefined')
t.equal(isBuffer(null), false, 'null')
t.equal(isBuffer(''), false, 'empty string')
t.equal(isBuffer(true), false, 'true')
t.equal(isBuffer(false), false, 'false')
t.equal(isBuffer(0), false, '0')
t.equal(isBuffer(1), false, '1')
t.equal(isBuffer(1.0), false, '1.0')
t.equal(isBuffer('string'), false, 'string')
t.equal(isBuffer({}), false, '{}')
t.equal(isBuffer([]), false, '[]')
t.equal(isBuffer(function foo () {}), false, 'function foo () {}')
t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }')
t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }')
t.end()
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc