Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
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 282,390 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.