
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
is-array-buffer
Advanced tools
The is-array-buffer npm package is a simple utility that allows you to check if a given value is an ArrayBuffer. It is useful when dealing with binary data in JavaScript, as it helps ensure that the data being processed is in the expected format.
Check if a value is an ArrayBuffer
This feature allows you to verify whether a given value is an instance of ArrayBuffer. It is particularly useful when working with APIs that expect binary data and you need to validate the input.
const isArrayBuffer = require('is-array-buffer');
const buffer = new ArrayBuffer(8);
const result = isArrayBuffer(buffer); // result will be true
The is-typedarray package is similar to is-array-buffer in that it checks if a value is a TypedArray, which is closely related to ArrayBuffer. It differs in that it specifically checks for TypedArray instances rather than ArrayBuffers.
The buffer package includes a method called Buffer.isBuffer which checks if an object is a Node.js Buffer, which is a way to handle binary data in Node.js. This is similar to is-array-buffer but is specific to Node.js Buffers rather than ArrayBuffers.
Similar to the buffer package, is-buffer provides a function to check if an object is a Buffer. It is designed to work in both Node.js and browser environments, making it a bit more versatile than the buffer package's Buffer.isBuffer method.
Is this value a JS ArrayBuffer? This module works cross-realm/iframe, does not depend on instanceof
or mutable properties, and despite ES6 Symbol.toStringTag.
var assert = require('assert');
var isArrayBuffer = require('is-array-buffer');
assert(!isArrayBuffer(function () {}));
assert(!isArrayBuffer(null));
assert(!isArrayBuffer(function* () { yield 42; return Infinity; });
assert(!isArrayBuffer(Symbol('foo')));
assert(!isArrayBuffer(1n));
assert(!isArrayBuffer(Object(1n)));
assert(!isArrayBuffer(new Set()));
assert(!isArrayBuffer(new WeakSet()));
assert(!isArrayBuffer(new Map()));
assert(!isArrayBuffer(new WeakMap()));
assert(!isArrayBuffer(new WeakRef({})));
assert(!isArrayBuffer(new FinalizationRegistry(() => {})));
assert(!isArrayBuffer(new SharedArrayBuffer()));
assert(isArrayBuffer(new ArrayBuffer()));
class MyArrayBuffer extends ArrayBuffer {}
assert(isArrayBuffer(new MyArrayBuffer()));
Simply clone the repo, npm install
, and run npm test
v3.0.5 - 2024-12-16
6180b31
1ea4712
@ljharb/eslint-config
, @ljharb/tsconfig
, @types/get-intrinsic
, @types/object-inspect
, @types/tape
, auto-changelog
, es-value-fixtures
, object-inspect
, tape
de2b6ab
call-bind
, get-intrinsic
55b80a1
call-bind
, get-intrinsic
184484a
available-typed-arrays
, tape
81582a7
@arethetypeswrong/cli
6d67841
call-bound
directly dd0bad1
aud
with npm audit
99b62d1
9fc6971
a3b8dbb
FAQs
Is this value a JS ArrayBuffer?
The npm package is-array-buffer receives a total of 35,206,813 weekly downloads. As such, is-array-buffer popularity was classified as popular.
We found that is-array-buffer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.