1 | # is-array-buffer <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
2 |
|
---|
3 | [![github actions][actions-image]][actions-url]
|
---|
4 | [![coverage][codecov-image]][codecov-url]
|
---|
5 | [![License][license-image]][license-url]
|
---|
6 | [![Downloads][downloads-image]][downloads-url]
|
---|
7 |
|
---|
8 | [![npm badge][npm-badge-png]][package-url]
|
---|
9 |
|
---|
10 | 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.
|
---|
11 |
|
---|
12 | ## Example
|
---|
13 |
|
---|
14 | ```js
|
---|
15 | var assert = require('assert');
|
---|
16 | var isArrayBuffer = require('is-array-buffer');
|
---|
17 |
|
---|
18 | assert(!isArrayBuffer(function () {}));
|
---|
19 | assert(!isArrayBuffer(null));
|
---|
20 | assert(!isArrayBuffer(function* () { yield 42; return Infinity; });
|
---|
21 | assert(!isArrayBuffer(Symbol('foo')));
|
---|
22 | assert(!isArrayBuffer(1n));
|
---|
23 | assert(!isArrayBuffer(Object(1n)));
|
---|
24 |
|
---|
25 | assert(!isArrayBuffer(new Set()));
|
---|
26 | assert(!isArrayBuffer(new WeakSet()));
|
---|
27 | assert(!isArrayBuffer(new Map()));
|
---|
28 | assert(!isArrayBuffer(new WeakMap()));
|
---|
29 | assert(!isArrayBuffer(new WeakRef({})));
|
---|
30 | assert(!isArrayBuffer(new FinalizationRegistry(() => {})));
|
---|
31 | assert(!isArrayBuffer(new SharedArrayBuffer()));
|
---|
32 |
|
---|
33 | assert(isArrayBuffer(new ArrayBuffer()));
|
---|
34 |
|
---|
35 | class MyArrayBuffer extends ArrayBuffer {}
|
---|
36 | assert(isArrayBuffer(new MyArrayBuffer()));
|
---|
37 | ```
|
---|
38 |
|
---|
39 | ## Tests
|
---|
40 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
41 |
|
---|
42 | [package-url]: https://npmjs.org/package/is-array-buffer
|
---|
43 | [npm-version-svg]: https://versionbadg.es/inspect-js/is-array-buffer.svg
|
---|
44 | [deps-svg]: https://david-dm.org/inspect-js/is-array-buffer.svg
|
---|
45 | [deps-url]: https://david-dm.org/inspect-js/is-array-buffer
|
---|
46 | [dev-deps-svg]: https://david-dm.org/inspect-js/is-array-buffer/dev-status.svg
|
---|
47 | [dev-deps-url]: https://david-dm.org/inspect-js/is-array-buffer#info=devDependencies
|
---|
48 | [npm-badge-png]: https://nodei.co/npm/is-array-buffer.png?downloads=true&stars=true
|
---|
49 | [license-image]: https://img.shields.io/npm/l/is-array-buffer.svg
|
---|
50 | [license-url]: LICENSE
|
---|
51 | [downloads-image]: https://img.shields.io/npm/dm/is-array-buffer.svg
|
---|
52 | [downloads-url]: https://npm-stat.com/charts.html?package=is-array-buffer
|
---|
53 | [codecov-image]: https://codecov.io/gh/inspect-js/is-array-buffer/branch/main/graphs/badge.svg
|
---|
54 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-array-buffer/
|
---|
55 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-array-buffer
|
---|
56 | [actions-url]: https://github.com/inspect-js/is-array-buffer/actions
|
---|