is-array-buffer
Is this value a JS ArrayBuffer?
Last updated 10 months ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install is-array-buffer 
SYNC missed versions from official npm registry.

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

Current Tags

  • 3.0.4                                ...           latest (10 months ago)

10 Versions

  • 3.0.4                                ...           10 months ago
  • 3.0.3                                ...           10 months ago
  • 3.0.2                                ...           2 years ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 0
Dependencies (2)
Dev Dependencies (20)

Copyright 2013 - present © cnpmjs.org | Home |