Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The is-buffer npm package is a simple utility module used to determine if an object is a Node.js Buffer. This package is particularly useful when working with modules that are designed to work both in the browser and Node.js, where the Buffer class is not available in the global scope in the browser.
Buffer Detection
This feature allows you to check if a given object is an instance of a Buffer. The function returns true if the object is a Buffer, and false otherwise.
var isBuffer = require('is-buffer');
var buffer = new Buffer('This is a buffer');
var notBuffer = {};
console.log(isBuffer(buffer)); // true
console.log(isBuffer(notBuffer)); // false
The 'buffer' package is a Node.js Buffer implementation for the browser. It's more complex than is-buffer as it aims to provide the entire Buffer API in environments that do not have it natively. Unlike is-buffer, which only checks if an object is a Buffer, the 'buffer' package allows you to create and manipulate Buffer objects in the browser.
Buffer
(including the browserify Buffer)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!
npm install is-buffer
Get supported is-buffer with the Tidelift Subscription
var isBuffer = require('is-buffer')
isBuffer(new Buffer(4)) // true
isBuffer(Buffer.alloc(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
MIT. Copyright (C) Feross Aboukhadijeh.
FAQs
Determine if an object is a Buffer
The npm package is-buffer receives a total of 11,172,398 weekly downloads. As such, is-buffer popularity was classified as popular.
We found that is-buffer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.