
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
A function that takes anything in javascript and returns true if its argument contains binary data.
The has-binary npm package is a utility that checks if a given JavaScript object or array contains any binary data. This can be useful in various scenarios, such as when you need to determine if an object contains binary data before performing certain operations like serialization or transmission over a network.
Check if an object contains binary data
This feature allows you to check if a given object contains any binary data. In this example, the object contains a Buffer, which is binary data, so the function returns true.
const hasBinary = require('has-binary');
const obj = { key: 'value', buffer: Buffer.from('binary data') };
console.log(hasBinary(obj)); // true
Check if an array contains binary data
This feature allows you to check if a given array contains any binary data. In this example, the array contains a Uint8Array, which is binary data, so the function returns true.
const hasBinary = require('has-binary');
const arr = ['string', new Uint8Array([1, 2, 3])];
console.log(hasBinary(arr)); // true
The is-buffer package is a simple utility to check if a given object is a Buffer. While it is more limited in scope compared to has-binary, it can be useful if you only need to check for Buffer objects specifically.
The bufferutil package provides utilities for working with Buffer objects, including checking if an object is a Buffer. It offers more functionality for Buffer manipulation but does not provide the broader binary data detection capabilities of has-binary.
The typedarray-to-buffer package converts TypedArray instances to Buffer objects. While it does not directly check for binary data, it can be used in conjunction with other utilities to handle binary data more effectively.
Simple module to test if an object contains binary data
FAQs
A function that takes anything in javascript and returns true if its argument contains binary data.
The npm package has-binary receives a total of 291,089 weekly downloads. As such, has-binary popularity was classified as popular.
We found that has-binary 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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.