Gathering detailed insights and metrics for @zitterorg/architecto-a-asperiores
Gathering detailed insights and metrics for @zitterorg/architecto-a-asperiores
Gathering detailed insights and metrics for @zitterorg/architecto-a-asperiores
Gathering detailed insights and metrics for @zitterorg/architecto-a-asperiores
npm install @zitterorg/architecto-a-asperiores
Typescript
Module System
Node Version
NPM Version
53.4
Supply Chain
80.8
Quality
85.9
Maintenance
100
Vulnerability
99.3
License
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
1
Compared to previous week
Last month
0%
5
Compared to previous month
Last year
0%
18
Compared to previous year
41
Robustly get the byte offset of a Typed Array, or false
if it is not a Typed Array. Works cross-realm, in every engine, even if the byteOffset
property is overridden.
1var typedArrayByteOffset = require('@zitterorg/architecto-a-asperiores');
2var assert = require('assert');
3
4assert.equal(false, typedArrayByteOffset(undefined));
5assert.equal(false, typedArrayByteOffset(null));
6assert.equal(false, typedArrayByteOffset(false));
7assert.equal(false, typedArrayByteOffset(true));
8assert.equal(false, typedArrayByteOffset([]));
9assert.equal(false, typedArrayByteOffset({}));
10assert.equal(false, typedArrayByteOffset(/a/g));
11assert.equal(false, typedArrayByteOffset(new RegExp('a', 'g')));
12assert.equal(false, typedArrayByteOffset(new Date()));
13assert.equal(false, typedArrayByteOffset(42));
14assert.equal(false, typedArrayByteOffset(NaN));
15assert.equal(false, typedArrayByteOffset(Infinity));
16assert.equal(false, typedArrayByteOffset(new Number(42)));
17assert.equal(false, typedArrayByteOffset('foo'));
18assert.equal(false, typedArrayByteOffset(Object('foo')));
19assert.equal(false, typedArrayByteOffset(function () {}));
20assert.equal(false, typedArrayByteOffset(function* () {}));
21assert.equal(false, typedArrayByteOffset(x => x * x));
22assert.equal(false, typedArrayByteOffset([]));
23
24const buffer = new ArrayBuffer(32);
25
26assert.equal(8, typedArrayByteOffset(new Int8Array(buffer, 8)));
27assert.equal(8, typedArrayByteOffset(new Uint8Array(buffer, 8)));
28assert.equal(8, typedArrayByteOffset(new Uint8ClampedArray(buffer, 8)));
29assert.equal(4, typedArrayByteOffset(new Int16Array(buffer, 4)));
30assert.equal(4, typedArrayByteOffset(new Uint16Array(buffer, 4)));
31assert.equal(8, typedArrayByteOffset(new Int32Array(buffer, 8)));
32assert.equal(8, typedArrayByteOffset(new Uint32Array(buffer, 8)));
33assert.equal(16, typedArrayByteOffset(new Float32Array(buffer, 16)));
34assert.equal(16, typedArrayByteOffset(new Float64Array(buffer, 16)));
35assert.equal(16, typedArrayByteOffset(new BigInt64Array(buffer, 16)));
36assert.equal(16, typedArrayByteOffset(new BigUint64Array(buffer, 16)));
Simply clone the repo, npm install
, and run npm test
No vulnerabilities found.
No security vulnerabilities found.