source: imaps-frontend/node_modules/which-typed-array/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 3.4 KB
Line 
1# which-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][deps-svg]][deps-url]
6[![dev dependency status][dev-deps-svg]][dev-deps-url]
7[![License][license-image]][license-url]
8[![Downloads][downloads-image]][downloads-url]
9
10[![npm badge][npm-badge-png]][package-url]
11
12Which kind of Typed Array is this JavaScript value? Works cross-realm, without `instanceof`, and despite Symbol.toStringTag.
13
14## Example
15
16```js
17var whichTypedArray = require('which-typed-array');
18var assert = require('assert');
19
20assert.equal(false, whichTypedArray(undefined));
21assert.equal(false, whichTypedArray(null));
22assert.equal(false, whichTypedArray(false));
23assert.equal(false, whichTypedArray(true));
24assert.equal(false, whichTypedArray([]));
25assert.equal(false, whichTypedArray({}));
26assert.equal(false, whichTypedArray(/a/g));
27assert.equal(false, whichTypedArray(new RegExp('a', 'g')));
28assert.equal(false, whichTypedArray(new Date()));
29assert.equal(false, whichTypedArray(42));
30assert.equal(false, whichTypedArray(NaN));
31assert.equal(false, whichTypedArray(Infinity));
32assert.equal(false, whichTypedArray(new Number(42)));
33assert.equal(false, whichTypedArray('foo'));
34assert.equal(false, whichTypedArray(Object('foo')));
35assert.equal(false, whichTypedArray(function () {}));
36assert.equal(false, whichTypedArray(function* () {}));
37assert.equal(false, whichTypedArray(x => x * x));
38assert.equal(false, whichTypedArray([]));
39
40assert.equal('Int8Array', whichTypedArray(new Int8Array()));
41assert.equal('Uint8Array', whichTypedArray(new Uint8Array()));
42assert.equal('Uint8ClampedArray', whichTypedArray(new Uint8ClampedArray()));
43assert.equal('Int16Array', whichTypedArray(new Int16Array()));
44assert.equal('Uint16Array', whichTypedArray(new Uint16Array()));
45assert.equal('Int32Array', whichTypedArray(new Int32Array()));
46assert.equal('Uint32Array', whichTypedArray(new Uint32Array()));
47assert.equal('Float32Array', whichTypedArray(new Float32Array()));
48assert.equal('Float64Array', whichTypedArray(new Float64Array()));
49assert.equal('BigInt64Array', whichTypedArray(new BigInt64Array()));
50assert.equal('BigUint64Array', whichTypedArray(new BigUint64Array()));
51```
52
53## Tests
54Simply clone the repo, `npm install`, and run `npm test`
55
56[package-url]: https://npmjs.org/package/which-typed-array
57[npm-version-svg]: https://versionbadg.es/inspect-js/which-typed-array.svg
58[deps-svg]: https://david-dm.org/inspect-js/which-typed-array.svg
59[deps-url]: https://david-dm.org/inspect-js/which-typed-array
60[dev-deps-svg]: https://david-dm.org/inspect-js/which-typed-array/dev-status.svg
61[dev-deps-url]: https://david-dm.org/inspect-js/which-typed-array#info=devDependencies
62[npm-badge-png]: https://nodei.co/npm/which-typed-array.png?downloads=true&stars=true
63[license-image]: https://img.shields.io/npm/l/which-typed-array.svg
64[license-url]: LICENSE
65[downloads-image]: https://img.shields.io/npm/dm/which-typed-array.svg
66[downloads-url]: https://npm-stat.com/charts.html?package=which-typed-array
67[codecov-image]: https://codecov.io/gh/inspect-js/which-typed-array/branch/main/graphs/badge.svg
68[codecov-url]: https://app.codecov.io/gh/inspect-js/which-typed-array/
69[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/which-typed-array
70[actions-url]: https://github.com/inspect-js/which-typed-array/actions
Note: See TracBrowser for help on using the repository browser.