Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-array-buffer

inspect-js96.2mMIT3.0.5TypeScript support: included

Is this value a JS ArrayBuffer?

javascript, ecmascript, is, arraybuffer, array, buffer

readme

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v3.0.5 - 2024-12-16

Commits

  • [types] use shared config 6180b31
  • [actions] split out node 10-20, and 20+ 1ea4712
  • [Dev Deps] update @ljharb/eslint-config, @ljharb/tsconfig, @types/get-intrinsic, @types/object-inspect, @types/tape, auto-changelog, es-value-fixtures, object-inspect, tape de2b6ab
  • [Deps] update call-bind, get-intrinsic 55b80a1
  • [Deps] update call-bind, get-intrinsic 184484a
  • [Dev Deps] update available-typed-arrays, tape 81582a7
  • [Tests] add @arethetypeswrong/cli 6d67841
  • [Refactor] use call-bound directly dd0bad1
  • [Tests] replace aud with npm audit 99b62d1
  • [Dev Deps] remove obsolete DT package 9fc6971
  • [Dev Deps] add missing peer dep a3b8dbb

v3.0.4 - 2024-02-02

Commits

v3.0.3 - 2024-02-02

Commits

  • [Fix] TAs can take a DataView in node 0.8; use a simpler check 69a03f6
  • [Dev Deps] update aud, available-typed-arrays, npmignore, object-inspect, tape 53ca341
  • [Deps] update call-bind, get-intrinsic, is-typed-array bec883f
  • [Dev Deps] update @ljharb/eslint-config, aud, tape 944d4ce
  • [meta] add missing engines.node 0852be6
  • [Deps] update get-intrinsic b59c4af

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

v3.0.1 - 2023-01-05

Commits

  • [Fix] in node 0.8, TAs do not coerce Uint8Arrays to an ArrayBuffer properly e488763
  • [Dev Deps] update @ljharb/eslint-config, aud 8eebfa2

v3.0.0 - 2023-01-04

Commits

  • [Breaking] replace package implementation b65f929
  • Initial implementation, tests, readme 06afa73
  • Initial commit 051813f
  • npm init 946d3de
  • [meta] use npmignore to autogenerate an npmignore file ca4c446
  • Only apps should have lockfiles be7d8eb
  • docs: fix badge link 9ea7fb6

2.0.0 (Feb 12, 2021)

  • Refactor in TypeScript.
  • Drop the dist directory.
  • Drop the UMD bundled file.
  • Add a declaration file for TypeScript.

1.0.1 (Apr 1, 2018)

  • Improve code style.

1.0.0 (Jul 25, 2017)

  • Supports UMD, CommonJS and ES Module.

0.1.0 (Nov 28, 2015)

  • Check if ArrayBuffer is defined first.

0.0.1 (Nov 11, 2015)

  • Initial release.