which-typed-array (1.1.19)

Published 2026-02-24 14:08:37 +00:00 by atheaadmin

Installation

registry=
npm install which-typed-array@1.1.19
"which-typed-array": "1.1.19"

About this package

which-typed-array Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Which kind of Typed Array is this JavaScript value? Works cross-realm, without instanceof, and despite Symbol.toStringTag.

Example

var whichTypedArray = require('which-typed-array');
var assert = require('assert');

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

assert.equal('Int8Array', whichTypedArray(new Int8Array()));
assert.equal('Uint8Array', whichTypedArray(new Uint8Array()));
assert.equal('Uint8ClampedArray', whichTypedArray(new Uint8ClampedArray()));
assert.equal('Int16Array', whichTypedArray(new Int16Array()));
assert.equal('Uint16Array', whichTypedArray(new Uint16Array()));
assert.equal('Int32Array', whichTypedArray(new Int32Array()));
assert.equal('Uint32Array', whichTypedArray(new Uint32Array()));
assert.equal('Float32Array', whichTypedArray(new Float32Array()));
assert.equal('Float64Array', whichTypedArray(new Float64Array()));
assert.equal('BigInt64Array', whichTypedArray(new BigInt64Array()));
assert.equal('BigUint64Array', whichTypedArray(new BigUint64Array()));

Tests

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

Dependencies

Dependencies

ID Version
available-typed-arrays ^1.0.7
call-bind ^1.0.8
call-bound ^1.0.4
for-each ^0.3.5
get-proto ^1.0.1
gopd ^1.2.0
has-tostringtag ^1.0.2

Development Dependencies

ID Version
@arethetypeswrong/cli ^0.17.4
@ljharb/eslint-config ^21.1.1
@ljharb/tsconfig ^0.3.2
@types/call-bind ^1.0.5
@types/for-each ^0.3.3
@types/gopd ^1.0.3
@types/is-callable ^1.1.2
@types/make-arrow-function ^1.2.2
@types/make-generator-function ^2.0.3
@types/tape ^5.8.1
auto-changelog ^2.5.0
encoding ^0.1.13
eslint =8.8.0
in-publish ^2.0.1
is-callable ^1.2.7
make-arrow-function ^1.2.0
make-generator-function ^2.0.0
npmignore ^0.3.1
nyc ^10.3.2
safe-publish-latest ^2.0.0
tape ^5.9.0
typescript next

Keywords

array TypedArray typed array which typed Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array ES6 toStringTag Symbol.toStringTag @@toStringTag
Details
npm
2026-02-24 14:08:37 +00:00
0
Jordan Harband
MIT
latest
13 KiB
Assets (1)
Versions (1) View all
1.1.19 2026-02-24