source: imaps-frontend/node_modules/typed-array-length/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: 2.7 KB
Line 
1# typed-array-length <sup>[![Version Badge][2]][1]</sup>
2
3[![dependency status][5]][6]
4[![dev dependency status][7]][8]
5[![License][license-image]][license-url]
6[![Downloads][downloads-image]][downloads-url]
7
8[![npm badge][11]][1]
9
10Robustly get the length of a Typed Array, or `false` if it is not a Typed Array. Works cross-realm, in every engine, even if the `length` property is overridden.
11
12## Example
13
14```js
15var typedArrayLength = require('typed-array-length');
16var assert = require('assert');
17
18assert.equal(false, typedArrayLength(undefined));
19assert.equal(false, typedArrayLength(null));
20assert.equal(false, typedArrayLength(false));
21assert.equal(false, typedArrayLength(true));
22assert.equal(false, typedArrayLength([]));
23assert.equal(false, typedArrayLength({}));
24assert.equal(false, typedArrayLength(/a/g));
25assert.equal(false, typedArrayLength(new RegExp('a', 'g')));
26assert.equal(false, typedArrayLength(new Date()));
27assert.equal(false, typedArrayLength(42));
28assert.equal(false, typedArrayLength(NaN));
29assert.equal(false, typedArrayLength(Infinity));
30assert.equal(false, typedArrayLength(new Number(42)));
31assert.equal(false, typedArrayLength('foo'));
32assert.equal(false, typedArrayLength(Object('foo')));
33assert.equal(false, typedArrayLength(function () {}));
34assert.equal(false, typedArrayLength(function* () {}));
35assert.equal(false, typedArrayLength(x => x * x));
36assert.equal(false, typedArrayLength([]));
37
38assert.equal(1, typedArrayLength(new Int8Array(1)));
39assert.equal(2, typedArrayLength(new Uint8Array(2)));
40assert.equal(3, typedArrayLength(new Uint8ClampedArray(3)));
41assert.equal(4, typedArrayLength(new Int16Array(4)));
42assert.equal(5, typedArrayLength(new Uint16Array(5)));
43assert.equal(6, typedArrayLength(new Int32Array(6)));
44assert.equal(7, typedArrayLength(new Uint32Array(7)));
45assert.equal(8, typedArrayLength(new Float32Array(8)));
46assert.equal(9, typedArrayLength(new Float64Array(9)));
47assert.equal(10, typedArrayLength(new BigInt64Array(10)));
48assert.equal(11, typedArrayLength(new BigUint64Array(11)));
49```
50
51## Tests
52Simply clone the repo, `npm install`, and run `npm test`
53
54[1]: https://npmjs.org/package/typed-array-length
55[2]: https://versionbadg.es/inspect-js/typed-array-length.svg
56[5]: https://david-dm.org/inspect-js/typed-array-length.svg
57[6]: https://david-dm.org/inspect-js/typed-array-length
58[7]: https://david-dm.org/inspect-js/typed-array-length/dev-status.svg
59[8]: https://david-dm.org/inspect-js/typed-array-length#info=devDependencies
60[11]: https://nodei.co/npm/typed-array-length.png?downloads=true&stars=true
61[license-image]: http://img.shields.io/npm/l/typed-array-length.svg
62[license-url]: LICENSE
63[downloads-image]: http://img.shields.io/npm/dm/typed-array-length.svg
64[downloads-url]: http://npm-stat.com/charts.html?package=typed-array-length
Note: See TracBrowser for help on using the repository browser.