1 | # data-view-byte-length <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
2 |
|
---|
3 | [![github actions][actions-image]][actions-url]
|
---|
4 | [![coverage][codecov-image]][codecov-url]
|
---|
5 | [![License][license-image]][license-url]
|
---|
6 | [![Downloads][downloads-image]][downloads-url]
|
---|
7 |
|
---|
8 | [![npm badge][npm-badge-png]][package-url]
|
---|
9 |
|
---|
10 | Get the `byteLength` out of a DataView, robustly.
|
---|
11 |
|
---|
12 | This will work in node <= 0.10 and < 0.11.4, where there's no prototype accessor, only a nonconfigurable own property.
|
---|
13 | It will also work in modern engines where `DataView.prototype.byteLength` has been deleted after this module has loaded.
|
---|
14 |
|
---|
15 | ## Example
|
---|
16 |
|
---|
17 | ```js
|
---|
18 | const dataViewByteLength = require('data-view-byte-length');
|
---|
19 | const assert = require('assert');
|
---|
20 |
|
---|
21 | const ab = new ArrayBuffer(42);
|
---|
22 | const dv = new DataView(ab);
|
---|
23 | assert.equal(dataViewByteLength(dv), 42);
|
---|
24 | ```
|
---|
25 |
|
---|
26 | ## Tests
|
---|
27 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
28 |
|
---|
29 | [package-url]: https://npmjs.org/package/data-view-byte-length
|
---|
30 | [npm-version-svg]: https://versionbadg.es/ljharb/data-view-byte-length.svg
|
---|
31 | [deps-svg]: https://david-dm.org/ljharb/data-view-byte-length.svg
|
---|
32 | [deps-url]: https://david-dm.org/ljharb/data-view-byte-length
|
---|
33 | [dev-deps-svg]: https://david-dm.org/ljharb/data-view-byte-length/dev-status.svg
|
---|
34 | [dev-deps-url]: https://david-dm.org/ljharb/data-view-byte-length#info=devDependencies
|
---|
35 | [npm-badge-png]: https://nodei.co/npm/data-view-byte-length.png?downloads=true&stars=true
|
---|
36 | [license-image]: https://img.shields.io/npm/l/data-view-byte-length.svg
|
---|
37 | [license-url]: LICENSE
|
---|
38 | [downloads-image]: https://img.shields.io/npm/dm/data-view-byte-length.svg
|
---|
39 | [downloads-url]: https://npm-stat.com/charts.html?package=data-view-byte-length
|
---|
40 | [codecov-image]: https://codecov.io/gh/ljharb/data-view-byte-length/branch/main/graphs/badge.svg
|
---|
41 | [codecov-url]: https://app.codecov.io/gh/ljharb/data-view-byte-length/
|
---|
42 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/data-view-byte-length
|
---|
43 | [actions-url]: https://github.com/ljharb/data-view-byte-length/actions
|
---|