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

Package detail

is-data-view

inspect-js67.4mMIT1.0.2TypeScript support: included

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.

javascript, ecmascript, dataview, data, view, typedarray, typedarrays

readme

is-data-view Version Badge

github actions coverage License Downloads

npm badge

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.

Example

var isDataView = require('is-data-view');
var assert = require('assert');

assert.equal(false, isDataView(undefined));
assert.equal(false, isDataView(null));
assert.equal(false, isDataView(false));
assert.equal(false, isDataView(true));
assert.equal(false, isDataView([]));
assert.equal(false, isDataView({}));
assert.equal(false, isDataView(/a/g));
assert.equal(false, isDataView(new RegExp('a', 'g')));
assert.equal(false, isDataView(new Date()));
assert.equal(false, isDataView(42));
assert.equal(false, isDataView(NaN));
assert.equal(false, isDataView(Infinity));
assert.equal(false, isDataView(new Number(42)));
assert.equal(false, isDataView('foo'));
assert.equal(false, isDataView(Object('foo')));
assert.equal(false, isDataView(function () {}));
assert.equal(false, isDataView(function* () {}));
assert.equal(false, isDataView(x => x * x));
assert.equal(false, isDataView([]));
assert.equal(false, isDataView(new Int8Array()));
assert.equal(false, isDataView(new Uint8Array()));
assert.equal(false, isDataView(new Uint8ClampedArray()));
assert.equal(false, isDataView(new Int16Array()));
assert.equal(false, isDataView(new Uint16Array()));
assert.equal(false, isDataView(new Int32Array()));
assert.equal(false, isDataView(new Uint32Array()));
assert.equal(false, isDataView(new Float32Array()));
assert.equal(false, isDataView(new Float64Array()));
assert.equal(false, isDataView(new BigInt64Array()));
assert.equal(false, isDataView(new BigUint64Array()));

assert.ok(isDataView(new DataView(new ArrayBuffer(0))));

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.

v1.0.2 - 2024-12-11

Commits

  • [types] use shared config 3a80072
  • [actions] split out node 10-20, and 20+ e2f37fd
  • [Dev Deps] update @ljharb/eslint-config, @ljharb/tsconfig, @types/node, @types/object-inspect, @types/tape, auto-changelog, es-value-fixtures, object-inspect, tape 6f8e9dd
  • [Dev Deps] update @types/node, available-typed-arrays, tape 37be591
  • [Fix] add missing dependencies; use call-bound directly 34de4b5
  • [Tests] replace aud with npm audit aa7060a
  • [Dev Deps] add missing peer dep 3d302d7

v1.0.1 - 2024-02-02

Commits

  • [patch] add types c2728ef
  • [Dev Deps] update aud, available-typed-arrays, has-tostringtag, npmignore, object-inspect, tape e7f9ebc
  • [Deps] update is-typed-array 2ca9333

v1.0.0 - 2024-01-31

Commits