Socket
Socket
Sign inDemoInstall

is-array-buffer

Package Overview
Dependencies
19
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

is-array-buffer

Is this value a JS ArrayBuffer?

    3.0.2
    GitHub
    npm

Version published
Maintainers
2
Weekly downloads
21,268,819
decreased by-16%

Weekly downloads

Package description

What is is-array-buffer?

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.

What are is-array-buffer's main functionalities?

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

Other packages similar to is-array-buffer

Changelog

Source

v3.0.2 - 2023-03-01

Commits

  • [Fix] node 0.8: an object arg to a TA only throws a RangeError when it is an ArrayBuffer of an incompatible byte length d5108f6
  • [Dev Deps] update object-inspect, tape 400f456
  • [Deps] update get-intrinsic 133732e

Readme

Source

is-array-buffer Version Badge

github actions coverage License Downloads

npm badge

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.

Example

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()));

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

Last updated on 02 Mar 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc