{"id":18277658,"url":"https://github.com/inspect-js/typed-array-byte-length","last_synced_at":"2025-04-05T04:30:42.794Z","repository":{"id":181307467,"uuid":"666250341","full_name":"inspect-js/typed-array-byte-length","owner":"inspect-js","description":"Get the byte length of a Typed Array, even in engines without a `.byteLength` method.","archived":false,"fork":false,"pushed_at":"2024-12-17T22:33:10.000Z","size":41,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T17:08:35.295Z","etag":null,"topics":["array","bytelength","typed","typed-array"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inspect-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ljharb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":"npm/deep-equal","community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2023-07-14T04:13:35.000Z","updated_at":"2024-12-17T22:33:14.000Z","dependencies_parsed_at":"2025-01-15T06:46:46.885Z","dependency_job_id":"029aeea9-c1ce-432b-9646-59d876b423aa","html_url":"https://github.com/inspect-js/typed-array-byte-length","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"ca29c46795620d624bcb6cbdbc32c1b0580ab0f8"},"previous_names":["inspect-js/typed-array-byte-length"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspect-js%2Ftyped-array-byte-length","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspect-js%2Ftyped-array-byte-length/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspect-js%2Ftyped-array-byte-length/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspect-js%2Ftyped-array-byte-length/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inspect-js","download_url":"https://codeload.github.com/inspect-js/typed-array-byte-length/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289382,"owners_count":20914463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","bytelength","typed","typed-array"],"created_at":"2024-11-05T12:19:57.292Z","updated_at":"2025-04-05T04:30:40.022Z","avatar_url":"https://github.com/inspect-js.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ljharb","https://tidelift.com/funding/github/npm/deep-equal"],"categories":[],"sub_categories":[],"readme":"# typed-array-byte-offset \u003csup\u003e[![Version Badge][npm-version-svg]][package-url]\u003c/sup\u003e\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nRobustly 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.\n\n## Example\n\n```js\nvar typedArrayByteOffset = require('typed-array-byte-offset');\nvar assert = require('assert');\n\nassert.equal(false, typedArrayByteOffset(undefined));\nassert.equal(false, typedArrayByteOffset(null));\nassert.equal(false, typedArrayByteOffset(false));\nassert.equal(false, typedArrayByteOffset(true));\nassert.equal(false, typedArrayByteOffset([]));\nassert.equal(false, typedArrayByteOffset({}));\nassert.equal(false, typedArrayByteOffset(/a/g));\nassert.equal(false, typedArrayByteOffset(new RegExp('a', 'g')));\nassert.equal(false, typedArrayByteOffset(new Date()));\nassert.equal(false, typedArrayByteOffset(42));\nassert.equal(false, typedArrayByteOffset(NaN));\nassert.equal(false, typedArrayByteOffset(Infinity));\nassert.equal(false, typedArrayByteOffset(new Number(42)));\nassert.equal(false, typedArrayByteOffset('foo'));\nassert.equal(false, typedArrayByteOffset(Object('foo')));\nassert.equal(false, typedArrayByteOffset(function () {}));\nassert.equal(false, typedArrayByteOffset(function* () {}));\nassert.equal(false, typedArrayByteOffset(x =\u003e x * x));\nassert.equal(false, typedArrayByteOffset([]));\n\nconst buffer = new ArrayBuffer(32);\n\nassert.equal(8, typedArrayByteOffset(new Int8Array(buffer, 8)));\nassert.equal(8, typedArrayByteOffset(new Uint8Array(buffer, 8)));\nassert.equal(8, typedArrayByteOffset(new Uint8ClampedArray(buffer, 8)));\nassert.equal(4, typedArrayByteOffset(new Int16Array(buffer, 4)));\nassert.equal(4, typedArrayByteOffset(new Uint16Array(buffer, 4)));\nassert.equal(8, typedArrayByteOffset(new Int32Array(buffer, 8)));\nassert.equal(8, typedArrayByteOffset(new Uint32Array(buffer, 8)));\nassert.equal(16, typedArrayByteOffset(new Float32Array(buffer, 16)));\nassert.equal(16, typedArrayByteOffset(new Float64Array(buffer, 16)));\nassert.equal(16, typedArrayByteOffset(new BigInt64Array(buffer, 16)));\nassert.equal(16, typedArrayByteOffset(new BigUint64Array(buffer, 16)));\n```\n\n## Tests\nSimply clone the repo, `npm install`, and run `npm test`\n\n[package-url]: https://npmjs.org/package/typed-array-byte-offset\n[npm-version-svg]: https://versionbadg.es/inspect-js/typed-array-byte-offset.svg\n[deps-svg]: https://david-dm.org/inspect-js/typed-array-byte-offset.svg\n[deps-url]: https://david-dm.org/inspect-js/typed-array-byte-offset\n[dev-deps-svg]: https://david-dm.org/inspect-js/typed-array-byte-offset/dev-status.svg\n[dev-deps-url]: https://david-dm.org/inspect-js/typed-array-byte-offset#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/typed-array-byte-offset.png?downloads=true\u0026stars=true\n[license-image]: https://img.shields.io/npm/l/typed-array-byte-offset.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/typed-array-byte-offset.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=typed-array-byte-offset\n[codecov-image]: https://codecov.io/gh/inspect-js/typed-array-byte-offset/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/inspect-js/typed-array-byte-offset/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/typed-array-byte-offset\n[actions-url]: https://github.com/inspect-js/typed-array-byte-offset/actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finspect-js%2Ftyped-array-byte-length","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finspect-js%2Ftyped-array-byte-length","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finspect-js%2Ftyped-array-byte-length/lists"}