Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.eslintrc
.gitignore
.npmignore
.npmrc
.travis.yml
CHANGELOG.md
LICENSE
Makefile
README.md
index.js
package.json
test.js

README.md

is-typed-array Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on instanceof or mutable properties, and despite ES6 Symbol.toStringTag.

Example

var isTypedArray = require('is-typed-array');
var assert = require('assert');

assert.notOk(isTypedArray(undefined));
assert.notOk(isTypedArray(null));
assert.notOk(isTypedArray(false));
assert.notOk(isTypedArray(true));
assert.notOk(isTypedArray([]));
assert.notOk(isTypedArray({}));
assert.notOk(isTypedArray(/a/g));
assert.notOk(isTypedArray(new RegExp('a', 'g')));
assert.notOk(isTypedArray(new Date()));
assert.notOk(isTypedArray(42));
assert.notOk(isTypedArray(NaN));
assert.notOk(isTypedArray(Infinity));
assert.notOk(isTypedArray(new Number(42)));
assert.notOk(isTypedArray('foo'));
assert.notOk(isTypedArray(Object('foo')));
assert.notOk(isTypedArray(function () {}));
assert.notOk(isTypedArray(function* () {}));
assert.notOk(isTypedArray(x => x * x));
assert.notOk(isTypedArray([]));

assert.ok(isTypedArray(new Int8Array()));
assert.ok(isTypedArray(new Uint8Array()));
assert.ok(isTypedArray(new Uint8ClampedArray()));
assert.ok(isTypedArray(new Int16Array()));
assert.ok(isTypedArray(new Uint16Array()));
assert.ok(isTypedArray(new Int32Array()));
assert.ok(isTypedArray(new Uint32Array()));
assert.ok(isTypedArray(new Float32Array()));
assert.ok(isTypedArray(new Float64Array()));

Tests

Simply clone the repo, npm install, and run npm test