Get the byte length of a Typed Array, even in engines without a `.byteLength` method.
Installations
npm install typed-array-byte-length
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Min. Node Version
>= 0.4
Node Version
23.4.0
NPM Version
10.9.2
Score
98.2
Supply Chain
88.8
Quality
81.9
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
inspect-js
Download Statistics
Total Downloads
1,517,178,217
Last Day
5,041,412
Last Week
23,206,442
Last Month
102,572,957
Last Year
1,173,702,796
GitHub Statistics
22 Commits
1 Watching
1 Branches
1 Contributors
Bundle Size
18.85 kB
Minified
5.42 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
1.0.3
Package Id
typed-array-byte-length@1.0.3
Unpacked Size
18.01 kB
Size
6.17 kB
File Count
11
NPM Version
10.9.2
Node Version
23.4.0
Publised On
17 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
1,517,178,217
Last day
-4.6%
5,041,412
Compared to previous day
Last week
-14.5%
23,206,442
Compared to previous week
Last month
7.8%
102,572,957
Compared to previous month
Last year
241.7%
1,173,702,796
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
5
Dev Dependencies
26
typed-array-byte-offset
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.
Example
1var typedArrayByteOffset = require('typed-array-byte-offset');
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)));
Tests
Simply clone the repo, npm install
, and run npm test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/inspect-js/.github/SECURITY.md:1
- Info: Found linked content: github.com/inspect-js/.github/SECURITY.md:1
- Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy
- Info: Found text in security policy: github.com/inspect-js/.github/SECURITY.md:1
Reason
9 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 7
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/require-allow-edits.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/inspect-js/typed-array-byte-length/require-allow-edits.yml/main?enable=pin
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node-aught.yml:1
- Warn: no topLevel permission defined: .github/workflows/node-pretest.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/node-tens.yml:6
- Info: topLevel 'contents' permission set to 'read': .github/workflows/node-twenties.yml:6
- Warn: no topLevel permission defined: .github/workflows/rebase.yml:1
- Warn: no topLevel permission defined: .github/workflows/require-allow-edits.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
4.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to typed-array-byte-length
@nolyfill/typed-array-byte-length
@socketregistry/typed-array-byte-length
Socket.dev optimized package override for typed-array-byte-length
@womorg/ipsam-sint-eaque
> Dependency-less Test Runner for Node.js
@diotoborg/est-voluptate
![npm](https://img.shields.io/npm/dm/data-structure-typed) ![GitHub contributors](https://img.shields.io/github/contributors/diotoborg/est-voluptate) ![npm package minimized gzipped size (select exports)](https://img.shields.io/bundlejs/size/data-structur