Bakhtina Sofya b84cb877be 1st comm | 3 weeks ago | |
---|---|---|
.. | ||
.github | 3 weeks ago | |
test | 3 weeks ago | |
.editorconfig | 3 weeks ago | |
.eslintrc | 3 weeks ago | |
.nycrc | 3 weeks ago | |
CHANGELOG.md | 3 weeks ago | |
LICENSE | 3 weeks ago | |
README.md | 3 weeks ago | |
index.d.ts | 3 weeks ago | |
index.js | 3 weeks ago | |
package.json | 3 weeks ago | |
tsconfig.json | 3 weeks ago |
[![dependency status][5]][6] [![dev dependency status][7]][8]
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.
var isTypedArray = require('is-typed-array');
var assert = require('assert');
assert.equal(false, isTypedArray(undefined));
assert.equal(false, isTypedArray(null));
assert.equal(false, isTypedArray(false));
assert.equal(false, isTypedArray(true));
assert.equal(false, isTypedArray([]));
assert.equal(false, isTypedArray({}));
assert.equal(false, isTypedArray(/a/g));
assert.equal(false, isTypedArray(new RegExp('a', 'g')));
assert.equal(false, isTypedArray(new Date()));
assert.equal(false, isTypedArray(42));
assert.equal(false, isTypedArray(NaN));
assert.equal(false, isTypedArray(Infinity));
assert.equal(false, isTypedArray(new Number(42)));
assert.equal(false, isTypedArray('foo'));
assert.equal(false, isTypedArray(Object('foo')));
assert.equal(false, isTypedArray(function () {}));
assert.equal(false, isTypedArray(function* () {}));
assert.equal(false, isTypedArray(x => x * x));
assert.equal(false, 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()));
assert.ok(isTypedArray(new BigInt64Array()));
assert.ok(isTypedArray(new BigUint64Array()));
Simply clone the repo, npm install
, and run npm test