Socket
Socket
Sign inDemoInstall

is-array-buffer

Package Overview
Dependencies
12
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-array-buffer

Is this value a JS ArrayBuffer?


Version published
Weekly downloads
27M
decreased by-0.39%
Maintainers
2
Install size
243 kB
Created
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.4 - 2024-02-02

Commits

  • [patch] add types 15fab4c

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 03 Feb 2024

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.

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