1 | # is-typed-array <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
2 |
|
---|
3 | [![github actions][actions-image]][actions-url]
|
---|
4 | [![coverage][codecov-image]][codecov-url]
|
---|
5 | [![dependency status][5]][6]
|
---|
6 | [![dev dependency status][7]][8]
|
---|
7 | [![License][license-image]][license-url]
|
---|
8 | [![Downloads][downloads-image]][downloads-url]
|
---|
9 |
|
---|
10 | [![npm badge][npm-badge-png]][package-url]
|
---|
11 |
|
---|
12 | 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.
|
---|
13 |
|
---|
14 | ## Example
|
---|
15 |
|
---|
16 | ```js
|
---|
17 | var isTypedArray = require('is-typed-array');
|
---|
18 | var assert = require('assert');
|
---|
19 |
|
---|
20 | assert.equal(false, isTypedArray(undefined));
|
---|
21 | assert.equal(false, isTypedArray(null));
|
---|
22 | assert.equal(false, isTypedArray(false));
|
---|
23 | assert.equal(false, isTypedArray(true));
|
---|
24 | assert.equal(false, isTypedArray([]));
|
---|
25 | assert.equal(false, isTypedArray({}));
|
---|
26 | assert.equal(false, isTypedArray(/a/g));
|
---|
27 | assert.equal(false, isTypedArray(new RegExp('a', 'g')));
|
---|
28 | assert.equal(false, isTypedArray(new Date()));
|
---|
29 | assert.equal(false, isTypedArray(42));
|
---|
30 | assert.equal(false, isTypedArray(NaN));
|
---|
31 | assert.equal(false, isTypedArray(Infinity));
|
---|
32 | assert.equal(false, isTypedArray(new Number(42)));
|
---|
33 | assert.equal(false, isTypedArray('foo'));
|
---|
34 | assert.equal(false, isTypedArray(Object('foo')));
|
---|
35 | assert.equal(false, isTypedArray(function () {}));
|
---|
36 | assert.equal(false, isTypedArray(function* () {}));
|
---|
37 | assert.equal(false, isTypedArray(x => x * x));
|
---|
38 | assert.equal(false, isTypedArray([]));
|
---|
39 |
|
---|
40 | assert.ok(isTypedArray(new Int8Array()));
|
---|
41 | assert.ok(isTypedArray(new Uint8Array()));
|
---|
42 | assert.ok(isTypedArray(new Uint8ClampedArray()));
|
---|
43 | assert.ok(isTypedArray(new Int16Array()));
|
---|
44 | assert.ok(isTypedArray(new Uint16Array()));
|
---|
45 | assert.ok(isTypedArray(new Int32Array()));
|
---|
46 | assert.ok(isTypedArray(new Uint32Array()));
|
---|
47 | assert.ok(isTypedArray(new Float32Array()));
|
---|
48 | assert.ok(isTypedArray(new Float64Array()));
|
---|
49 | assert.ok(isTypedArray(new BigInt64Array()));
|
---|
50 | assert.ok(isTypedArray(new BigUint64Array()));
|
---|
51 | ```
|
---|
52 |
|
---|
53 | ## Tests
|
---|
54 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
55 |
|
---|
56 | [package-url]: https://npmjs.org/package/is-typed-array
|
---|
57 | [npm-version-svg]: https://versionbadg.es/inspect-js/is-typed-array.svg
|
---|
58 | [deps-svg]: https://david-dm.org/inspect-js/is-typed-array.svg
|
---|
59 | [deps-url]: https://david-dm.org/inspect-js/is-typed-array
|
---|
60 | [dev-deps-svg]: https://david-dm.org/inspect-js/is-typed-array/dev-status.svg
|
---|
61 | [dev-deps-url]: https://david-dm.org/inspect-js/is-typed-array#info=devDependencies
|
---|
62 | [npm-badge-png]: https://nodei.co/npm/is-typed-array.png?downloads=true&stars=true
|
---|
63 | [license-image]: https://img.shields.io/npm/l/is-typed-array.svg
|
---|
64 | [license-url]: LICENSE
|
---|
65 | [downloads-image]: https://img.shields.io/npm/dm/is-typed-array.svg
|
---|
66 | [downloads-url]: https://npm-stat.com/charts.html?package=is-typed-array
|
---|
67 | [codecov-image]: https://codecov.io/gh/inspect-js/is-typed-array/branch/main/graphs/badge.svg
|
---|
68 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-typed-array/
|
---|
69 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-typed-array
|
---|
70 | [actions-url]: https://github.com/inspect-js/is-typed-array/actions
|
---|