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

Package detail

is-typed-array

inspect-js179.8mMIT1.1.15TypeScript support: included

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.

array, TypedArray, typed array, is, typed, Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, ES6, toStringTag, Symbol.toStringTag, @@toStringTag

readme

is-typed-array Version Badge

github actions coverage [![dependency status][5]][6] [![dev dependency status][7]][8] License Downloads

npm badge

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.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()));

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.1.15 - 2024-12-18

Commits

v1.1.14 - 2024-12-17

Commits

  • [types] use shared config eafa7fa
  • [actions] split out node 10-20, and 20+ cd6d5a3
  • [types] use which-typed-array’s TypedArray type; re-export it d7d9fcd
  • [Dev Deps] update @arethetypeswrong/cli, @ljharb/eslint-config, @ljharb/tsconfig, @types/node, @types/object-inspect, @types/tape, auto-changelog, object-inspect, tape 65afb42
  • [Dev Deps] update @types/node, has-tostringtag, tape 9e27ddd
  • [Tests] replace aud with npm audit ad4defe
  • [Tests] use @arethetypeswrong/cli ac4bcca
  • [Deps] update which-typed-array c298129
  • [Deps] update which-typed-array 744c29a
  • [Dev Deps] add missing peer dep 94d2f5a

v1.1.13 - 2024-02-01

Commits

  • [patch] add types 8a8a679
  • [Dev Deps] update aud, has-tostringtag, npmignore, object-inspect, tape 8146b60
  • [actions] optimize finishers 34f875a
  • [Deps] update which-typed-array 19c974f
  • [meta] add sideEffects flag 0b68e5e

v1.1.12 - 2023-07-17

Commits

  • [Refactor] use which-typed-array for all internals 7619405

v1.1.11 - 2023-07-17

Commits

  • [Fix] node < v0.6 lacks proper Object toString behavior c94b90d
  • [Robustness] use call-bind 573b00b
  • [Dev Deps] update @ljharb/eslint-config, aud, object-inspect, tape c88c2d4

v1.1.10 - 2022-11-02

Commits

1.1.9 / 2022-05-13

  • [Refactor] use foreach instead of for-each
  • [readme] markdown URL cleanup
  • [Deps] update es-abstract
  • [meta] use npmignore to autogenerate an npmignore file
  • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, safe-publish-latest, tape
  • [actions] reuse common workflows
  • [actions] update codecov uploader

1.1.8 / 2021-08-30

  • [Refactor] use globalThis if available (#53)
  • [Deps] update available-typed-arrays
  • [Dev Deps] update @ljharb/eslint-config

1.1.7 / 2021-08-07

  • [Fix] if Symbol.toStringTag exists but is not present, use Object.prototype.toString
  • [Dev Deps] update is-callable, tape

1.1.6 / 2021-08-05

  • [Fix] use has-tostringtag to behave correctly in the presence of symbol shams
  • [readme] add actions and codecov badges
  • [meta] use prepublishOnly script for npm 7+
  • [Deps] update available-typed-arrays, es-abstract
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, tape
  • [actions] use node/install instead of node/run; use codecov action

1.1.5 / 2021-02-14

  • [meta] do not publish github action workflow files or nyc output
  • [Deps] update call-bind, es-abstract
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, is-callable, tape

1.1.4 / 2020-12-05

  • [readme] fix repo URLs, remove defunct badges
  • [Deps] update available-typed-arrays, es-abstract; use call-bind where applicable
  • [meta] gitignore nyc output
  • [meta] only audit prod deps
  • [actions] add "Allow Edits" workflow
  • [actions] switch Automatic Rebase workflow to pull_request_target event
  • [Dev Deps] update eslint, @ljharb/eslint-config, is-callable, make-arrow-function, make-generator-function, object-inspect, tape; add aud
  • [Tests] migrate tests to Github Actions
  • [Tests] run nyc on all tests

1.1.3 / 2020-01-24

  • [Refactor] use es-abstract’s callBound, available-typed-arrays, has-symbols

1.1.2 / 2020-01-20

  • [Fix] in envs without Symbol.toStringTag, dc8a8cc made arrays return true
  • [Tests] add evalmd to prelint

1.1.1 / 2020-01-18

  • [Robustness] don’t rely on Array.prototype.indexOf existing
  • [meta] remove unused Makefile and associated utilities
  • [meta] add funding field; create FUNDING.yml
  • [actions] add automatic rebasing / merge commit blocking
  • [Dev Deps] update eslint, @ljharb/eslint-config, is-callable, replace, semver, tape; add safe-publish-latest
  • [Tests] use shared travis-ci configs
  • [Tests] use npx aud instead of nsp or npm audit with hoops

1.1.0 / 2019-02-16

  • [New] add BigInt64Array and BigUint64Array
  • [Refactor] use an array instead of an object for storing Typed Array names
  • [meta] ignore test.html
  • [Tests] up to node v11.10, v10.15, v8.15, v7.10, v6.16, v5.10, v4.9
  • [Tests] remove jscs
  • [Tests] use npm audit instead of nsp
  • [Dev Deps] update eslint,@ljharb/eslint-config, is-callable, tape, replace, semver
  • [Dev Deps] remove unused eccheck script + dep

1.0.4 / 2016-03-19

  • [Fix] Symbol.toStringTag is on the super-[[Prototype]] of Float32Array, not the [[Prototype]] (#3)
  • [Tests] up to node v5.9, v4.4
  • [Tests] use pretest/posttest for linting/security
  • [Dev Deps] update tape, jscs, nsp, eslint, @ljharb/eslint-config, semver, is-callable

1.0.3 / 2015-10-13

  • [Deps] Add missing foreach dependency (#1)

1.0.2 / 2015-10-05

  • [Deps] Remove unneeded "isarray" dependency
  • [Dev Deps] update eslint, @ljharb/eslint-config

1.0.1 / 2015-10-02

  • Rerelease: avoid instanceof and the constructor property; work cross-realm; work with Symbol.toStringTag.

1.0.0 / 2015-05-06

  • Initial release.