[d565449] | 1 | # is-data-view <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 DataView? 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 isDataView = require('is-data-view');
|
---|
| 16 | var assert = require('assert');
|
---|
| 17 |
|
---|
| 18 | assert.equal(false, isDataView(undefined));
|
---|
| 19 | assert.equal(false, isDataView(null));
|
---|
| 20 | assert.equal(false, isDataView(false));
|
---|
| 21 | assert.equal(false, isDataView(true));
|
---|
| 22 | assert.equal(false, isDataView([]));
|
---|
| 23 | assert.equal(false, isDataView({}));
|
---|
| 24 | assert.equal(false, isDataView(/a/g));
|
---|
| 25 | assert.equal(false, isDataView(new RegExp('a', 'g')));
|
---|
| 26 | assert.equal(false, isDataView(new Date()));
|
---|
| 27 | assert.equal(false, isDataView(42));
|
---|
| 28 | assert.equal(false, isDataView(NaN));
|
---|
| 29 | assert.equal(false, isDataView(Infinity));
|
---|
| 30 | assert.equal(false, isDataView(new Number(42)));
|
---|
| 31 | assert.equal(false, isDataView('foo'));
|
---|
| 32 | assert.equal(false, isDataView(Object('foo')));
|
---|
| 33 | assert.equal(false, isDataView(function () {}));
|
---|
| 34 | assert.equal(false, isDataView(function* () {}));
|
---|
| 35 | assert.equal(false, isDataView(x => x * x));
|
---|
| 36 | assert.equal(false, isDataView([]));
|
---|
| 37 | assert.equal(false, isDataView(new Int8Array()));
|
---|
| 38 | assert.equal(false, isDataView(new Uint8Array()));
|
---|
| 39 | assert.equal(false, isDataView(new Uint8ClampedArray()));
|
---|
| 40 | assert.equal(false, isDataView(new Int16Array()));
|
---|
| 41 | assert.equal(false, isDataView(new Uint16Array()));
|
---|
| 42 | assert.equal(false, isDataView(new Int32Array()));
|
---|
| 43 | assert.equal(false, isDataView(new Uint32Array()));
|
---|
| 44 | assert.equal(false, isDataView(new Float32Array()));
|
---|
| 45 | assert.equal(false, isDataView(new Float64Array()));
|
---|
| 46 | assert.equal(false, isDataView(new BigInt64Array()));
|
---|
| 47 | assert.equal(false, isDataView(new BigUint64Array()));
|
---|
| 48 |
|
---|
| 49 | assert.ok(isDataView(new DataView(new ArrayBuffer(0))));
|
---|
| 50 | ```
|
---|
| 51 |
|
---|
| 52 | ## Tests
|
---|
| 53 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
| 54 |
|
---|
| 55 | [package-url]: https://npmjs.org/package/is-data-view
|
---|
| 56 | [npm-version-svg]: https://versionbadg.es/inspect-js/is-data-view.svg
|
---|
| 57 | [deps-svg]: https://david-dm.org/inspect-js/is-data-view.svg
|
---|
| 58 | [deps-url]: https://david-dm.org/inspect-js/is-data-view
|
---|
| 59 | [dev-deps-svg]: https://david-dm.org/inspect-js/is-data-view/dev-status.svg
|
---|
| 60 | [dev-deps-url]: https://david-dm.org/inspect-js/is-data-view#info=devDependencies
|
---|
| 61 | [npm-badge-png]: https://nodei.co/npm/is-data-view.png?downloads=true&stars=true
|
---|
| 62 | [license-image]: https://img.shields.io/npm/l/is-data-view.svg
|
---|
| 63 | [license-url]: LICENSE
|
---|
| 64 | [downloads-image]: https://img.shields.io/npm/dm/is-data-view.svg
|
---|
| 65 | [downloads-url]: https://npm-stat.com/charts.html?package=is-data-view
|
---|
| 66 | [codecov-image]: https://codecov.io/gh/inspect-js/is-data-view/branch/main/graphs/badge.svg
|
---|
| 67 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-data-view/
|
---|
| 68 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-data-view
|
---|
| 69 | [actions-url]: https://github.com/inspect-js/is-data-view/actions
|
---|